scikit-learn / scikit-learn/scikit-learn

Add per feature "maximum category" counts to `OrdinalEncoder`

Open
#26,013 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

New Feature
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

Describe the workflow you want to enable

This is a follow up task for #25677

It would be nice to allow users to specify a per feature number of maxcategories instead of having a global limit as implemented in #25677.

More details in the linked comment.

Describe your proposed solution

Allow users to pass a list of shape (n_features,) or a dict mapping column name to max_categories values to specify the number of maximum categories per feature.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OrdinalEncoder and read the linked discussion in #25677, including the implementation of the existing global limit. The work is done when users can provide either an (n_features,) list or a column-name-to-max_categories dictionary to set maximum category counts per feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.