yasc.scorecard.ksplot

yasc.scorecard.ksplot(preds, labels, data=None, n=50, is_prob=True, equal_aspect=False)

Plot distributions of good and bad clients, including an estimate of the KS statistics.

Parameters
predsarray, shape=[n_samples]

Predicted values of the positive class, either scores or probabilities.

labelsarray, shape=[n_samples]

True binary labels. A label takes value in {0, 1} with 0 indicating a good client, 1 a bad client.

dataDataFrame, optional

A data frame returned by yasc.scorecard.util._util.compute_ks_lift(). Defaults to None.

nint, optional

Number of segments to compute KS, by default 50

is_probbool, optional

If True given, preds are probabilities else scores, by default True

equal_aspectbool, optional

Whether to make aspect equal. Defaults to False.

Returns
ks_valuefloat

The value of KS statistics.

axmatplotlib.axes.Axes

Axes object with the plot drawn onto it.

Examples

Plot a simple KS curve.

>>> import numpy as np
>>> np.random.seed(0)
>>> preds = np.random.rand(1000)
>>> labels = np.random.choice(2, 1000)
>>> from yasc.scorecard.util import ksplot
>>> ksplot(preds, labels)
../_images/yasc-scorecard-ksplot-1.png