[R] Ranger could not work with caret

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Thu Jun 30 23:27:49 CEST 2022


Hello,

Please post data in dput format, without it it's difficult to tell.
If I substitute

mpg for act_effort
mtcars for tr

keeping everything else, I don't get any errors.
And the error message says clearly that the error is in tr (data).

Can you post the output of dput(head(tr, 30))?

Rui Barradas


Às 19:32 de 30/06/2022, Neha gupta escreveu:
> I posted it for the second time as I didn't get any response from group
> members. I am not sure if some problem is with the question.
> 
> 
> 
> I cannot run the "ranger" model with caret. I am only using the farff and
> caret libraries and the following code:
> 
> boot <- trainControl(method = "cv", number=10)
> 
> c1 <-train(act_effort ~ ., data = tr,
>                method = "ranger",
>                 tuneLength = 5,
>                metric = "MAE",
>                preProc = c("center", "scale", "nzv"),
>                trControl = boot)
> 
> The error I get is the repeating of the following message until I interrupt
> it.
> 
> Error: mtry can not be larger than number of variables in data. Ranger will
> EXIT now.
> 
> 	[[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.



More information about the R-help mailing list