sklift.metrics.response_rate_by_percentile¶
-
sklift.metrics.metrics.
response_rate_by_percentile
(y_true, uplift, treatment, group, strategy='overall', bins=10)[source]¶ Compute response rate (target mean in the control or treatment group) at each percentile.
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.
- group (string, ['treatment', 'control']) –
Group type for computing response rate: treatment or control.
'treatment'
:- Values equal 1 in the treatment column.
'control'
:- Values equal 0 in the treatment column.
- 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.
- bins (int) – Determines the number of bins (and relative percentile) in the data. Default is 10.
Returns: response rate at each percentile for control or treatment group, variance of the response rate at each percentile, group size at each percentile.
Return type: array (shape = [>2]), array (shape = [>2]), array (shape = [>2])