For general information regarding scikit-learn visualization tools, see
the Visualization Guide.
For guidance on interpreting these plots, refer to the
Model Evaluation Guide.
Parameters:
confusion_matrix : ndarray of shape (n_classes, n_classes)
Confusion matrix.
display_labels : ndarray of shape (n_classes,), default=None
Display labels for plot. If None, display labels are set from 0 to
n_classes-1.
Attributes:
im_ : matplotlib AxesImage
Image representing the confusion matrix.
text_ : ndarray of shape (n_classes, n_classes), dtype=matplotlib Text, or None
Array of matplotlib axes. None if include_values is false.
Plot Confusion Matrix given an estimator and some data.
For general information regarding scikit-learn visualization tools, see
the Visualization Guide.
For guidance on interpreting these plots, refer to the
Model Evaluation Guide.
Parameters:
estimator : estimator instance
Fitted classifier or a fitted
in which the last estimator is a classifier.
Plot Confusion Matrix given true and predicted labels.
For general information regarding scikit-learn visualization tools, see
the Visualization Guide.
For guidance on interpreting these plots, refer to the
Model Evaluation Guide.
Parameters:
y_true : array-like of shape (n_samples,)
True labels.
y_pred : array-like of shape (n_samples,)
The predicted labels given by the method of an
classifier.
Classification of text documents using sparse features
Pipeline
X : {array-like, sparse matrix} of shape (n_samples, n_features)
Input values.
y : array-like of shape (n_samples,)
Target values.
labels : array-like of shape (n_classes,), default=None
List of labels to index the confusion matrix. This may be used to
reorder or select a subset of labels. If None is given, those
that appear at least once in y_true or y_pred are used in
sorted order.
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.
normalize : {‘true’, ‘pred’, ‘all’}, default=None
Either to normalize the counts display in the matrix:
if 'true', the confusion matrix is normalized over the true
conditions (e.g. rows);
if 'pred', the confusion matrix is normalized over the
predicted conditions (e.g. columns);
if 'all', the confusion matrix is normalized by the total
number of samples;
if None (default), the confusion matrix will not be normalized.
display_labels : array-like of shape (n_classes,), default=None
Target names used for plotting. By default, labels will be used
if it is defined, otherwise the unique labels of y_true and
y_pred will be used.
include_values : bool, default=True
Includes values in confusion matrix.
xticks_rotation : {‘vertical’, ‘horizontal’} or float, default=’horizontal’
Rotation of xtick labels.
values_format : str, default=None
Format specification for values in confusion matrix. If None, the
format specification is ‘d’ or ‘.2g’ whichever is shorter.
cmap : str or matplotlib Colormap, default=’viridis’
Colormap recognized by matplotlib.
ax : matplotlib Axes, default=None
Axes object to plot on. If None, a new figure and axes is
created.
colorbar : bool, default=True
Whether or not to add a colorbar to the plot.
im_kw : dict, default=None
Dict with keywords passed to matplotlib.pyplot.imshow call.
text_kw : dict, default=None
Dict with keywords passed to matplotlib.pyplot.text call.
labels : array-like of shape (n_classes,), default=None
List of labels to index the confusion matrix. This may be used to
reorder or select a subset of labels. If None is given, those
that appear at least once in y_true or y_pred are used in
sorted order.
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.
normalize : {‘true’, ‘pred’, ‘all’}, default=None
Either to normalize the counts display in the matrix:
if 'true', the confusion matrix is normalized over the true
conditions (e.g. rows);
if 'pred', the confusion matrix is normalized over the
predicted conditions (e.g. columns);
if 'all', the confusion matrix is normalized by the total
number of samples;
if None (default), the confusion matrix will not be normalized.
display_labels : array-like of shape (n_classes,), default=None
Target names used for plotting. By default, labels will be used
if it is defined, otherwise the unique labels of y_true and
y_pred will be used.
include_values : bool, default=True
Includes values in confusion matrix.
xticks_rotation : {‘vertical’, ‘horizontal’} or float, default=’horizontal’
Rotation of xtick labels.
values_format : str, default=None
Format specification for values in confusion matrix. If None, the
format specification is ‘d’ or ‘.2g’ whichever is shorter.
cmap : str or matplotlib Colormap, default=’viridis’
Colormap recognized by matplotlib.
ax : matplotlib Axes, default=None
Axes object to plot on. If None, a new figure and axes is
created.
colorbar : bool, default=True
Whether or not to add a colorbar to the plot.
im_kw : dict, default=None
Dict with keywords passed to matplotlib.pyplot.imshow call.
text_kw : dict, default=None
Dict with keywords passed to matplotlib.pyplot.text call.