Skip to content

DOC: inconsistent monotonic_cst docstring across forest estimators #34222

Closed

Description

@vashita-pandey

Describe the issue linked to the documentation

Describe the issue

In sklearn/ensemble/_forest.py, the monotonic_cst parameter docstring
has two inconsistencies across the forest estimators:

1. Missing trailing comma in shape notation

All four classes (RandomForestClassifier, RandomForestRegressor,
ExtraTreesClassifier, ExtraTreesRegressor) write the shape as:

array-like of int of shape (n_features)

It should be:

array-like of int of shape (n_features,)

This is inconsistent with the rest of the scikit-learn codebase which
uses the trailing comma to denote a 1D tuple.

2. Inconsistent wording for constraint values

RandomForestClassifier uses:
- 1: monotonic increase
- -1: monotonic decrease

While RandomForestRegressor, ExtraTreesClassifier, and
ExtraTreesRegressor use:
- 1: monotonically increasing
- -1: monotonically decreasing

Both should use the same phrasing. The adjective form
("monotonically increasing/decreasing") is more grammatically
consistent with how constraints are described elsewhere.

Steps to reproduce

Open sklearn/ensemble/_forest.py and search for monotonic_cst.

Suggested fix

  • Add trailing comma: (n_features,) in all four classes
  • Standardize wording to "monotonically increasing" / "monotonically
    decreasing" across all four classes

Suggest a potential alternative/fix

No response

Activity

  1. added
    good first PR to review
    and removed
    Needs Triage
    on Jun 9, 2026
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

    Documentationgood first PR to review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions