sklift.viz.plot_uplift_by_percentile

sklift.viz.base.plot_uplift_by_percentile(y_true, uplift, treatment, strategy='overall', 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 array-like) – Correct (true) target values.
  • uplift (1d array-like) – Predicted uplift, as returned by a model.
  • treatment (1d array-like) – Treatment labels.
  • strategy (string, ['overall', 'by_group']) –

    Determines the calculating strategy. Default is ‘overall’.

    • '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 bar-style plot.
  • bins (int) – Determines а number of bins (and the relative percentile) in the test data. Default is 10.
Returns:

Object that stores computed values.