barplot_feat_select: plot important features

View source: R/plot_feature_selection.R

barplot_feat_selectR Documentation

plot important features

Description

This function takes the result of the feature_selection function or the wrapper_feat_select function and returns a barplot with the important features

Usage

barplot_feat_select(obj, params_barplot, xgb_sort = NULL)

Arguments

obj

either a data frame or a list from the functions : feature_selection, wrapper_feat_select

params_barplot

a list of parameters needed for plotting the important features

xgb_sort

sort the xgboost features by "Gain", "Cover" or "Frequency" ( defaults to "Frequency")

Details

This function takes a data frame (from the feature_selection function) or a list (from the wrapper_feat_select function) and returns a barplot of the important features. If union is TRUE in the params_barplot vector it returns also the average importance of all methods

Value

a barplot with the important features of each method

Examples


## Not run: 

data(iris)

X = iris[, -5]
y = X[, 1]
X = X[, -1]

#.............................
# plot of the wrapper function
#.............................

feat = wrapper_feat_select(X, y, params_glmnet = params_glmnet, params_xgboost = params_xgboost, params_ranger = params_ranger, xgb_sort = NULL,
                           CV_folds = 10, stratified_regr = FALSE, cores_glmnet = 2, params_features = params_features)

params_barplot = list(keep_features = 5, horiz = TRUE, cex.names = 1.0)

barplot_feat_select(feat, params_barplot, xgb_sort = NULL)


#.......................................
# plot of the feature_selection function
#.......................................

res = feature_selection(X, y, method = 'glmnet-lasso', params_glmnet = params_glmnet, CV_folds = 5, cores_glmnet = 5)


params_barplot = list(keep_features = 5, horiz = TRUE, cex.names = 0.8)

barplot_feat_select(res, params_barplot, xgb_sort = NULL)


## End(Not run)

mlampros/FeatureSelection documentation built on Jan. 12, 2023, 4:40 a.m.