Visualization (sklift.viz)¶

sklift.viz.base.
plot_treatment_balance_curve
(uplift, treatment, random=True, winsize=0.1)[source]¶ Plot Treatment Balance curve.
Parameters:  uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
 random (bool, default True) – Draw a random curve.
 winsize (float, default 0.1) – Size of the sliding window to apply. Should be between 0 and 1, extremes excluded.
Returns: Object that stores computed values.

sklift.viz.base.
plot_uplift_by_percentile
(y_true, uplift, treatment, strategy, kind='line', bins=10)[source]¶ Plot uplift score, treatment response rate and control response rate at each percentile.
Treatment response rate ia a target mean in the treatment group. Control response rate is a target mean in the control group. Uplift score is a difference between treatment response rate and control response rate.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
 strategy (string, ['overall', 'by_group']) –
Determines the calculating strategy.
'overall'
: The first step is taking the first k observations of all test data ordered by uplift prediction (overall both groups  control and treatment) and conversions in treatment and control groups calculated only on them. Then the difference between these conversions is calculated.
'by_group'
: Separately calculates conversions in top k observations in each group (control and treatment) sorted by uplift predictions. Then the difference between these conversions is calculated.
 kind (string, ['line', 'bar']) –
The type of plot to draw. Default is ‘line’.
'line'
: Generates a line plot.
'bar'
: Generates a traditional barstyle plot.
 bins (int) – Determines а number of bins (and а relative percentile) in the test data. Default is 10.
Returns: Object that stores computed values.

sklift.viz.base.
plot_uplift_preds
(trmnt_preds, ctrl_preds, log=False, bins=100)[source]¶ Plot histograms of treatment, control and uplift predictions.
Parameters:  trmnt_preds (1d arraylike) – Predictions for all observations if they are treatment.
 ctrl_preds (1d arraylike) – Predictions for all observations if they are control.
 log (bool, default False) – Logarithm of source samples.
 bins (integer or sequence, default 100) – Number of histogram bins to be used. If an integer is given, bins + 1 bin edges are calculated and returned. If bins is a sequence, gives bin edges, including left edge of first bin and right edge of last bin. In this case, bins is returned unmodified.
Returns: Object that stores computed values.

sklift.viz.base.
plot_uplift_qini_curves
(y_true, uplift, treatment, random=True, perfect=False)[source]¶ Plot Uplift and Qini curves.
Parameters:  y_true (1d arraylike) – Ground truth (correct) labels.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
 random (bool, default True) – Draw a random curve.
 perfect (bool, default False) – Draw a perfect curve.
Returns: Object that stores computed values.