sklearn.metrics
: Metrics
官网是最好的学习区。
See the Model evaluation: quantifying the quality of predictions section and the Pairwise metrics, Affinities and Kernelssection of the user guide for further details.
sklearn.metrics 模块包括评分函数、性能指标、成对指标和距离计算
Model Selection Interface 模型可选接口
See the The scoring parameter: defining model evaluation rules section of the user guide for further details.
metrics.get_scorer (scoring) | Get a scorer from string |
metrics.make_scorer (score_func[, …]) | Make a scorer from a performance metric or loss function. |
Classification metrics 分类问题的指标
See the Classification metrics section of the user guide for further details.
metrics.accuracy_score (y_true, y_pred[, …]) | 分类准确性得分 |
metrics.auc (x, y[, reorder]) | 计算AUC |
metrics.average_precision_score (y_true, y_score) | Compute average precision (AP) from prediction scores |
metrics.brier_score_loss (y_true, y_prob[, …]) | Compute the Brier score. |
metrics.classification_report (y_true, y_pred) | Build a text report showing the main classification metrics |
metrics.cohen_kappa_score (y1, y2[, labels, …]) | Cohen’s kappa: a statistic that measures inter-annotator agreement. |
metrics.confusion_matrix (y_true, y_pred[, …]) | Compute confusion matrix to evaluate the accuracy of a classification |
metrics.f1_score (y_true, y_pred[, labels, …]) | Compute the F1 score, also known as balanced F-score or F-measure |
metrics.fbeta_score (y_true, y_pred, beta[, …]) | Compute the F-beta score |
metrics.hamming_loss (y_true, y_pred[, …]) | Compute the average Hamming loss. |
metrics.hinge_loss (y_true, pred_decision[, …]) | Average hinge loss (non-regularized) |
metrics.jaccard_similarity_score (y_true, y_pred) | Jaccard similarity coefficient score |
metrics.log_loss (y_true, y_pred[, eps, …]) | Log loss, aka logistic loss or cross-entropy loss. |
metrics.matthews_corrcoef (y_true, y_pred[, …]) | Compute the Matthews correlation coefficient (MCC) |
metrics.precision_recall_curve (y_true, …) | Compute precision-recall pairs for different probability thresholds |
metrics.precision_recall_fscore_support (…) | Compute precision, recall, F-measure and support for each class |
metrics.precision_score (y_true, y_pred[, …]) | Compute the precision |
metrics.recall_score (y_true, y_pred[, …]) | Compute the recall |
metrics.roc_auc_score (y_true, y_score[, …]) | Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores. |
metrics.roc_curve (y_true, y_score[, …]) | Compute Receiver operating characteristic (ROC) |
metrics.zero_one_loss (y_true, y_pred[, …]) | Zero-one classification loss. |
Regression metrics 回归问题的指标
See the Regression metrics section of the user guide for further details.
metrics.explained_variance_score (y_true, y_pred) | Explained variance regression score function |
metrics.mean_absolute_error (y_true, y_pred) | Mean absolute error regression loss |
metrics.mean_squared_error (y_true, y_pred[, …]) | Mean squared error regression loss |
metrics.mean_squared_log_error (y_true, y_pred) | Mean squared logarithmic error regression loss |
metrics.median_absolute_error (y_true, y_pred) | Median absolute error regression loss |
metrics.r2_score (y_true, y_pred[, …]) | R^2 (coefficient of determination) regression score function. |
Multilabel ranking metrics 多标签排序指标
See the Multilabel ranking metrics section of the user guide for further details.
metrics.coverage_error (y_true, y_score[, …]) | Coverage error measure |
metrics.label_ranking_average_precision_score (…) | Compute ranking-based average precision |
metrics.label_ranking_loss (y_true, y_score) | Compute Ranking loss measure |
Clustering metrics 聚类指标
See the Clustering performance evaluation section of the user guide for further details.
The sklearn.metrics.cluster
submodule contains evaluation metrics for cluster analysis results. There are two forms of evaluation:
supervised, which uses a ground truth class values for each sample.
unsupervised, which does not and measures the ‘quality’ of the model itself.
metrics.adjusted_mutual_info_score (…) | Adjusted Mutual Information between two clusterings. |
metrics.adjusted_rand_score (labels_true, …) | Rand index adjusted for chance. |
metrics.calinski_harabaz_score (X, labels) | Compute the Calinski and Harabaz score. |
metrics.completeness_score (labels_true, …) | Completeness metric of a cluster labeling given a ground truth. |
metrics.fowlkes_mallows_score (labels_true, …) | Measure the similarity of two clusterings of a set of points. |
metrics.homogeneity_completeness_v_measure (…) | Compute the homogeneity and completeness and V-Measure scores at once. |
metrics.homogeneity_score (labels_true, …) | Homogeneity metric of a cluster labeling given a ground truth. |
metrics.mutual_info_score (labels_true, …) | Mutual Information between two clusterings. |
metrics.normalized_mutual_info_score (…) | Normalized Mutual Information between two clusterings. |
metrics.silhouette_score (X, labels[, …]) | Compute the mean Silhouette Coefficient of all samples. |
metrics.silhouette_samples (X, labels[, metric]) | Compute the Silhouette Coefficient for each sample. |
metrics.v_measure_score (labels_true, labels_pred) | V-measure cluster labeling given a ground truth. |
Biclustering metrics
See the Biclustering evaluation section of the user guide for further details.
metrics.consensus_score (a, b[, similarity]) | The similarity of two sets of biclusters. |
Pairwise metrics
See the Pairwise metrics, Affinities and Kernels section of the user guide for further details.
metrics.pairwise.additive_chi2_kernel (X[, Y]) | Computes the additive chi-squared kernel between observations in X and Y |
metrics.pairwise.chi2_kernel (X[, Y, gamma]) | Computes the exponential chi-squared kernel X and Y. |
metrics.pairwise.cosine_similarity (X[, Y, …]) | Compute cosine similarity between samples in X and Y. |
metrics.pairwise.cosine_distances (X[, Y]) | Compute cosine distance between samples in X and Y. |
metrics.pairwise.distance_metrics () | Valid metrics for pairwise_distances. |
metrics.pairwise.euclidean_distances (X[, Y, …]) | Considering the rows of X (and Y=X) as vectors, compute the distance matrix between each pair of vectors. |
metrics.pairwise.kernel_metrics () | Valid metrics for pairwise_kernels |
metrics.pairwise.laplacian_kernel (X[, Y, gamma]) | Compute the laplacian kernel between X and Y. |
metrics.pairwise.linear_kernel (X[, Y]) | Compute the linear kernel between X and Y. |
metrics.pairwise.manhattan_distances (X[, Y, …]) | Compute the L1 distances between the vectors in X and Y. |
metrics.pairwise.pairwise_distances (X[, Y, …]) | Compute the distance matrix from a vector array X and optional Y. |
metrics.pairwise.pairwise_kernels (X[, Y, …]) | Compute the kernel between arrays X and optional array Y. |
metrics.pairwise.polynomial_kernel (X[, Y, …]) | Compute the polynomial kernel between X and Y: |
metrics.pairwise.rbf_kernel (X[, Y, gamma]) | Compute the rbf (gaussian) kernel between X and Y: |
metrics.pairwise.sigmoid_kernel (X[, Y, …]) | Compute the sigmoid kernel between X and Y: |
metrics.pairwise.paired_euclidean_distances (X, Y) | Computes the paired euclidean distances between X and Y |
metrics.pairwise.paired_manhattan_distances (X, Y) | Compute the L1 distances between the vectors in X and Y. |
metrics.pairwise.paired_cosine_distances (X, Y) | Computes the paired cosine distances between X and Y |
metrics.pairwise.paired_distances (X, Y[, metric]) | Computes the paired distances between X and Y. |
metrics.pairwise_distances (X[, Y, metric, …]) | Compute the distance matrix from a vector array X and optional Y. |
metrics.pairwise_distances_argmin (X, Y[, …]) | Compute minimum distances between one point and a set of points. |
metrics.pairwise_distances_argmin_min (X, Y) | Compute minimum distances between one point and a set of points. |