[R] Ranger could not work with caret

Neha gupta neh@@bo|ogn@90 @end|ng |rom gm@||@com
Fri Jul 1 00:03:35 CEST 2022


Ok, the data is pasted below

But on the same data (everything the same) and with other models like RF,
SVM etc, it works fine.


> dput(head(tr, 30))
structure(list(recordnumber = c(0, 0.02, 0.04, 0.06, 0.07, 0.08,
0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.16, 0.17, 0.18, 0.23, 0.24,
0.25, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.35, 0.36, 0.37, 0.38,
0.4, 0.41), projectname = structure(c(1L, 1L, 1L, 1L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 5L, 6L), levels = c("de", "erb", "gal",
"X", "hst", "slp", "spl", "Y"), class = "factor"), cat2 = structure(c(3L,
3L, 3L, 3L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L,
9L, 11L, 5L, 4L, 6L, 8L, 3L, 9L, 9L, 9L, 9L, 6L, 7L), levels =
c("Avionics",
"application_ground", "avionicsmonitoring", "batchdataprocessing",
"communications", "datacapture", "launchprocessing", "missionplanning",
"monitor_control", "operatingsystem", "realdataprocessing", "science",
"simulation", "utility"), class = "factor"), forg = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), levels = c("f",
"g"), class = "factor"), center = structure(c(2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 6L), levels = c("1", "2",
"3", "4", "5", "6"), class = "factor"), year = c(0.5, 0.5, 0.5,
0.5, 0.6875, 0.5625, 0.5625, 0.8125, 0.5625, 0.875, 0.5625, 0.75,
0.5625, 0.8125, 0.75, 0.9375, 0.9375, 0.9375, 0.6875, 0.6875,
0.6875, 0.6875, 0.875, 1, 0.9375, 0.9375, 0.9375, 0.9375, 0.5625,
0.25), mode = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), levels = c("embedded", "organic", "semidetached"
), class = "factor"), rely = structure(c(4L, 4L, 4L, 4L, 4L,
4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 3L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L), levels = c("vl", "l", "n",
"h", "vh", "xh"), class = "factor"), data = structure(c(2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
5L, 5L, 5L, 5L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 2L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), cplx = structure(c(4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 4L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), time = structure(c(3L,
3L, 3L, 3L, 3L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L,
3L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), stor = structure(c(3L,
3L, 3L, 3L, 3L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 3L, 3L, 3L, 3L,
3L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), virt = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), turn = structure(c(2L,
2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 2L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), acap = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L,
3L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), aexp = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 4L, 5L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), pcap = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 5L, 4L, 5L, 3L, 4L, 4L, 5L, 4L, 4L, 4L, 4L,
4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 4L, 4L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), vexp = structure(c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), lexp = structure(c(4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 1L, 4L, 4L, 4L, 4L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), modp = structure(c(4L,
4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 5L, 5L, 5L, 5L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 4L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), tool = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 1L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), sced = structure(c(2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 3L), levels = c("vl",
"l", "n", "h", "vh", "xh"), class = "factor"), equivphyskloc = c(0.025534,
0.006945, 0.008988, 0.002655, 0.067102, 0.006741, 0.019508, 0.005209,
0.101215, 0.010622, 0.101215, 0.019508, 0.152283, 0.031253, 0.014401,
0.014401, 0.037892, 0.009294, 0.015729, 0.012154, 0.032377, 0.035339,
0.004698, 0.009703, 0.00572, 0.012358, 0.091002, 0.007252, 0.180778,
0.307527), act_effort = c(117.6, 31.2, 25.2, 10.8, 352.8, 72,
72, 24, 360, 36, 215, 48, 324, 60, 48, 90, 210, 48, 82, 62, 170,
192, 18, 50, 42, 60, 444, 42, 1248, 2400)), row.names = c(1L,
3L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 17L, 18L, 19L,
24L, 25L, 26L, 29L, 30L, 31L, 32L, 33L, 34L, 36L, 37L, 38L, 39L,
41L, 42L), class = "data.frame")



On Thu, Jun 30, 2022 at 11:28 PM Rui Barradas <ruipbarradas using sapo.pt> wrote:

> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list