Skip to content

QoL improvement: Add monotonicity constraints specification using dict of feature names in HistGradientBoostingClassifier/Regressor #21961

Closed

Description

@Anirudhsekar96

Describe the workflow you want to enable

As of current version, we need to specify monotonicity constraints for each feature as an array-like object ( e.g. [0,1,1] ) in HistGradientBoostingClassifier/Regressor. It would be a good quality of life improvement if we can specify the constraint as dict (e.g. {"feature_name1":0, "feature_name2":1 ...}) if the input X is a dataframe.

References:

Describe your proposed solution

Make the following changes inside fit function for HistGradientBoostingClassifier/Regressor:

  • Change input type for monotonic_cst to array-like or dict.
  • If constraint is specified as a dict, add a validation check for verifying if X is a dataframe with string column names.
  • Iterate through column names in X, add constraint if specified in the dict to array-like object or add default value if no constraint is specified explicitly. Return array-like object in place of original dict.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Activity

  1. added a commit that references this issue on Dec 12, 2021
    ef4c73e
  2. added
    Needs Decision - Include Feature
    on Sep 15, 2022
  3. lorentzenchr commented on Mar 28, 2026

    @lorentzenchr
    Member

    This was implemented in #24855, released in 1.2.
    #24852 is actually a duplicate of this issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Decision - Include FeatureNew Featuremodule:ensemble

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions