feature_engine icon indicating copy to clipboard operation
feature_engine copied to clipboard

SelectFromModel score extention

Open NicoGalli opened this issue 3 years ago • 1 comments

It would be great to have a feature which extends from class sklearn.feature_selection.SelectFromModel and allows us to review the score of the base estimator from which the transformer is built,

Something like feature_engine.sel_.score

That will help to undertand the score of the model used to select the features, as it is not the same to select A and B from a model that scores 0.5 than other features from a model which scores 0.97.

NicoGalli avatar Jan 03 '23 18:01 NicoGalli

What about also a function which will merge selected features columns names with the feature_importances_ or coef_ value? As I always need to perform that manually by adding some code like:

       # Add the columns name

            X_train_coef.columns = X_train.columns[(sel_.get_support())]             X_test_coef.columns = X_train.columns[(sel_.get_support())]

            # Join ABS of Coefs with features             coef_table = pd.DataFrame(list(X_train.columns)).copy()             coef_table.insert(len(coef_table.columns), "Coefs", np.abs(sel_.estimator_.coef_).transpose())

            coef_table.rename(columns={0: "Feature"}, inplace=True)             coef_table = coef_table.sort_values(by='Coefs', ascending=False)

NicoGalli avatar Jan 03 '23 18:01 NicoGalli