optbinningR is a native R package for optimal binning, scorecard, and monitoring workflows.
This is an independent implementation for the R community, inspired by the Python package optbinning, but rewritten for R users and R package conventions.
If you want a practical overview of why optbinningR was built, where it fits across industries, and what the outputs look like, see the Medium article:
Introducing optbinningR: Native Optimal Binning Is Now Easy in R
CRAN:
install.packages("optbinningR")
Available on CRAN.
GitHub:
# remotes::install_github("s-rani1/optbinningR")
install.packages("optbinningR", repos = c('https://s-rani1.r-universe.dev', 'https://cloud.r-project.org'))
Local tarball:
install.packages("optbinningR_0.2.1.tar.gz", repos = NULL, type = "source")
Core package usage is native R.
You do not need Python for:
BinningProcess, Scorecard, monitoring, counterfactualsPython parity scripts in scripts/ are optional validation utilities only.
library(optbinningR)
d <- read.csv(system.file("extdata", "breast_cancer_mean_radius.csv", package = "optbinningR"))
y <- d$y
x <- d$x
ob <- OptimalBinning(name = "mean radius", dtype = "numerical")
ob <- fit(
ob, x, y,
algorithm = "optimal",
prebinning_method = "cart",
max_n_prebins = 20,
max_n_bins = 6,
monotonic_trend = "auto"
)
bt <- binning_table(ob)
build(bt)
plot(ob, type = "woe")
Binary:

Continuous:

Multiclass:

These are GitHub-rendered tutorial pages (recommended for reading):
Source R Markdown files (for editing/running):
inst/doc/tutorial-binary.Rmd
inst/doc/tutorial-continuous.Rmd
inst/doc/tutorial-multiclass.Rmd
inst/doc/getting-started.Rmd
ascending, descending, peak, valley, auto
binning_table handle and build() output formatBinningProcess and Scorecard workflowsscorecard_monitoring() and counterfactual_scorecard()
run_fico_tutorial() and run_telco_tutorial()
See the CRAN release process documentation in the repository.
Contributions are welcome via pull requests.
For substantial changes, please open an issue first to discuss scope and approach.
Bug reports and feature requests: GitHub Issues
If this project is useful for your work, please consider starring the repository: s-rani1/optbinningR
optbinning
optbinningR references the upstream methodology and tutorials, but the package code here is reimplemented in R for direct R usage.
If you use optbinningR, please cite:
optbinning project and references from its documentation:Citation metadata for this repository is available from the GitHub citation tab.