Error in FUN(X[[i]], ...) : subscript out of bounds

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in FUN(X[[i]], ...) : subscript out of bounds

NehaBologna
Hi , I know nobody will respond to my query as I asked few in the past and
no answer received for any of my questions. However, I am asking here with
the hope it will get responded.

I am using bayesian optimization to tune the parameter of mtry for random
forest but it gives me the error: Error in FUN(X[[i]], ...) : subscript out
of bounds

I am using the following code:

fit_bayes <- function(mtry) {
  ## Use the same model code but for a single (C, sigma) pair.
  mod <- train(Effort ~ ., data = tr,
               method = "rf",
               preProc = c("center", "scale", "zv"),
               metric = "RMSE",
               trControl = ctrl,
               tuneGrid = data.frame(C = 10^(mtry)))

  list(Score = -getTrainPerf(mod)[, "TrainRMSE"], Pred = 0)
}


library(rBayesianOptimization)

bounds <- list(mtry = c(-2,  5)


set.seed(8606)
bo_search <- BayesianOptimization(fit_bayes,
                                  bounds = bounds,
                                  init_points = 10,
                                  n_iter = 100,
                                  acq = "ucb",
                                  kappa = 1,
                                  eps = 0.0)
bo_search

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Error in FUN(X[[i]], ...) : subscript out of bounds

PIKAL Petr
Hi

I am pretty sure that nobody will be able to answer your question due to
lack of information.

Missing parentheses          here
bounds <- list(mtry = c(-2,  5)

Use ?debug if the error is from your function.
If the code is coppied from some help page, use the data from help page and
try to find differences in your data and help data.

Provide reproducible example

I get this
Error in train(Effort ~ ., data = tr, method = "rf", preProc = c("center",
:
  could not find function "train"
Timing stopped at: 0 0 0.01

with your code

Cheers
Petr

> -----Original Message-----
> From: R-help <[hidden email]> On Behalf Of Neha gupta
> Sent: Wednesday, December 4, 2019 12:37 PM
> To: [hidden email]
> Subject: [R] Error in FUN(X[[i]], ...) : subscript out of bounds
>
> Hi , I know nobody will respond to my query as I asked few in the past and
> no answer received for any of my questions. However, I am asking here with
> the hope it will get responded.
>
> I am using bayesian optimization to tune the parameter of mtry for random
> forest but it gives me the error: Error in FUN(X[[i]], ...) : subscript
out of

> bounds
>
> I am using the following code:
>
> fit_bayes <- function(mtry) {
>   ## Use the same model code but for a single (C, sigma) pair.
>   mod <- train(Effort ~ ., data = tr,
>                method = "rf",
>                preProc = c("center", "scale", "zv"),
>                metric = "RMSE",
>                trControl = ctrl,
>                tuneGrid = data.frame(C = 10^(mtry)))
>
>   list(Score = -getTrainPerf(mod)[, "TrainRMSE"], Pred = 0) }
>
>
> library(rBayesianOptimization)
>
> bounds <- list(mtry = c(-2,  5)
>
>
> set.seed(8606)
> bo_search <- BayesianOptimization(fit_bayes,
>                                   bounds = bounds,
>                                   init_points = 10,
>                                   n_iter = 100,
>                                   acq = "ucb",
>                                   kappa = 1,
>                                   eps = 0.0) bo_search
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Error in FUN(X[[i]], ...) : subscript out of bounds

R help mailing list-2
In reply to this post by NehaBologna
In your fit_bayes function, you have
   getTrainPerf(mod)[, "TrainRMSE"]
What are the column name of the output of getTrainPerf(mod)?
   print(colnames(getTrainPerf(mod)))
You can home in on the problem faster if you call
   traceback()
immediately after the error.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Dec 4, 2019 at 3:38 AM Neha gupta <[hidden email]> wrote:

> Hi , I know nobody will respond to my query as I asked few in the past and
> no answer received for any of my questions. However, I am asking here with
> the hope it will get responded.
>
> I am using bayesian optimization to tune the parameter of mtry for random
> forest but it gives me the error: Error in FUN(X[[i]], ...) : subscript out
> of bounds
>
> I am using the following code:
>
> fit_bayes <- function(mtry) {
>   ## Use the same model code but for a single (C, sigma) pair.
>   mod <- train(Effort ~ ., data = tr,
>                method = "rf",
>                preProc = c("center", "scale", "zv"),
>                metric = "RMSE",
>                trControl = ctrl,
>                tuneGrid = data.frame(C = 10^(mtry)))
>
>   list(Score = -getTrainPerf(mod)[, "TrainRMSE"], Pred = 0)
> }
>
>
> library(rBayesianOptimization)
>
> bounds <- list(mtry = c(-2,  5)
>
>
> set.seed(8606)
> bo_search <- BayesianOptimization(fit_bayes,
>                                   bounds = bounds,
>                                   init_points = 10,
>                                   n_iter = 100,
>                                   acq = "ucb",
>                                   kappa = 1,
>                                   eps = 0.0)
> bo_search
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.