Skip to main content

Monotonic-WOE-Binning-Algorithm

This algorithm is based on the excellent paper by Mironchyk and Tchistiakov (2017) named "Monotone optimal binning algorithm for credit risk modeling".

How to use

  1. pip install monotonic_binning: pip install -i https://test.pypi.org/simple/simple/ monotonic-binning
  2. Import monotonic_woe_binning: from monotonic_binning import monotonic_woe_binning as bin
  3. Use fit and transform to bin variables for train and test datasets respectively

Demo Run Details

The demo_run.py file available under tests/ uses German credit card data from Penn State's online course and gives an overview of how to use the package.

Summary of Monotonic WOE

The weight-of-evidence (WOE) method of evaluating strength of predictors is an understated one in the field of analytics. While it is standard fare in credit risk modelling, it is under-utilized in other settings though its formulation makes it generic enough for use in other domains too. The WOE method primarily aims to bin variables into buckets that deliver the most information to a potential classification model. Quite often, WOE binning methods measure effectiveness of such bins using Information Value or IV. For a more detailed introduction to WOE and IV, this article is a useful read.

In the world of credit risk modelling, regulatory oversight often requires that the variables that go into models are split into bins

  • whose weight of evidence (WOE) values maintain a monotonic relationship with the 1/0 variable (loan default or not default for example.)
  • are reasonably sized and large enough to be respresentative of population segments, and
  • maximize the IV value of the given variable in the process of this binning.

To exemplify the constraints such a problem, consider a simple dataset containing age and a default indicator (1 if defaulted, 0 if not). The following is a possible scenario in which the variable is binned into three groups in such a manner that their WOE values decrease monotomically as the ages of customers increase.

The WOE is derived in such a manner that as the WOE value increases, the default rate decreases. So we can infer that younger customers are more likely to default in comparison to older customers.

Arriving at the perfect bin cutoffs to meet all three requirements discussed earlier is a non-trivial exercise. Most statistical software provide this type of optimal discretization of interval variables. R's smbinning package and SAS' proc transreg are two such examples. To my knowledge, Python's solutions to this problem are fairly sparse.

This package is an attempt to complement already exhaustive packages like scorecardpy with the capability to bin variables with monotonic WOE.

Metadata

Release files for monotonic-binning 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for monotonic-binning 0.0.1
File Size Uploaded Provenance Actions
monotonic_binning-0.0.1.tar.gz 4.9 kB Without provenance Details for monotonic_binning-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for monotonic-binning 0.0.1
File Interpreter ABI Platform Actions
monotonic_binning-0.0.1-py3-none-any.whl Python 3 none any Details for monotonic_binning-0.0.1-py3-none-any.whl

Total release size: 10.9 kB

Release files / monotonic_binning-0.0.1.tar.gz

Download URL monotonic_binning-0.0.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
65f79d807b7ec0f37be80ee64334baaaed35ef44ac17bd0688c9f3e737bf7d09
BLAKE2b-256 checksum
How to use checksums
c83faf5dfe5546d0be72a528f3f8a174a9b21a88f6fd701f82de84c14ecc7928
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release files / monotonic_binning-0.0.1-py3-none-any.whl

Download URL monotonic_binning-0.0.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84599df1431c563a6f737d44d89821f09ea52045ad1492995e46cfb934f5be7c
BLAKE2b-256 checksum
How to use checksums
a69e4fc8a79c1555b52de9e6f7b297c3841a9e06d164181e7108df00084422fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Security for monotonic-binning 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page