category_encoders: 23 encoders, one install line with no setup.py behind it
A library of sklearn compatible categorical variable encoders
At a glance
- What is it?
- category_encoders is a scikit-learn style transformer collection with a documented setup.py install command, a build system that uses poetry-core, and no setup.py in the repository. Underneath that sit smaller gaps: statsmodels described as required but gated behind an extra, and a reference list where the fairness paper is cited by nobody.
- Who is it for?
- Use this library when you want a single drop in transformer that speaks the scikit-learn API and covers the ordinary encoders plus a handful of supervised ones with leakage aware defaults. Check three things before you trust it in a pipeline.
- Can I use it commercially?
- Yes. BSD-3-Clause is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 15 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- scikit-learn-contrib/category_encoders2,510 ★ · +3
| Repository | 2026-09-29 | 2026-11-15 |
|---|---|---|
| scikit-learn-contrib/category_encoders | 2.5k | 2.5k |
3 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The page documents python setup.py install and the root has no setup.py
Four install paths are offered for the same package. The first is a shell block containing one line:
$ python setup.py installThe second is `pip install category_encoders`, the third is `conda install -c conda-forge category_encoders`, and the fourth installs the development version from `git+https://github.com/scikit-learn-contrib/category_encoders`. The build configuration contradicts the first of those four. The build backend is poetry-core rather than setuptools, the package metadata lives in pyproject.toml under a tool.poetry table with the name and version filled in, and a poetry.lock sits at the root. No setup.py appears among the top level entries, which are the GitHub workflows directory, .gitignore, .zenodo.json, CHANGELOG.md, CITATION.cff, CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE.md, MANIFEST.in, README.md, benchmarks/, category_encoders/, docs/, examples/, joss/, poetry.lock, pyproject.toml, tests/ and tox.ini. So the first command has nothing to run, and the two commands a reader is steered away from are the two that work.
statsmodels is called a requirement but sits behind the glmm extra
The install section opens by saying the package requires numpy, statsmodels, and scipy. The dependency table says something different. Python is pinned at 3.11 or newer, numpy at 1.14.0 or newer, scipy at 1.0.0 or newer, pandas at 1.0.5 or newer and scikit-learn at 1.6.0 or newer, and statsmodels appears as an optional entry with the version floor 0.9.0, wired to an extra named glmm:
statsmodels = {version = ">=0.9.0", optional = true}
[tool.poetry.extras]
glmm = ["statsmodels"]So the sentence naming three requirements skips pandas and scikit-learn, which are hard dependencies, and calls required something that only the Generalized Linear Mixed Model encoder needs. The gap matters at install time, because a user who follows the sentence and skips the extra gets a library whose mixed model encoder cannot import its own backend.
For supervised encoders, fit_transform and transform are documented to disagree
One passage on the page is the most useful thing in it, and it is a warning rather than a feature. For the transformation of training data with the supervised methods you should call fit_transform() instead of fit() followed by transform(), because the two methods do not have to generate the same result. The encoder where the difference is visible is LeaveOneOut, which performs a nested cross validation for the training data inside fit_transform() to decrease over fitting of the downstream model, while transform() uses all the training data for scoring in order to get estimates that are as accurate as possible. That is a deliberate asymmetry between the two paths, not a rounding difference, and it means the same encoder in the same pipeline produces different numbers depending on which call site you used. It is also why the two wrappers exist: PolynomialWrapper extends the supervised encoders to polynomial targets, and NestedCVWrapper exists to help prevent overfitting.
The unsupervised example fits and transforms one frame while the supervised one stops mid-statement
Two worked examples are given, and they do not line up. The unsupervised one builds a frame with gender, country and age, then fits a BinaryEncoder on two named columns and transforms the same frame:
enc = BinaryEncoder(cols=['gender', 'country']).fit(X)
numeric_dataset = enc.transform(X)The supervised one builds separate X_train, y_train and X_test frames, instantiates a TargetEncoder, and calls fit_transform on the training pair. Its last line is `testing_numeric_data`, an assignment with nothing on the right hand side of it, so the call that would transform the test set never appears. What is left is a page whose first example ends cleanly on a transformed dataset and whose second ends on an incomplete statement. Both examples use `from category_encoders import *`, and both pass the columns explicitly rather than relying on the default that encodes every column of object or pandas categorical dtype.
Three recent tags, two naming conventions, and a push one minute after the tag
The three most recent releases are v2.11.1, v2.11.0 and 2.10.0, and the third one carries no v prefix while the other two do. The package metadata records the version as 2.11.1, which matches the newest tag rather than trailing it. The dates are tighter than the numbering suggests: v2.11.0 was published on 2026-09-07 and v2.11.1 the next day, a patch level one day after a minor one, with 2.10.0 preceding them on 2026-07-26. The default branch is master rather than main, and it received a push at 15:29:25 on 2026-09-08, roughly a minute after the v2.11.1 tag was published at 15:28:24 the same day. The repository is not archived and carries 27 open issues. The page states that the project is under active development, which for a package whose newest release is the current version is at least consistent with the record.
The fairness reference is listed and cited by no encoder at all
The encoding methods are numbered by reference, seventeen entries in total, and the numbering has two loose ends. Reference 16 is Fairness implications of encoding protected categorical attributes, by Mougan, Alvarez, Ruggieri and Staab, published in the 2023 AAAI/ACM Conference on AI, Ethics, and Society. Neither the unsupervised list nor the supervised list cites it: the unsupervised thirteen run from Backward Difference Contrast through Sum Contrast, and the supervised ten from CatBoost through Summary Encoder, and 16 appears in neither. Reference 7, the Miccii-Barreca preprocessing scheme, does get used twice, by both M-estimator and Target Encoding. The other loose end is concentration at the other extreme, with Backward Difference Contrast, Helmert Contrast, Ordinal, One-Hot, Polynomial Contrast and Sum Contrast all citing the same two sources, the UCLA contrast coding page and a Carey handout. So the citation apparatus is thin exactly where the encoders are most used.
ruff selects pydocstyle, ignores a rule with a todo, and misspells its own comment
The tool configuration is unusually explicit. Line length is 100, the target version is py311, and the source roots are the library package and tests. The lint selection pulls in pycodestyle errors and warnings, pyflakes, isort, flake8-bugbear, comprehensions, naming and pydocstyle, with pydocstyle set to the numpy convention. Four ignores follow: imperative mood for D401, three naming rules that allow X, np_X_t and mixed case names as parameter names, and B023, whose comment reads todo re-add this rule. The naming entry is labelled PEP8 naming convetions, missing the n. Formatting asks for single quotes, space indentation and formatted code inside docstrings. Mutation testing is configured alongside it, with mutmut pointed at the library package and given the tests directory as the suite to run for every mutant, and the comment says it mutates only the library source. Dev tooling is declared under tool.poetry.dev-dependencies rather than a dependency group: numpydoc, ruff, sphinx with its read the docs theme, pytest at 9.0.3 or newer, and pytest-subtests.
One package directory holds 23 encoders while the repository also carries benchmarks and a joss folder
The layout says what the project is for. Everything the library exposes lives in a single category_encoders/ package directory, and the default branch is master. Alongside it sit benchmarks/ for timing work, docs/ for the site the README links at contrib.scikit-learn.org over plain http, examples/ with subdirectories for benchmarking, benchmarking_cpu and benchmarking_large plus column_transformer_example.py, encoding_examples.py and grid_search_example.py, and an img/ and source_data/ folder. tox.ini sits at the root for multi environment test runs, MANIFEST.in for packaging, poetry.lock for the resolved dev environment, CITATION.cff and .zenodo.json for citation metadata, and a joss/ folder for the Journal of Open Source Software submission. Twenty three encoders split thirteen unsupervised and ten supervised, with two wrappers alongside them, so a single import pulls in the full menu rather than a subset, and the only way to get a narrower surface is to import the module you need.
Editorial conclusion
Use this library when you want a single drop in transformer that speaks the scikit-learn API and covers the ordinary encoders plus a handful of supervised ones with leakage aware defaults. Check three things before you trust it in a pipeline. The documented install path includes a command the repository cannot execute, so pick the pip or conda line and ignore the other. statsmodels is presented as a requirement but is really optional and gates only the mixed model encoder, so install the glmm extra if that one is in your set. And for the supervised encoders, train data transformed through fit_transform and through fit followed by transform are documented to disagree, which means a pipeline built the second way is quietly scoring with data the encoder already saw.
Frequently asked questions
How do you install category_encoders?
Three working paths are given on the page: pip install category_encoders, conda install -c conda-forge category_encoders, and pip install --upgrade git+https://github.com/scikit-learn-contrib/category_encoders for the development version. The fourth line offered, python setup.py install, has no setup.py in the repository, which builds with poetry-core from pyproject.toml.
Do I need statsmodels to use category_encoders?
Only for the Generalized Linear Mixed Model encoder. In the dependency table statsmodels is an optional entry from version 0.9.0 wired to an extra named glmm, while numpy, scipy, pandas and scikit-learn are required outright.
What is the difference between fit_transform and transform in category_encoders?
For the supervised encoders on training data the two are documented to differ. LeaveOneOut runs a nested cross validation inside fit_transform to reduce over fitting of the downstream model, while transform scores using all the training data, so the same encoder returns different numbers depending on the call.
How many encoders does category_encoders ship and how are they grouped?
Twenty three encoders in two families: thirteen unsupervised, from Backward Difference Contrast through Sum Contrast, and ten supervised, from CatBoost through Summary Encoder. Two wrappers, PolynomialWrapper and NestedCVWrapper, sit alongside them for polynomial targets and for nested cross validation.
Which columns does category_encoders encode if cols is not passed?
Every column whose dtype is object or pandas categorical. Supported inputs are numpy arrays and pandas dataframes, and each transformer has its own configuration options that the page leaves to the documentation site.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/scikit-learn-contrib-category-encoders)Star history chart for your README
[](https://hysenlabs.com/projects/scikit-learn-contrib-category-encoders)Was this useful?