MyNixOS website logo
Description

Optimal Binning Methods for Predictive Modeling and Analytics.

Native R tools for optimal binning workflows in predictive modeling. The package provides APIs for binary, multi-class and continuous targets, with multi-variable binning and scorecard workflows. Methods are informed by Navas-Palencia (2020) <doi:10.48550/arXiv.2001.08025> and Navas-Palencia (2021) <doi:10.48550/arXiv.2104.08619>.

optbinningR

R-CMD-check

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.

Install

CRAN:

install.packages("optbinningR")

CRAN status: submission is currently in process of acceptance.

GitHub:

remotes::install_github("s-rani1/optbinningR")

Local tarball:

install.packages("optbinningR_0.2.1.tar.gz", repos = NULL, type = "source")

No Python dependency for normal use

Core package usage is native R.

You do not need Python for:

  • binary / multiclass / continuous optimal binning
  • binning tables and plots
  • BinningProcess, Scorecard, monitoring, counterfactuals
  • 2D / piecewise / sketch / uncertainty APIs

Python parity scripts in scripts/ are optional validation utilities only.

Quick start (binary)

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")

Plot previews

Binary:

Binary tutorial plot

Continuous:

Continuous tutorial plot

Multiclass:

Multiclass tutorial plot

Tutorials included in this repo

These are GitHub-rendered tutorial pages (recommended for reading):

Source R Markdown files (for editing/running):

Current scope

  • Native R optimal binning: binary, multiclass, continuous targets
  • Numerical and categorical variables
  • Monotonic constraints: ascending, descending, peak, valley, auto
  • Python-style binning_table handle and build() output format
  • Plot parity work aligned to official tutorial styles
  • BinningProcess and Scorecard workflows
  • scorecard_monitoring() and counterfactual_scorecard()
  • Tutorial workflow helpers: run_fico_tutorial() and run_telco_tutorial()

CRAN and release notes

See the CRAN release process documentation in the repository.

Contributing

Contributions are welcome via pull requests.
For substantial changes, please open an issue first to discuss scope and approach.

Issues

Bug reports and feature requests: GitHub Issues

Support

If this project is useful for your work, please consider starring the repository: s-rani1/optbinningR

Relationship to Python optbinning

optbinningR references the upstream methodology and tutorials, but the package code here is reimplemented in R for direct R usage.

Citation and attribution

If you use optbinningR, please cite:

  1. This repository (preferred):
    GitHub “Cite this repository” page: https://github.com/s-rani1/optbinningR?tab=citation
  2. The original optbinning project and references from its documentation:
    https://github.com/guillermo-navas-palencia/optbinning
    https://gnpalencia.org/optbinning/

Citation metadata for this repository is available from the GitHub citation tab.

Metadata

Version

0.2.1

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows