Hi, Dear all, I am just starting using R in my work and got some trouble to figure out some of the errors. Can anybody help me? The following is the script: read.csv('pupil.txt',header=TRUE,sep='\t')->pupil samp<-c(1:50, 112:162, 171:220, 228:278) pupil.nn2 <- nnet(Type ~ ., data = pupil, subset = samp, size = 2, rang = 0.1, decay = 5e-4, maxit = 200) table(pupil$Type[-samp], predict(pupil.nn2, pupil[-samp,], type = "class")) After running this, I got error information as #Error in switch(type, raw = z, class = { : # inappropriate fit for class BTW, pupil.txt X1 X2 Type 0.2 0.5 0 ........... .......... .........1 ......... ......... ..........2 ....... ........3 ........ there are totally 351 records. My objective is to classify them into 4 classes. Thanks a lot for your help!
I'm not a nnet() user, but after reading the help, there are two things you might try, both in the model formula passed to nnet() in the third line of code below. Alternate version: pupil.nn2 <- nnet( as.factor(Type) ~ X1 + X2, ... (with all the remaining arguments as before). I'm not sure which (if either) of these two variants might do the trick. - tom blackwell - u michigan medical school - ann arbor - On Thu, 17 Jul 2003, sbinny wrote:> The following is the script: > > read.csv('pupil.txt',header=TRUE,sep='\t')->pupil > samp<-c(1:50, 112:162, 171:220, 228:278) > pupil.nn2 <- nnet(Type ~ ., data = pupil, subset = samp, size = 2, rang = 0.1, decay = 5e-4, maxit = 200) > table(pupil$Type[-samp], predict(pupil.nn2, pupil[-samp,], type = "class")) > > There are totally 351 observations. > My objective is to classify them into 4 classes. > > Thanks a lot for your help!
Seemingly Similar Threads
- how to get actual value from predict in nnet?
- Training nnet in two ways, trying to understand the performance difference - with (i hope!) commented, minimal, self-contained, reproducible code
- modifying predict.nnet() to function with errorest()
- Translating R code + library into Fortran?
- accuracy of a neural net