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.
put options(error=utils::recover) in the script and when the error occurs use the browser to examine the values to see where the error is. On Mon, Jan 24, 2011 at 12:44 PM, Neeti <nikkihathi at gmail.com> wrote:> > 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?
What version of caret and R? We'll also need a reproducible example. On Mon, Jan 24, 2011 at 12:44 PM, Neeti <nikkihathi at gmail.com> wrote:> > 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Max
Version: R = 2.11.1 CARET = 4.68 -- View this message in context: http://r.789695.n4.nabble.com/Train-error-subscript-out-of-bonds-tp3234510p3236251.html Sent from the R help mailing list archive at Nabble.com.
after using options(error=utils::recover) option, following is the output. if i am correct this means that in ksvm there is some problem, but really could not understand. could anyone please tell me what is wrong... any help will be great .... thank you so much.. Enter a frame number, or 0 to exit 1: train(train1, as.factor(trainset[, ncol(trainset)]), "svmpoly", trControl = trainControl((method = "cv"), 10, 2: train.default(train1, as.factor(trainset[, ncol(trainset)]), "svmpoly", trControl = trainControl((method = "c 3: do.call(trControl$computeFunction, argList) 4: function (X, FUN, ...) 5: FUN(X[[25]], ...) 6: do.call(createModel, args) 7: function (data, method, tuneValue, obsLevels, pp = NULL, ...) 8: ksvm(as.matrix(trainX), trainY, kernel = polydot(degree tuneValue$.degree, scale = tuneValue$.scale, offset 9: ksvm(as.matrix(trainX), trainY, kernel = polydot(degree tuneValue$.degree, scale = tuneValue$.scale, offset 10: .local(x, ...) 11: ksvm(x[c(indexes[[i]], indexes[[j]]), , drop = FALSE][cind, ], yd[cind], type = type(ret), kernel = kernel, k 12: ksvm(x[c(indexes[[i]], indexes[[j]]), , drop = FALSE][cind, ], yd[cind], type = type(ret), kernel = kernel, k 13: .local(x, ...) -- View this message in context: http://r.789695.n4.nabble.com/Train-error-subscript-out-of-bonds-tp3234510p3236494.html Sent from the R help mailing list archive at Nabble.com.
No. Any valid seed should work. In this case, train() should on;y be using it to determine which training set samples are in the CV or bootstrap data sets. Max On Wed, Jan 26, 2011 at 9:56 AM, Neeti <nikkihathi at gmail.com> wrote:> > Thank you so much for your reply. In my case it is giving error in some seed > value for example if I set seed value to 357 this gives an error. Does train > have some specific seed range? > -- > View this message in context: http://r.789695.n4.nabble.com/Train-error-subscript-out-of-bonds-tp3234510p3238197.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Max