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.
Predicted values of the positive class, either scores or probabilities.
True binary labels. A label takes value in {0, 1} with 0 indicating a good client, 1 a bad client.
A data frame returned by yasc.scorecard.util._util.compute_ks_lift()
.
Defaults to None
.
Number of segments to compute KS, by default 50
If True given, preds are probabilities else scores, by default True
Whether to make aspect equal. Defaults to False
.
The value of KS statistics.
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)