toad.metrics module

toad.metrics.AIC(y_pred, y, k, lf=None)[source]

Akaike Information Criterion

Parameters:
  • y_pred (array-like) –
  • y (array-like) –
  • k (int) – number of featuers
  • lf (float) – result of likelihood function
toad.metrics.AUC(score, target)[source]

AUC Score

Parameters:
  • score (array-like) – list of score or probability that the model predict
  • target (array-like) – list of real target
Returns:

auc score

Return type:

float

toad.metrics.BIC(y_pred, y, k, lf=None)[source]

Bayesian Information Criterion

Parameters:
  • y_pred (array-like) –
  • y (array-like) –
  • k (int) – number of featuers
  • lf (float) – result of likelihood function
toad.metrics.F1(score, target, split='best', return_split=False)[source]

calculate f1 value

Parameters:
  • score (array-like) –
  • target (array-like) –
Returns:

best f1 score float: best spliter

Return type:

float

toad.metrics.KS(score, target)[source]

calculate ks value

Parameters:
  • score (array-like) – list of score or probability that the model predict
  • target (array-like) – list of real target
Returns:

the max KS value

Return type:

float

toad.metrics.KS_bucket(score, target, bucket=10, method='quantile', **kwargs)[source]

calculate ks value by bucket

Parameters:
  • score (array-like) – list of score or probability that the model predict
  • target (array-like) – list of real target
  • bucket (int) – n groups that will bin into
  • method (str) – method to bin score. quantile (default), step
Returns:

DataFrame

toad.metrics.KS_by_col(df, by='feature', score='score', target='target')[source]
toad.metrics.MSE(y_pred, y)[source]

mean of squares due to error

toad.metrics.PSI(test, base, combiner=None, return_frame=False)[source]

calculate PSI

Parameters:
  • test (array-like) – data to test PSI
  • base (array-like) – base data for calculate PSI
  • combiner (Combiner|list|dict) – combiner to combine data
  • return_frame (bool) – if need to return frame of proportion
Returns:

float|Series

toad.metrics.SSE(y_pred, y)[source]

sum of squares due to error