ShapFeatureSelector

class mastml.feature_selectors.ShapFeatureSelector(model, n_features_to_select, make_plot=False, plot_type='all', max_display=10)[source]

Bases: BaseSelector

Class custom-written for MAST-ML to conduct selection of features with SHAP

Args:

model: (mastml.models object), a MAST-ML compatible model

n_features_to_select: (int), the number of features to select

make_plot: Saves the plot of SHAP value if True, default is False

plot_type: The style of SHAP plot to make. Current supported values are “beeswarm”, “bar”, “all”. The SHAP package has other plot types (https://github.com/slundberg/shap), such as “force” and “waterfall”, and these may be added in the future but currently do not plot for all data/features at once in a single plot.

max_display: maximum number of feature to display in the plot

Methods:
fit: performs feature selection
Args:

X: (dataframe), dataframe of X features

y: (dataframe), dataframe of y data

Returns:

None

transform: performs the transform to generate output of only selected features
Args:

X: (dataframe), dataframe of X features

Returns:

dataframe: (dataframe), dataframe of selected X features

Methods Summary

fit(X, y)

transform(X)

Methods Documentation

fit(X, y)[source]
transform(X)[source]