optbinning
OptBinning: The Python Optimal Binning library
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 optbinninguv
uv add optbinningpoetry
poetry add optbinningInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
optlangOptlang formulates and solves linear,…
permissive · top 15,000 on PyPI
jenkspyComputes optimal class boundaries for numerical…
permissive · top 15,000 on PyPI
ropwrRoPWR computes optimal piecewise polynomial…
permissive · top 15,000 on PyPI
prtpyImplements multiway number partitioning and bin…
permissive · top 15,000 on PyPI
py3dbpSolves the 3D bin packing problem by fitting…
permissive · top 5,000 on PyPI
nloptNLopt provides Python bindings to the NLopt…
permissive · top 5,000 on PyPI
cvxoptcvxopt is a Python library for solving convex…
unclear · top 5,000 on PyPI
binpackingDistributes weighted items into bins using…
permissive · top 15,000 on PyPI
cvxpy-basecvxpy-base provides compiled solver kernels for…
permissive · top 15,000 on PyPI
munkresImplements the Munkres algorithm (Hungarian…
permissive · top 15,000 on PyPI