sklearn.metrics#
Score functions, performance metrics, pairwise metrics and distance computations.
User guide. See the Metrics and scoring: quantifying the quality of predictions and Pairwise metrics, Affinities and Kernels sections for further details.
Model selection interface#
User guide. See the The scoring parameter: defining model evaluation rules section for further details.
Determine scorer from user options. |
|
Get a scorer from string. |
|
Get the names of all available scorers. |
|
Make a scorer from a performance metric or loss function. |
Classification metrics#
User guide. See the Classification metrics section for further details.
Accuracy classification score. |
|
Compute Area Under the Curve (AUC) using the trapezoidal rule. |
|
Compute average precision (AP) from prediction scores. |
|
Compute the balanced accuracy. |
|
Compute the Brier score loss. |
|
Compute binary classification positive and negative likelihood ratios. |
|
Build a text report showing the main classification metrics. |
|
Compute Cohen's kappa: a statistic that measures inter-annotator agreement. |
|
Compute confusion matrix to evaluate the accuracy of a classification. |
|
\(D^2\) score function, fraction of log loss explained. |
|
Compute Discounted Cumulative Gain. |
|
Compute error rates for different probability thresholds. |
|
Compute the f1 score, also known as balanced f-score or f-measure. |
|
Compute the f-beta score. |
|
Compute the average Hamming loss. |
|
Average hinge loss (non-regularized). |
|
Jaccard similarity coefficient score. |
|
Log loss, aka logistic loss or cross-entropy loss. |
|
Compute the Matthews correlation coefficient (MCC). |
|
Compute a confusion matrix for each class or sample. |
|
Compute Normalized Discounted Cumulative Gain. |
|
Compute precision-recall pairs for different probability thresholds. |
|
Compute precision, recall, f-measure and support for each class. |
|
Compute the precision. |
|
Compute the recall. |
|
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores. |
|
Compute Receiver operating characteristic (ROC). |
|
Top-k Accuracy classification score. |
|
Zero-one classification loss. |
Regression metrics#
User guide. See the Regression metrics section for further details.
\(D^2\) regression score function, fraction of absolute error explained. |
|
\(D^2\) regression score function, fraction of pinball loss explained. |
|
\(D^2\) regression score function, fraction of Tweedie deviance explained. |
|
Explained variance regression score function. |
|
The max_error metric calculates the maximum residual error. |
|
Mean absolute error regression loss. |
|
Mean absolute percentage error (MAPE) regression loss. |
|
Mean Gamma deviance regression loss. |
|
Pinball loss for quantile regression. |
|
Mean Poisson deviance regression loss. |
|
Mean squared error regression loss. |
|
Mean squared logarithmic error regression loss. |
|
Mean Tweedie deviance regression loss. |
|
Median absolute error regression loss. |
|
\(R^2\) (coefficient of determination) regression score function. |
|
Root mean squared error regression loss. |
|
Root mean squared logarithmic error regression loss. |
Multilabel ranking metrics#
User guide. See the Multilabel ranking metrics section for further details.
Coverage error measure. |
|
Compute ranking-based average precision. |
|
Compute Ranking loss measure. |
Clustering metrics#
Evaluation metrics for cluster analysis results.
Supervised evaluation uses a ground truth class values for each sample.
Unsupervised evaluation does use ground truths and measures the “quality” of the model itself.
User guide. See the Clustering performance evaluation section for further details.
Adjusted Mutual Information between two clusterings. |
|
Rand index adjusted for chance. |
|
Compute the Calinski and Harabasz score. |
|
Build a contingency matrix describing the relationship between labels. |
|
Pair confusion matrix arising from two clusterings. |
|
Compute completeness metric of a cluster labeling given a ground truth. |
|
Compute the Davies-Bouldin score. |
|
Measure the similarity of two clusterings of a set of points. |
|
Compute the homogeneity and completeness and V-Measure scores at once. |
|
Homogeneity metric of a cluster labeling given a ground truth. |
|
Mutual Information between two clusterings. |
|
Normalized Mutual Information between two clusterings. |
|
Rand index. |
|
Compute the Silhouette Coefficient for each sample. |
|
Compute the mean Silhouette Coefficient of all samples. |
|
V-measure cluster labeling given a ground truth. |
Biclustering metrics#
User guide. See the Biclustering evaluation section for further details.
The similarity of two sets of biclusters. |
Distance metrics#
Uniform interface for fast distance metric functions. |
Pairwise metrics#
Metrics for pairwise distances and affinity of sets of samples.
User guide. See the Pairwise metrics, Affinities and Kernels section for further details.
Compute the additive chi-squared kernel between observations in X and Y. |
|
Compute the exponential chi-squared kernel between X and Y. |
|
Compute cosine distance between samples in X and Y. |
|
Compute cosine similarity between samples in X and Y. |
|
Valid metrics for pairwise_distances. |
|
Compute the distance matrix between each pair from a vector array X and Y. |
|
Compute the Haversine distance between samples in X and Y. |
|
Valid metrics for pairwise_kernels. |
|
Compute the laplacian kernel between X and Y. |
|
Compute the linear kernel between X and Y. |
|
Compute the L1 distances between the vectors in X and Y. |
|
Calculate the euclidean distances in the presence of missing values. |
|
Compute the paired cosine distances between X and Y. |
|
Compute the paired distances between X and Y. |
|
Compute the paired euclidean distances between X and Y. |
|
Compute the paired L1 distances between X and Y. |
|
Compute the kernel between arrays X and optional array Y. |
|
Compute the polynomial kernel between X and Y. |
|
Compute the rbf (gaussian) kernel between X and Y. |
|
Compute the sigmoid kernel between X and Y. |
|
Compute the distance matrix from a vector array X and optional Y. |
|
Compute minimum distances between one point and a set of points. |
|
Compute minimum distances between one point and a set of points. |
|
Generate a distance matrix chunk by chunk with optional reduction. |
Plotting#
User guide. See the Visualizations section for further details.
Confusion Matrix visualization. |
|
DET curve visualization. |
|
Precision Recall visualization. |
|
Visualization of the prediction error of a regression model. |
|
ROC Curve visualization. |