Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: clarify categorical missing docs (HGB & trees) - #34553

Merged
thomasjpfan merged 142 commits into
scikit-learn:mainfrom
cakedev0:codex/clarify-categorical-missing-docs
Jul 24, 2026
Merged

DOC: clarify categorical missing docs (HGB & trees)#34553
thomasjpfan merged 142 commits into
scikit-learn:mainfrom
cakedev0:codex/clarify-categorical-missing-docs

Conversation

@cakedev0

Copy link
Copy Markdown
Contributor

While reviewing #33354, Codex noticed the wording of the docstring was incorrect regarding negative values for categorical features: "Negative values for categorical features encoded as numeric dtypes are treated as missing values". There just treated as normal categories.

Reference Issues/PRs

Follow-up from #33354

What does this implement/fix? Explain your changes.

Fixes the wording, and also proposes to trim a part that's not informative IMO (more details in a inline comment)

AI usage disclosure

I used AI assistance for:

  • Noticing it
  • Helping with the wording

Comment on lines -1461 to -1463
dtypes are treated as missing values. All categorical values are
converted to floating point numbers. This means that categorical values
of 1.0 and 1 are treated as the same category.

@cakedev0 cakedev0 Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All categorical values are converted to floating point numbers. This means that categorical values of 1.0 and 1 are treated as the same category.

This sentence is weird and probably dating from before using OrdinalEncoder. With ordinal encoder, the case of feeding 1 and 1.0 can't really happen:

  • features mixing string and numerical are forbidden.
  • arrays or Series mixing 1 and 1.0 will be float dtype and 1 will 1.0, so the "collision" happens before it reaches scikit-learn.

IMO, this is using a lot of users' cognitive space for something users won't encounter. We don't have a similar sentence in encoders doc, so why here?

But if reviewers disagree with removing this sentence, I'll just revert the last commit.

@cakedev0
cakedev0 marked this pull request as ready for review July 23, 2026 09:02
@cakedev0 cakedev0 changed the title Codex/clarify categorical missing docs DOC: clarify categorical missing docs (HGB & trees) Jul 23, 2026

@thomasjpfan thomasjpfan 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

@thomasjpfan
thomasjpfan merged commit 3711950 into scikit-learn:main Jul 24, 2026
39 checks passed
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
Co-authored-by: Adam Li <[email protected]>
Co-authored-by: Adam Li <[email protected]>
Co-authored-by: Christian Lorentzen <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
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