[R] Train error:: subscript out of bonds

Neeti nikkihathi at gmail.com
Mon Jan 24 18:44:37 CET 2011


Hi,
I am trying to construct a svmpoly model using the "caret" package (please
see code below). Using the same data, without changing any setting, I am
just changing the seed value. Sometimes it constructs the model
successfully, and sometimes I get an “Error in indexes[[j]] : subscript out
of bounds”.
For example when I set seed to 357 following code produced result only for 8
iterations and for 9th iteration it reaches to an error that “subscript out
of bonds” error. I don’t understand why 

Any help would be great
thanks
#######
for (i in 1:10)
 {
fit1<-NULL;
x<-NULL;
 x<-which(number==i)
	trainset<-d[-x,]
	testset<-d[x,]
train1<-trainset[,-ncol(trainset)]
	train1<-train1[,-(1)]
	test_t<-testset[,-ncol(testset)]
	species_test<-as.factor(testset[,ncol(testset)])
	test_t<-test_t[,-(1)]
	####
	#CARET::TRAIN
	####
	
	fit1<-train(train1,as.factor(trainset[,ncol(trainset)]),"svmpoly",trControl
= trainControl((method = "cv"),10,verboseIter = F),tuneLength=3)
	pred<-predict(fit1,test_t)
	t_train[[i]]<-table(predicted=pred,observed=testset[,ncol(testset)])
tune_result[[i]]<-fit1$results;
	tune_best<-fit1$bestTune;
	scale1[i]<-tune_best[[3]]
	degree[i]<-tune_best[[2]]
	c1[i]<-tune_best[[1]]
	
	}
	

-- 
View this message in context: http://r.789695.n4.nabble.com/Train-error-subscript-out-of-bonds-tp3234510p3234510.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list