load_credit_scoring_pakdd#

empulse.datasets.load_credit_scoring_pakdd(*, backend)[source]#

Load the credit scoring PAKDD 2009 competition dataset (binary classification).

The goal is to predict whether a customer will default on a loan in the next two years. The target variable is whether the customer defaulted, ‘yes’ = 1 and ‘no’ = 0.

Only clients with a personal income between 100 and 10000 are considered.

For a full data description and additional information about the dataset, consult the User Guide.

Classes

2

Defaulters

7743

Non-defaulters

31195

Samples

38938

Features

25

Parameters:
backendmodule

Dataframe library to use for data and target. Pass the library module directly, e.g. backend=polars or backend=pandas.

Returns:
datasetDataset

instance_costs contains:

  • 'cl': estimated credit line per client (used in fn_cost = cl * lgd).

  • 'fp_cost': precomputed FP cost per client.

Notes

Cost matrix

Actual positive \(y_i = 1\)

Actual negative \(y_i = 0\)

Predicted positive \(\hat{y}_i = 1\)

tp_cost \(= 0\)

fp_cost \(= r_i - (1 - \pi_1) \bar{r} + \pi_1 \overline{Cl} L_{gd}\)

Predicted negative \(\hat{y}_i = 0\)

fn_cost \(= Cl_i \cdot L_{gd}\)

tn_cost \(= 0\)

The cost matrix uses symbolic parameters with the following defaults:

  • loss_given_default (\(L_{gd}\)) = 0.75

The following parameters are used to precompute the per-instance credit lines and fp_cost values stored in instance_costs:

  • interest_rate = 0.63 (annual)

  • fund_cost = 0.165 (annual)

  • max_credit_line = 25000

  • term_length_months = 24

  • loan_to_income_ratio = 3

To override the symbolic default, pass the desired value when evaluating the metric:

metric(dataset.target, y_score, loss_given_default=0.6, **dataset.instance_costs)

References

[1]

A. Correa Bahnsen, D.Aouada, B, Ottersten, “Example-Dependent Cost-Sensitive Logistic Regression for Credit Scoring”, in Proceedings of the International Conference on Machine Learning and Applications, 2014.

Examples

import numpy as np
import pandas as pd
from empulse.datasets import load_credit_scoring_pakdd
from empulse.metrics import Metric, Cost

dataset = load_credit_scoring_pakdd(backend=pd)

# replace with your own model's predicted probabilities
y_score = np.random.default_rng(0).uniform(size=len(dataset.target))

metric = Metric(dataset.cost_matrix, Cost())
score = metric(dataset.target, y_score, **dataset.instance_costs)