skillfed

category-encoders

A package for encoding categorical variables for machine learning

category-encoders v2.10.0 3.1M downloads/30d#2,741 on PyPI
Permissive license BSD-3 Active released

What it is and what it does

Category-encoders is a scikit-learn-compatible library that converts categorical variables into numeric form using a range of encoding strategies. It provides both unsupervised methods (binary, one-hot, ordinal, hashing) that treat all categories equally, and supervised methods (target encoding, CatBoost encoding, leave-one-out) that leverage target information to create more predictive numeric representations. The library integrates seamlessly into sklearn pipelines and accepts numpy arrays or pandas dataframes as input.

The package is designed for machine learning workflows where categorical features must be converted to numeric form. It handles the common problem of deciding which encoding method to use by offering multiple techniques with different statistical properties and computational trade-offs. Supervised encoders can reduce overfitting through nested cross-validation wrappers, and the library supports both classification and regression tasks through specialized wrappers.

Use it for:

  • Encode categorical features like gender or country in a classification pipeline using one-hot or binary encoding
  • Apply target encoding to high-cardinality categorical variables to capture predictive signal from the target variable
  • Use LeaveOneOut encoding in supervised settings to prevent overfitting while maintaining target information
  • Build feature engineering pipelines that automatically encode all object-type columns in a pandas dataframe
  • Compare multiple encoding strategies on the same dataset to select the best performing method

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Transforms categorical variables into numeric representations using scikit-learn-compatible encoders, supporting both unsupervised methods (one-hot, binary, ordinal) and supervised techniques (target encoding, CatBoost encoding).

Yes. The package is actively maintained, has low installation friction, carries no known vulnerabilities, and provides a well-documented suite of encoding methods that integrate directly into sklearn workflows. It solves a common data preprocessing problem with multiple proven techniques. Install it if you work with categorical data in machine learning projects.

Install

category-encoders on PyPI

pip

pip install category-encoders

uv

uv add category-encoders

poetry

poetry add category-encoders

Installing category-encoders

Before you install

Low friction installation with a pure Python wheel. Depends on established numerical and statistical libraries (numpy, pandas, scikit-learn, scipy, statsmodels). Actively maintained with a recent release.

License in practice

BSD-3 permissive license allows commercial and private use with minimal restrictions; attribution required.

Quickstart

pip install category_encoders

from category_encoders import BinaryEncoder
import pandas as pd

X = pd.DataFrame({'gender': ['male', 'female'], 'age': [25, 32]})
enc = BinaryEncoder(cols=['gender']).fit(X)
numeric_X = enc.transform(X)

Verify before relying

  • Whether supervised encoders (TargetEncoder, LeaveOneOut) handle class imbalance or missing values automatically
  • Performance characteristics when encoding high-cardinality categorical features with many unique values
  • Memory overhead of different encoding methods on large datasets

Package facts

License BSD-3 (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 6 — numpy, pandas, patsy, scikit-learn, scipy, statsmodels
Maintenance actively maintained — 19 days since the last release
First released
Downloads 3,123,199/month — #2,741 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: category_encoders-2.10.0-py3-none-any.whl

License :: Other/Proprietary LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

categorical variable encodingsklearn categorical transformerone-hot encoding alternativetarget encoding machine learningcategorical feature preprocessingsupervised categorical encodingfeature engineering categorical data
feature-engineeringcategorical-datasklearn-compatible

More Artificial Intelligence packages