Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectFromModel score extention #579

Open
NicoGalli opened this issue Jan 3, 2023 · 1 comment
Open

SelectFromModel score extention #579

NicoGalli opened this issue Jan 3, 2023 · 1 comment

Comments

@NicoGalli
Copy link
Collaborator

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
Copy link
Collaborator Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant