plot_precision_recall_curve#

scikitplot.metrics.plot_precision_recall_curve(y_true, y_probas, title='Precision-Recall Curve', curves=('micro', 'each_class'), ax=None, figsize=None, cmap='nipy_spectral', title_fontsize='large', text_fontsize='medium')#

Generates the Precision Recall Curve from labels and probabilities

Parameters:
  • y_true (array-like, shape (n_samples)) – Ground truth (correct) target values.

  • y_probas (array-like, shape (n_samples, n_classes)) – Prediction probabilities for each class returned by a classifier.

  • title (string, optional) – Title of the generated plot. Defaults to “Precision-Recall curve”.

  • curves (array-like) – A listing of which curves should be plotted on the resulting plot. Defaults to ("micro", "each_class") i.e. “micro” for micro-averaged curve

  • ax (matplotlib.axes.Axes, optional) – The axes upon which to plot the curve. If None, the plot is drawn on a new set of axes.

  • figsize (2-tuple, optional) – Tuple denoting figure size of the plot e.g. (6, 6). Defaults to None.

  • cmap (string or matplotlib.colors.Colormap instance, optional) – Colormap used for plotting the projection. View Matplotlib Colormap documentation for available options. https://matplotlib.org/users/colormaps.html

  • title_fontsize (string or int, optional) – Matplotlib-style fontsizes. Use e.g. “small”, “medium”, “large” or integer-values. Defaults to “large”.

  • text_fontsize (string or int, optional) – Matplotlib-style fontsizes. Use e.g. “small”, “medium”, “large” or integer-values. Defaults to “medium”.

Returns:

The axes on which the plot was

drawn.

Return type:

ax (matplotlib.axes.Axes)

Example

>>> import scikitplot as skplt
>>> nb = GaussianNB()
>>> nb.fit(X_train, y_train)
>>> y_probas = nb.predict_proba(X_test)
>>> skplt.metrics.plot_precision_recall_curve(y_test, y_probas)
<matplotlib.axes._subplots.AxesSubplot object at 0x7fe967d64490>
>>> plt.show()
Precision Recall Curve