classification_report
- sklearn.metrics.classification_report(y_true, y_pred, *, labels=None, target_names=None, sample_weight=None, digits=2, output_dict=False, zero_division
Build a text report showing the main classification metrics.
Read more in the User Guide.
Ground truth (correct) target values. Sparse matrix is only supported when targets are of multilabel type.
Estimated targets as returned by a classifier. Sparse matrix is only supported when targets are of multilabel type.
Optional list of label indices to include in the report.
Optional display names matching the labels (same order).
Sample weights.
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.
If True, return output as dict.
Sets the value to return when there is a zero division. If set to “warn”, this acts as 0, but warnings are also raised.
Text summary of the precision, recall, F1 score for each class. Dictionary returned if output_dict is True. Dictionary has the following structure:
{'label 1': {'precision':0.5,
'recall':1.0,
'f1-score':0.67,
'support':1},
'label 2': { ... },
>>> from sklearn.metrics import classification_report
>>> y_true = [0, 1, 2, 2, 2]
>>> y_pred = [0, 0, 2, 2, 1]
>>> target_names
Faces recognition example using eigenfaces and kernel approximation
Column Transformer with Heterogeneous Data Sources
Custom refit strategy of a grid search with cross-validation
Restricted Boltzmann Machine features for digit classification
Label Propagation digits: Demonstrating performance
The reported averages include macro average (averaging the unweighted
mean per label), weighted average (averaging the support-weighted mean
per label), and sample average (only for multilabel classification).
Micro average (averaging the total true positives, false negatives and
false positives) is only shown for multi-label or multi-class
with a subset of classes, because it corresponds to accuracy
otherwise and would be the same for all metrics.
See also precision_recall_fscore_support for more details
on averages.
Note that in binary classification, recall of the positive class is also known as “sensitivity”; recall of the negative class is “specificity”.