[R] Different number of resamples error
javed khan
j@vedbtk111 @end|ng |rom gm@||@com
Fri Feb 21 10:04:09 CET 2020
When I do not include gbm in the boxplot, it gives me the result for nnet
and svm but when I include also gbm, it gives the error message
There are different numbers of resamples in each model
On Fri, Feb 21, 2020 at 10:00 AM javed khan <javedbtk111 using gmail.com> wrote:
> The whole code is as follows:
>
> library(caret)
> library(farff)
> library(gbm)
> library(nnet)
>
> setwd("C:/Users/PC/Documents")
> d=readARFF("myresults.arff")
>
> index <- createDataPartition(d$results, p = .70,list = FALSE)
> tr <- d[index, ]
> ts <- d[-index, ]
> index_2 <- createFolds(tr$results, returnTrain = TRUE, list = TRUE)
> ctrl <- trainControl(method = "repeatedcv", index = index_2)
>
> set.seed(30218)
> nnet1 <- train(results~ ., data = tr,
> method = "nnet",
>
> metric = "MAE",
> trControl = ctrl,
>
> preProc = c("center", "scale", "zv"),
> tuneGrid = data.frame(decay = (1),
> size = (1.3801517)))
> nnet1$results
>
> ///For SVM
>
> set.seed(30218)
> svm1 <- train(results ~ ., data = tr,
> method = "svmRadial",
>
> metric = "MAE",
> preProc = c("center", "scale", "zv"),
> trControl = ctrl,
> tuneGrid=expand.grid(sigma = (0.5),
> C = c(1.348657)))
> getTrainPerf(svm1)
> svm1$results
>
> //For GBM
>
> set.seed(30218)
> gbm <- train(results ~ ., data = tr,
> method = "gbm",
> preProc = c("center", "scale", "zv"),
> metric = "MAE",
>
>
> tuneGrid = data.frame(n.trees = (200.09633523),
> interaction.depth = (1),
> shrinkage=(0.1), n.minobsinnode=(10)))
> gbm$results
>
> //Then the boxplot
>
> rvalues=resamples(list(nnet=nnet1, svm=svm1, GBM=gbm))
>
> bwplot(rvalues, metric="MAE")
>
>
> On Fri, Feb 21, 2020 at 12:16 AM Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
> wrote:
>
>> You are being way too cavalier about what packages you are using. Read
>> the Posting Guide about contributed packages... this list cannot provide
>> expert support for every package out there. This confusion is why you
>> should be providing a reproducible example when you ask for help about R.
>>
>> The caret package depends on lattice and provides some overloaded
>> versions of the bwplot function that do have a metric argument. I have no
>> expertise with caret myself... but recommend that you supply a reproducible
>> example for best luck in prompting someone to look closer.
>>
>> On February 20, 2020 1:31:30 PM PST, javed khan <javedbtk111 using gmail.com>
>> wrote:
>> >Thanks for your reply.
>> >
>> >I am not using any specific package for bwplot. I just used caret, nnet
>> >and
>> >gbm packages.
>> >
>> >When I use resample (instead of resamples), it give me error message.
>> >
>> >metric=MAE gives the MAE values at x-axis when I used simple plots in
>> >the
>> >recent past.
>> >
>> >Best regards
>> >
>> >On Thu, Feb 20, 2020 at 10:29 PM Bert Gunter <bgunter.4567 using gmail.com>
>> >wrote:
>> >
>> >> cc the list!
>> >> (which I have done here)
>> >>
>> >> Bert Gunter
>> >>
>> >> "The trouble with having an open mind is that people keep coming
>> >along and
>> >> sticking things into it."
>> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >>
>> >>
>> >> On Thu, Feb 20, 2020 at 1:20 PM javed khan <javedbtk111 using gmail.com>
>> >wrote:
>> >>
>> >>> Thanks for your reply.
>> >>>
>> >>> I am not using any specific package for bwplot. I just used caret,
>> >nnet
>> >>> and gbm packages.
>> >>>
>> >>> When I use resample (instead of resamples), it give me error
>> >message.
>> >>>
>> >>> metric=MAE gives the MAE values at x-axis when I used simple plots
>> >in the
>> >>> recent past.
>> >>>
>> >>> Best regards
>> >>>
>> >>> On Thu, Feb 20, 2020 at 10:15 PM Bert Gunter
>> ><bgunter.4567 using gmail.com>
>> >>> wrote:
>> >>>
>> >>>> ??
>> >>>> Isn't is resample() not resamples()?
>> >>>> From what package?
>> >>>> What package is bwplot from? lattice:::bwplot has no "metric"
>> >argument.
>> >>>>
>> >>>>
>> >>>>
>> >>>> Bert Gunter
>> >>>>
>> >>>> "The trouble with having an open mind is that people keep coming
>> >along
>> >>>> and sticking things into it."
>> >>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >>>>
>> >>>>
>> >>>> On Thu, Feb 20, 2020 at 12:55 PM javed khan <javedbtk111 using gmail.com>
>> >>>> wrote:
>> >>>>
>> >>>>> Hello to all
>> >>>>>
>> >>>>> I have different train functions for NN, SVM and GBM and when I
>> >combine
>> >>>>> the
>> >>>>> results using bwplot, it gives me the error " Different number of
>> >>>>> resamples
>> >>>>> in each model". It gives me the results (MAE values) but using the
>> >>>>> boxplot,
>> >>>>> it gives the error. The code is as follows:
>> >>>>>
>> >>>>> set.seed(30218)
>> >>>>> nnet1 <- train(results~ ., data = tr,
>> >>>>> method = "nnet",
>> >>>>>
>> >>>>> metric = "MAE",
>> >>>>> trControl = ctrl,
>> >>>>>
>> >>>>> preProc = c("center", "scale", "zv"),
>> >>>>> tuneGrid = data.frame(decay = (1),
>> >>>>> size = (1.3801517)))
>> >>>>> nnet1$results
>> >>>>>
>> >>>>> ///For SVM
>> >>>>>
>> >>>>> set.seed(30218)
>> >>>>> svm1 <- train(results ~ ., data = tr,
>> >>>>> method = "svmRadial",
>> >>>>>
>> >>>>> metric = "MAE",
>> >>>>> preProc = c("center", "scale", "zv"),
>> >>>>> trControl = ctrl,
>> >>>>> tuneGrid=expand.grid(sigma = (0.5),
>> >>>>> C = c(1.348657)))
>> >>>>> getTrainPerf(svm1)
>> >>>>> svm1$results
>> >>>>>
>> >>>>> //For GBM
>> >>>>>
>> >>>>> set.seed(30218)
>> >>>>> gbm <- train(results ~ ., data = tr,
>> >>>>> method = "gbm",
>> >>>>> preProc = c("center", "scale", "zv"),
>> >>>>> metric = "MAE",
>> >>>>>
>> >>>>>
>> >>>>> tuneGrid = data.frame(n.trees = (200.09633523),
>> >>>>> interaction.depth = (1),
>> >>>>> shrinkage=(0.1),
>> >>>>> n.minobsinnode=(10)))
>> >>>>> gbm$results
>> >>>>>
>> >>>>> //Then the boxplot
>> >>>>>
>> >>>>> rvalues=resamples(list(nnet=nnet1, svm=svm1, GBM=gbm))
>> >>>>>
>> >>>>> bwplot(rvalues, metric="MAE")
>> >>>>>
>> >>>>> [[alternative HTML version deleted]]
>> >>>>>
>> >>>>> ______________________________________________
>> >>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >>>>> 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.
>> >>>>>
>> >>>>
>> >
>> > [[alternative HTML version deleted]]
>> >
>> >______________________________________________
>> >R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >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.
>>
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list