decileplot#

scikitplot.snsx.decileplot(data=None, *, x=None, y=None, hue=None, kind=None, weights=None, n_deciles=10, hue_order=None, hue_norm=None, palette=None, color=None, fill=False, baseline=False, line_kws=None, log_scale=None, legend=True, ax=None, digits=None, common_norm=None, verbose=False, **kwargs)[source]#

Given binary labels y_true (0/1) and probabilities y_score 1d array, compute/plot a decile [2] table.

The function sorts observations by descending score, assigns decile index (1..n_deciles) using pandas qcut on the rank/index to ensure near-equal bins, and computes standard decile-level stats (features):

[
    "decile",
    "prob_min",
    "prob_max",
    "prob_avg",
    "cnt_resp_total",
    "cnt_resp",
    "cnt_resp_non",
    "cnt_resp_rndm",
    "cnt_resp_wiz",
    "rate_resp",  # (alias to decile_wise_response, decile_wise_gain)
    "cum_resp_total",
    "cum_resp_total_pct",
    "cum_resp",  #  (alias to cumulative_gain)
    "cum_resp_pct",
    "cum_resp_non",
    "cum_resp_non_pct",
    "cum_resp_rndm",
    "cum_resp_rndm_pct",
    "cum_resp_wiz",
    "cum_resp_wiz_pct",
    "KS",
    "cumulative_lift",
    "decile_wise_lift",
]
Parameters:
datapandas.DataFrame, numpy.ndarray, mapping, or sequence

Input data structure. Either a long-form collection of vectors that can be assigned to named variables or a wide-form dataset that will be internally reshaped.

x, yvectors or keys in data

Variables that specify positions on the x and y axes.

huevector or key in data

Semantic variable that is mapped to determine the color of plot elements.

kind{‘df’, ‘cumulative_lift’, ‘decile_wise_lift’, ‘cumulative_gain’, ‘decile_wise_gain’, ‘cumulative_response’, ‘ks_statistic’, ‘report’} or None, default=None

Kind of plot to make.

  • if 'df', not plot return as pandas.DataFrame;

  • if None, the plot is roc curve.

weightsvector or key in data

If provided, observation weights used for computing the distribution function.

n_decilesint, optional, default=10

The number of partitions for creating the table. Defaults to 10 for deciles.

hue_ordervector of strings

Specify the order of processing and plotting for categorical levels of the hue semantic.

hue_normtuple or matplotlib.colors.Normalize

Either a pair of values that set the normalization range in data units or an object that will map from data units into a [0, 1] interval. Usage implies numeric mapping.

palettestring, list, dict, or matplotlib.colors.Colormap

Method for choosing the colors to use when mapping the hue semantic. String values are passed to color_palette. List or dict values imply categorical mapping, while a colormap object implies numeric mapping.

colormatplotlib color

Single color specification for when hue mapping is not used. Otherwise, the plot will try to hook into the matplotlib property cycle.

fillbool or None

If True, fill in the area under univariate density curves or between bivariate contours. If None, the default depends on multiple.

{line}_kwsdictionaries

Additional keyword arguments to pass to plt.plot.

log_scalebool or number, or pair of bools or numbers

Set axis scale(s) to log. A single value sets the data axis for any numeric axes in the plot. A pair of values sets each axis independently. Numeric values are interpreted as the desired base (default 10). When None or False, seaborn defers to the existing Axes scale.

legendbool

If False, suppress the legend for semantic variables.

axmatplotlib.axes.Axes

Pre-existing axes for the plot. Otherwise, call matplotlib.pyplot.gca internally.

digitsint, optional, default=4

Number of digits for formatting output floating point values. When output_dict is True, this will be ignored and the returned values will not be rounded.

output_dictbool, default=False

If True, return output as dict.

zero_division{‘warn’, 0.0, 1.0, np.nan}, default=’warn’

Sets the value to return when there is a zero division. If set to ‘warn’, this acts as 0, but warnings are also raised.

common_normbool

If True, scale each conditional density by the number of observations such that the total area under all densities sums to 1. Otherwise, normalize each density independently.

verbosebool, optional, default=False

Whether to be verbose.

kwargs

Other keyword arguments are passed to one of the following matplotlib functions:

Returns:
pandas.DataFrame | matplotlib.axes.Axes | dict

The dataframe (decile-table) with the indexed by deciles (sorted ascending) and related information (decile-level metrics). If hue/facet semantics were used, the returned table will include extra columns for those keys (e.g., ‘hue’).

Warning

Some function parameters are experimental prototypes. These may be modified, renamed, or removed in future library versions. Use with caution and check documentation for the latest updates.

Parameters:
Return type:

DataFrame | Axes

References