Aleksandar Jovanovic
Aleksandar Jovanovic

Reputation: 1177

"promise already under evaluation" error in R caret's rfe function

I have a matrix X and vector Y which I use as arguments into the rfe function from the caret package. It's as simple as:

I get a weird error which I can't decipher:

promise already under evaluation: recursive default argument reference or earlier problems?

EDIT: Here is a reproducible example for the first 5 rows of my data:

library(caret)

X_values = c(29.04,96.57,4.57,94.23,66.81,26.71,69.01,77.06,49.52,97.59,47.57,64.07,24.25,11.27,77.30,90.99,44.05,30.96,96.32,16.04)
X = matrix(X_values, nrow = 5, ncol=4)
Y = c(5608.11,2916.61,5093.05,3949.35,2482.52)

rfe(X, Y)

My R version is 3.2.3. Caret package is 6.0-76.

Does anybody know what this is?

Upvotes: 1

Views: 1213

Answers (1)

David Heckmann
David Heckmann

Reputation: 2939

There are two problems with your code.

  1. You need to specify the function/algorithm that you want to fit. (this is what causes the error message you get. I am unsure why rfe throws such a cryptic error message; it makes it difficult to debug, indeed.)
  2. You need to name your columns in the input data.

The following works:

library(caret)

X_values = c(29.04,96.57,4.57,94.23,66.81,26.71,69.01,77.06,49.52,97.59,47.57,64.07,24.25,11.27,77.30,90.99,44.05,30.96,96.32,16.04)
X = matrix(X_values, nrow = 5, ncol=4)
Y = c(5608.11,2916.61,5093.05,3949.35,2482.52)

ctrl <- rfeControl(functions = lmFuncs)
colnames(X) <- letters[1:ncol(X)]

set.seed(123)
rfe(X, Y, rfeControl = ctrl)

I chose a linear model for the rfe. The reason for the warning messages is the low number of observations in your data during cross validation. You probably also want to set the sizes argument to get a meaningful feature elimination.

Upvotes: 4

Related Questions