sklift.metrics.uplift_at_k

sklift.metrics.metrics.uplift_at_k(y_true, uplift, treatment, strategy, k=0.3)[source]

Compute uplift at first k observations by uplift of the total sample.

Parameters
  • y_true (1d array-like) – Correct (true) binary target values.

  • uplift (1d array-like) – Predicted uplift, as returned by a model.

  • treatment (1d array-like) – 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 parameter

  • Add parameter strategy

Returns

Uplift score at first k observations of the total sample.

Return type

float

See also

uplift_auc_score(): Compute normalized Area Under the Uplift curve from prediction scores.

qini_auc_score(): Compute normalized Area Under the Qini Curve from prediction scores.