Metrics (sklift.metrics)¶

sklift.metrics.metrics.
auqc
(y_true, uplift, treatment)[source]¶ Compute Area Under the Qini Curve (aka Qini coefficient) from prediction scores.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Area Under the Qini Curve.
Return type: float
Warning
Metric auqc was renamed to
qini_auc_score()
in version 0.1.0 and will be removed in 0.2.0

sklift.metrics.metrics.
auuc
(y_true, uplift, treatment)[source]¶ Compute Area Under the Uplift Curve from prediction scores.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Area Under the Uplift Curve.
Return type: float
Warning
Metric auuc was renamed to
uplift_auc_score()
in version 0.1.0 and will be removed in 0.2.0

sklift.metrics.metrics.
qini_auc_score
(y_true, uplift, treatment)[source]¶ Compute Area Under the Qini Curve (aka Qini coefficient) from prediction scores.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Area Under the Qini Curve.
Return type: float

sklift.metrics.metrics.
qini_curve
(y_true, uplift, treatment)[source]¶ Compute Qini curve.
This is a general function, given points on a curve. For computing the area under the Qini Curve, see
qini_auc_score()
.Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Points on a curve.
Return type: array (shape = [>2]), array (shape = [>2])
See also
qini_auc_score()
: Compute the area under the Qini curve.plot_uplift_qini_curves()
: Plot Uplift and Qini curves.

sklift.metrics.metrics.
response_rate_by_percentile
(y_true, uplift, treatment, group, strategy, bins=10)[source]¶ Compute response rate (target mean in the control or treatment group) at each percentile.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – 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. *
'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 test data.
Returns: Response rate at each percentile for control or treatment group array: Variance of the response rate at each percentile
Return type: array

sklift.metrics.metrics.
treatment_balance_curve
(uplift, treatment, winsize)[source]¶ Compute the treatment balance curve: proportion of treatment group in the ordered predictions.
Parameters:  uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
 winsize (int) – Size of the sliding window for calculating the balance between treatment and control.
Returns: Points on a curve.
Return type: array (shape = [>2]), array (shape = [>2])

sklift.metrics.metrics.
uplift_at_k
(y_true, uplift, treatment, strategy, k=0.3)[source]¶ Compute uplift at first k percentage of the total sample.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
 k (float or int) – If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the computation of uplift. If int, represents the absolute number of samples.
 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

Changed in version 0.1.0:
Add supporting absolute values for
k
parameterAdd parameter
strategy
Returns: Uplift score at first k observations of the total sample. Return type: float

sklift.metrics.metrics.
uplift_auc_score
(y_true, uplift, treatment)[source]¶ Compute Area Under the Uplift Curve from prediction scores.
Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Area Under the Uplift Curve.
Return type: float

sklift.metrics.metrics.
uplift_curve
(y_true, uplift, treatment)[source]¶ Compute Uplift curve
This is a general function, given points on a curve. For computing the area under the Uplift Curve, see
uplift_auc_score()
.Parameters:  y_true (1d arraylike) – Correct (true) target values.
 uplift (1d arraylike) – Predicted uplift, as returned by a model.
 treatment (1d arraylike) – Treatment labels.
Returns: Points on a curve.
Return type: array (shape = [>2]), array (shape = [>2])
See also
uplift_auc_score()
: Compute the area under the Uplift curve.plot_uplift_qini_curves()
: Plot Uplift and Qini curves.