[R] Train error:: subscript out of bonds

jim holtman jholtman at gmail.com
Mon Jan 24 19:41:32 CET 2011


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?



More information about the R-help mailing list