plot_lift#

scikitplot.kds.plot_lift(y_true, y_probas, *args, pos_label=None, class_index=1, title='Lift Curves', ax=None, fig=None, figsize=None, title_fontsize='large', text_fontsize='medium', data=None, **kwargs)[source]#

Generates the Decile based cumulative Lift Plot from labels and probabilities.

View aliases#

Main aliases

scikitplot.api.kds.plot_lift

Compat aliases

scikitplot.kds.plot_lift

The lift curve is used to determine the effectiveness of a binary classifier. A detailed explanation can be found at http://www2.cs.uregina.ca/~dbd/cs831/notes/lift_chart/lift_chart.html The implementation here works only for binary classification.

Parameters:
y_truearray-like of shape (n_samples,)

Ground truth (correct) target values.

y_probasarray-like of shape (n_samples,) or (n_samples, n_classes)

Predicted probabilities for each class or only target class probabilities. If 1D, it is treated as probabilities for the positive class in binary or multiclass classification with the class_index.

class_indexint, optional, default=1

Index of the class of interest for multi-class classification. Ignored for binary classification.

titlestr, default=’Lift Curves’

Title of the plot.

title_fontsizestr or int, optional, default=’large’

Font size for the plot title.

text_fontsizestr or int, optional, default=’medium’

Font size for the text in the plot.

**kwargsdict, optional

Added in version 0.3.9.

Returns:
matplotlib.axes.Axes

The axes with the plotted lift curves.

Other Parameters:
axmpl.axes.Axes, optional

The axes on which to plot. If None, a new one will be created.

figmpl.figure.Figure, optional

The figure in which to place the axes. If None, a new one will be created.

figsizetuple, optional

Size of the figure if a new one is created. Default is None.

nrowsint, optional

Number of rows in the subplot grid. Default is 1.

ncolsint, optional

Number of columns in the subplot grid. Default is 1.

indexint or tuple, optional

The position of the subplot on the grid. It can be: - An integer specifying the position (1-based).

*argstuple, optional

validate_plotting_kwargs properties Positional arguments passed to the function.

**kwargsdict, optional

validate_plotting_kwargs properties Keyword arguments passed to the function.

See also

plot_lift_decile_wise

Generates the Decile-wise Lift Plot from labels and probabilities.

Examples

>>> from sklearn.datasets import load_iris as data_3_classes
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.linear_model import LogisticRegression
>>> import scikitplot as skplt
>>> X, y = data_3_classes(return_X_y=True, as_frame=False)
>>> X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.5, random_state=0)
>>> model = LogisticRegression(max_iter=int(1e5), random_state=0).fit(X_train, y_train)
>>> y_probas = model.predict_proba(X_val)
>>> skplt.kds.plot_lift(
>>>     y_val, y_probas, class_index=1,
>>> );

(Source code, png)

Lift Curves