Skip to main content

Tools for creating credit scoring models

Project description

Contributors

Forks

Stargazers

Issues

GPLv3 License

LinkedIn

Credit Scoring Toolkit

In finance is a common practice to create risk scorecards to assess the credit worthiness for a given customer. Unfortunately, out of the box credit scoring tools are quite expensive and scatter, that's why we created this toolkit: to empower all credit scoring practicioners and spread the use of weight of evidence based scoring techniques for alternative uses cases (virtually any binary classification problem).


Explore the documentation»
Report Bug

Request Feature

Table of Contents
  1. About The Project
    1. Discrete Normalizer
    2. Discretizer
    3. WoeEncoder
    4. WoeBaseFeatureSelector
    5. WoeContinuousFeatureSelector
    6. WoeDiscreteFeatureSelector
    7. CreditScoring
    8. Built With
  2. Installation
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Citing
  8. Acknowledgments

About The Project

The general process for creating Weight of Evidence based scorecards is illustrated in the figure below :

alt text

For that matter, we implemented the following classes to address the necesary steps to perform credit scoring transformation:

DiscreteNormalizer

Class for normalizing discrete data for a given relative frequency threshold

Discretizer

Class for discretizing continuous data into bins using several methods

WoeEncoder

Class for encoding discrete features into Weight of Evidence(WoE) transformation

WoeBaseFeatureSelector

Base class for selecting features based on their WoE transformation and Information Value statistic.

WoeContinuousFeatureSelector

Class for selecting continuous features based on their WoE transformation and Information Value statistic.

WoeDiscreteFeatureSelector

Class for selecting discrete features based on their WoE transformation and Information Value statistic.

CreditScoring

Implements credit risk scorecards following the methodology proposed in Siddiqi, N. (2012). Credit risk scorecards: developing and implementing intelligent credit scoring (Vol. 3). John Wiley & Sons.

Built With

(back to top)

Installation

You can simply install the module using pip

  • pip
pip install woe-credit-scoring

(back to top)

Usage

The new AutoCreditScoring class provides a streamlined way to train a credit scoring model, generate reports, and make predictions. Here's a quick example of how to use it:

Dependencies

import pandas as pd 
from CreditScoringToolkit import AutoCreditScoring
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="sklearn.preprocessing._discretization")

Reading example data

# Read example data for train and validation (loan applications)
train = pd.read_csv('example_data/train.csv')
valid = pd.read_csv('example_data/valid.csv')   

Defining feature type

# Assign features lists by type
vard = [v for v in train.columns if v.startswith('D_')]
varc = [v for v in train.columns if v.startswith('C_')]

Automated Credit Scoring

The AutoCreditScoring class handles the entire workflow, from feature selection and WoE transformation to model training and scoring.

# If you prefer, use AutoCreditScoring class to perform all the steps in a single call with additional features
# like outlier detection and treatment, feature selection, reporting and more.
from CreditScoringToolkit import AutoCreditScoring

kwargs = {'iv_feature_threshold':0.05,
          'max_discretization_bins':6,
          'strictly_monotonic':True,
          'create_reporting':True,
          'discretization_method':'dcc'}
acs = AutoCreditScoring(train,'TARGET',varc,vard)
acs.fit(**kwargs)

# You can also save the reports to a folder in PNG format
acs.save_reports('reports')

This will generate several reports, including:

  • Score distribution histograms and KDE plots
  • Event rate by score range plots
  • Feature importance based on Information Value
  • ROC curve for the model

png png png png png

Making Predictions

Once the model is trained, you can use the predict method to score new data.

predictions = acs.predict(valid)
predictions.head()

This will return a DataFrame with the individual point contributions for each feature (pts_* columns) and the final score.

(back to top)

Contributing

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

Don't forget to give the project a star! Thanks again!

  1. Fork the Project

  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)

  3. Commit your Changes (git commit -m 'Add some AmazingFeature')

  4. Push to the Branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request

(back to top)

License

Distributed under the GNU General Public License v3.0 License. See LICENSE for more information.

(back to top)

Contact

José G Fuentes - @jgusteacher - jose.gustavo.fuentes@comunidad.unam.mx

Project Link: https://github.com/JGFuentesC/woe_credit_scoring

(back to top)

Citing

If you use this software in scientific publications, we would appreciate citations to the following paper:

Combination of Unsupervised Discretization Methods for Credit Risk José G. Fuentes Cabrera, Hugo A. Pérez Vicente, Sebastián Maldonado,Jonás Velasco

(back to top)

Acknowledgments

(back to top)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

woe_credit_scoring-2.0.2.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

woe_credit_scoring-2.0.2-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file woe_credit_scoring-2.0.2.tar.gz.

File metadata

  • Download URL: woe_credit_scoring-2.0.2.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for woe_credit_scoring-2.0.2.tar.gz
Algorithm Hash digest
SHA256 33d3b6c3df24ef72e2579d5928492e194bacc701010973b5b1a1c4ee661dd637
MD5 938e7c65af9e635fc05262426c3c3171
BLAKE2b-256 1f937e8d5c9c7f45a0896bfa42650e1ffed18c70fd453ba56530f59735b9f859

See more details on using hashes here.

File details

Details for the file woe_credit_scoring-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for woe_credit_scoring-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a93967e79f1157a51801990db6c15585875c6749326331573f57080943a462b
MD5 4f81a0819cd5f42035c0f038dab98cc7
BLAKE2b-256 477f6ecf70202e443c4c5ae005ebae1a388ebc068385cd838ce028bfb69755b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page