I have a data set that I\'m trying to use rfe()
from the caret
package in R on.
x is the prices I\'m trying to predict.
y is the va
It should be factor and vector:
as.factor(noquote(as.vector(t(df[,14]))))
In my case column 14 is a class in df.
y
should be a numeric or factor vector. Here you have it as a data frame. Compare:
> rfe(data.frame(matrix(rnorm(100*3), ncol=3)), sample(2, 100, replace=T), sizes=1:3, rfeControl=rfeControl(functions=lmFuncs))
Recursive feature selection
Outer resampling method: Bootstrap (25 reps)
Resampling performance over subset size:
Variables RMSE Rsquared RMSESD RsquaredSD Selected
1 0.5154 0.02120 0.02421 0.02752 *
2 0.5162 0.02295 0.02722 0.03204
3 0.5162 0.02295 0.02722 0.03204
The top 1 variables (out of 1):
X3
vs.
> rfe(data.frame(matrix(rnorm(100*3), ncol=3)), data.frame(sample(2, 100, replace=T)), sizes=1:3, rfeControl=rfeControl(functions=lmFuncs))
Error in rfe.default(data.frame(matrix(rnorm(100 * 3), ncol = 3)), data.frame(sample(2, :
there should be the same number of samples in x and y