Skip to content

Scorecard

ScoreCard

The function calculates the scorecard based on the log odds.

Parameters:

  • y_proba: np.ndarray or pd.Series
    A numpy ndarray with probabilities of default. If log == True, then ln(probabilities).
  • log: bool
    Whether y_proba is ln(probabilities) or not.
  • target_score: int, default = 600
    A baseline score.
  • target_odds: int, default = 30
    The corresponding odds for the target_score.
  • pdo: int, default = 20
    Points to double odds.

Returns:

  • pred: pd.DataFrame
    A pandas DataFrame with probability and the corresponding Score.

Exceptions:

  • TypeError:
    Raised if log parameter is not logical.
    Raised if y_proba parameter is not np.ndarray or pd.Series.

  • ValueError:
    Raised if probabilities parameter does not have 1 column.
    Raised if target_score is not a positive integer.
    Raised if target_odds is not a positive integer.
    Raised if pdo is not a positive integer.

Example:

import numpy as np
import pandas as pd
from combat.scorecard import ScoreCard

# Sample input data
y_proba = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
log = False
target_score = 600
target_odds = 30
pdo = 20

# Calculate scorecard
result = ScoreCard(y_proba, log, target_score, target_odds, pdo)
print(result)