Skip to content

ENH Specify categorical features with feature names in HGBDT - #24889

Merged
lorentzenchr merged 11 commits into
scikit-learn:mainfrom
ogrisel:categorical_feaature-feature_names_in_
Nov 13, 2022
Merged

lorentzenchr merged 11 commits into
scikit-learn:mainfrom
ogrisel:categorical_feaature-feature_names_in_

Conversation

@ogrisel

@ogrisel ogrisel commented Nov 10, 2022

Copy link
Copy Markdown
Member

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
Comment thread doc/whats_new/v1.2.rst 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

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@lorentzenchr lorentzenchr left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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?

@ogrisel ogrisel Nov 13, 2022 •

Copy link
Copy Markdown
Member Author

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.

@ogrisel ogrisel Nov 13, 2022 •

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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.

@lorentzenchr lorentzenchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Final adjustments.

@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

ogrisel commented Nov 13, 2022

Copy link
Copy Markdown
Member Author

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.

4 participants