Skip to content

ENH Support for monotonic trees with missing values - #27630

Merged
glemaitre merged 18 commits into
scikit-learn:mainfrom
samronsin:monotonic-trees-missing-values
May 10, 2026
Merged

glemaitre merged 18 commits into
scikit-learn:mainfrom
samronsin:monotonic-trees-missing-values

Conversation

@samronsin

@samronsin samronsin commented Oct 20, 2023 •

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Follow up on #13649 to allow monotonic constraints on tree-based models when missing values are present (introduced in #23595 and #26391).

What does this implement/fix? Explain your changes.

Update on tests and monotonic constraints checks to make them work with missing values, since a recent PR fixed the core issue.

Any other comments?

The incompatibility was actually fixed by #32119

@github-actions

github-actions Bot commented Oct 20, 2023 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 8d803ef. Link to the linter CI: here

@glemaitre

Copy link
Copy Markdown
Member

@samronsin if you want to easily solve the problem linked to the linter, I encourage you to install pre-commit:

pip install pre-commit
pre-commit install

Then, It will use the version used by the CI to make the reformat the file before committing.

@glemaitre
glemaitre self-requested a review October 30, 2023 13:22
@glemaitre
glemaitre removed their request for review October 17, 2024 08:57
@github-actions github-actions Bot added the CI:Linter failure The linter CI is failing on this PR label Apr 25, 2026
@github-actions github-actions Bot removed the CI:Linter failure The linter CI is failing on this PR label Apr 25, 2026
@samronsin
samronsin marked this pull request as ready for review April 25, 2026 21:19
@samronsin samronsin changed the title Monotonic trees missing values Monotonic trees with missing values May 2, 2026
@samronsin

Copy link
Copy Markdown
Contributor Author

@jjerphan @glemaitre this turns out to be free thanks to a recent PR by @cakedev0 !

@jjerphan

jjerphan commented May 7, 2026

Copy link
Copy Markdown
Member

Hello @samronsin! 👋

Do you mean that this PR can be reviewed again? 🙂

@samronsin

Copy link
Copy Markdown
Contributor Author

👋 @jjerphan yes this PR (now only removing a flag and adding / updating tests) can be reviewed !

@jjerphan

jjerphan commented May 7, 2026

Copy link
Copy Markdown
Member

I would really like to review it, but I am not sure I will be able in the coming weeks.

I warmly invite @cakedev0 (who's confortable with tree implementations and Cython) to review.

@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. The missing coverage is actually in the test where it seems that we are always supporting the missing values for which we test.

You are only missing to add a fragment for the documentation as stated in the README of this folder: https://github.com/scikit-learn/scikit-learn/tree/main/doc/whats_new/upcoming_changes

I think that we can state it as an enhancement.

@glemaitre glemaitre changed the title Monotonic trees with missing values ENH Support for monotonic trees with missing values May 7, 2026
@samronsin

Copy link
Copy Markdown
Contributor Author

Thank you @glemaitre for the review ! I just added the fragment, referencing the heavy-lifting by #32119

@cakedev0 cakedev0 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.

That's very satisfying to see my previous refactor unlock this, it makes my day 😄

Minor style/simplification comments, but otherwise LGTM. We should be able to merge it quickly.

@cakedev0 cakedev0 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.

Thanks for quick iteration.

LGTM!

@samronsin

Copy link
Copy Markdown
Contributor Author

Thank you @cakedev0 for your review !

@glemaitre
glemaitre merged commit 6e9ef2b into scikit-learn:main May 10, 2026
33 checks passed
kundurt1 added a commit to kundurt1/scikit-learn that referenced this pull request May 15, 2026
…missing_values

Commit c01c2f6 (sparse NaN support) accidentally re-introduced the
`monotonic_cst is None` guard that commit 6e9ef2b (ENH scikit-learn#27630) had
removed. The correct combined condition is: allow NaN for all dense input
regardless of monotonic_cst, and allow NaN for sparse input only when
monotonic_cst is None.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants