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

ENH Specify categorical features with feature names in HGBDT #24889

Merged

Conversation

ogrisel
Copy link
Member

@ogrisel ogrisel commented Nov 10, 2022

Similar to #24855 but for the categorical_features parameter as stated in #24852 (comment).

Note that this works well with the .set_output("pandas") of this release.

However it requires disabling the verbose column names of the column transformer :)

Note: in the future we might directly inspect dataframe column dtypes in HGBDT and have an "auto" mode to trigger native categorical support for explicitly encoded categorical dtyped columns, but this will be the topic for a later PR.

@ogrisel ogrisel added the Quick Review For PRs that are quick to review label Nov 10, 2022
@ogrisel ogrisel added this to the 1.2 milestone Nov 10, 2022
doc/whats_new/v1.2.rst Outdated Show resolved Hide resolved
@glemaitre glemaitre changed the title Specify categorical feaature with feature names in HGBDT ENH Specify categorical feaature with feature names in HGBDT Nov 10, 2022
@lorentzenchr lorentzenchr changed the title ENH Specify categorical feaature with feature names in HGBDT ENH Specify categorical feature with feature names in HGBDT Nov 11, 2022
@lorentzenchr lorentzenchr changed the title ENH Specify categorical feature with feature names in HGBDT ENH Specify categorical features with feature names in HGBDT Nov 11, 2022
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@lorentzenchr lorentzenchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only some questions.
This will improve user friendliness soooo much!!!

"on data without feature names."
)
is_categorical = np.zeros(n_features, dtype=bool)
feature_names = self.feature_names_in_.tolist()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this conversion to a list necessary?

Copy link
Member Author

@ogrisel ogrisel Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrays do not have the index method. Not sure how to implement this while staying in numpy and making it easy to raise the error message timely at the same time.

Copy link
Member Author

@ogrisel ogrisel Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the feature names list should never be to long (few hundred values) for HGBDT models in practice because those models tend to perform poorly when n_features >> n_samples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

Copy link
Member

@lorentzenchr lorentzenchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final adjustments.

examples/applications/plot_cyclical_feature_engineering.py Outdated Show resolved Hide resolved
examples/ensemble/plot_gradient_boosting_categorical.py Outdated Show resolved Hide resolved
@lorentzenchr lorentzenchr merged commit 84a7a7a into scikit-learn:main Nov 13, 2022
@ogrisel ogrisel deleted the categorical_feaature-feature_names_in_ branch November 13, 2022 14:03
@ogrisel
Copy link
Member Author

ogrisel commented Nov 13, 2022

Thank for the final fixes @lorentzenchr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ensemble Quick Review For PRs that are quick to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants