skillfed

optbinning

OptBinning: The Python Optimal Binning library

optbinning v0.21.0 298.8K downloads/30d#7,868 on PyPI531
Permissive license Apache Licence 2.0 AGING released

What it is and what it does

OptBinning is a Python library that solves the optimal binning problem—finding the best way to discretize a continuous or discrete numeric variable into bins to maximize predictive power or meet other objectives with respect to a target variable. It uses rigorous mathematical programming to handle binary, continuous, and multiclass targets, and incorporates constraints that go beyond simpler binning approaches.

The library depends on numpy, scipy, scikit-learn, pandas, matplotlib, ortools, and ropwr. It is designed for data scientists and researchers working on feature engineering, model preprocessing, and statistical analysis where controlled discretization of variables is needed.

Use it for:

  • Feature engineering in credit risk or classification models where binned variables improve interpretability and model performance.
  • Discretizing continuous predictors in logistic regression or tree-based models with explicit constraints on bin counts or monotonicity.
  • Exploratory data analysis to find natural or optimal breakpoints in a variable's relationship to a target outcome.
  • Preprocessing for regulatory or compliance requirements that demand human-interpretable variable bins with documented thresholds.

Worth the install?

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

OptBinning discretizes numeric variables into bins optimally for binary, continuous, and multiclass targets using mathematical programming, with support for constraints.

Yes, if you need principled optimal binning with constraint support for feature engineering. The low install friction, permissive license, and active (though aging) maintenance make it a solid choice. However, verify that its mathematical programming approach and dependency footprint fit your performance and deployment constraints before committing to production use.

Install

optbinning on PyPI

pip

pip install optbinning

uv

uv add optbinning

poetry

poetry add optbinning

Installing optbinning

Before you install

Low install friction with a pure-wheel distribution. Maintenance status is aging—last commit was 292 days ago—but the repository remains active and not archived, with steady community interest (531 stars).

License in practice

Distributed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions; you must retain license and copyright notices.

Quickstart

pip install optbinning
import optbinning
# Requires numpy, scipy, scikit-learn, pandas, matplotlib, ortools, ropwr as runtime dependencies

Verify before relying

  • Whether the mathematical programming formulation scales to very large datasets or high-dimensional problems.
  • Performance characteristics and typical runtime for common binning scenarios.
  • Specific constraint types supported beyond what the description excerpt mentions.

Package facts

License Apache Licence 2.0 (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 7 — matplotlib, numpy, ortools, pandas, ropwr, scikit-learn, scipy
Maintenance aging — 292 days since the last release
Last repo commit
First released
Downloads 298,804/month — #7,868 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: optbinning-0.21.0-py3-none-any.whl

Intended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

optimal binning discretizationvariable binning pythonoptimal discretization targetbinning constraints optimizationcontinuous target binningmulticlass binning algorithmmathematical programming binning
feature-engineeringdiscretizationoptimization

More Libraries packages