Take input as predictons and response and return the list of features that are important
feature_selection(X, y, mode, n_features)
X | data.frame of predictors |
---|---|
y | vector of response and should be a factor in case of classification |
mode | string regression or classification |
n_features | int number of top important features select from all the features |
vector of feature nams of top n_features
#> Warning: package 'caret' was built under R version 3.6.2#>#>#> Warning: prediction from a rank-deficient fit may be misleading#> Warning: prediction from a rank-deficient fit may be misleading#> Warning: prediction from a rank-deficient fit may be misleading#> [1] X1 X2 #> Levels: X1 X2feature_selection(data.frame(X1 = c(2, 4, 3), X2 = c(8, 7, 4)), factor(c(1, 1, 0)), "classification", 1)#> Warning: prediction from a rank-deficient fit may be misleading#> Warning: rfe is expecting 2 importance values but only has 1. This may be caused by having zero-variance predictors, excessively-correlated predictors, factor predictors that were expanded into dummy variables or you may have failed to drop one of your dummy variables.#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> Warning: prediction from a rank-deficient fit may be misleading#> Warning: rfe is expecting 2 importance values but only has 1. This may be caused by having zero-variance predictors, excessively-correlated predictors, factor predictors that were expanded into dummy variables or you may have failed to drop one of your dummy variables.#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> Warning: prediction from a rank-deficient fit may be misleading#> Warning: rfe is expecting 2 importance values but only has 1. This may be caused by having zero-variance predictors, excessively-correlated predictors, factor predictors that were expanded into dummy variables or you may have failed to drop one of your dummy variables.#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> Warning: There were missing importance values. There may be linear dependencies in your predictor variables#> [1] "X1"