Sklearn.metrics evaluation method described in (accuracy_score, recall_score, roc_curve, roc_auc_score, confusion_matrix, classification_report)

accuracy_score
classification accuracy score is the percentage of correct classification means all. This measure classification accuracy of the classifier is easier to understand, but it can not tell you respond to potential distribution of values, and it can not tell you the type of classifier mistakes.

形式:
sklearn.metrics.accuracy_score(y_true, y_pred, normalize=True, sample_weight=None)

normalize: The default value is True, returns the proportion of correctly classified; the number of samples If False, returns the correct classification

————————————————

recall_score
information number of pieces of the correct number of pieces of information extracted recall = / sample. In layman's terms, it is that all entries have the exact number is retrieved out.

形式:
klearn.metrics.recall_score(y_true, y_pred, labels=None, pos_label=1,average='binary', sample_weight=None)

参数average : string, [None, ‘micro’, ‘macro’(default), ‘samples’, ‘weighted’]

When a binary classification matrics to expand or multi-label classification problem, we can be seen as a set of multiple data of binary classification, each class is a binary classification. Then, we can calculate metrics for each dichotomous mean score across multiple classification, which is useful in some cases. You can use the average arguments.

macro: calculate the mean of the binary metrics, given the same weight value for each class. When the subclass is important to go wrong, because the macro-averging method is the average of the performance. On the other hand, this method assumes that all categories are as important, and therefore greatly affect the performance of macro-averaging method will subclasses.

weighted: For uneven number of classes, computing an average of the binary metrics achieved by weighting on the score of each class.

micro: each sample is given and the contribution of its entire class of metrics pair (sample-weight), rather than the sum of the whole class of metrics, it will be right on the metrics for each class of weight factors and summed, to calculate the entire share. Micro-averaging method in a multi-tag (the multilabel) provided in question, comprising a plurality of classification, this time, categories will be ignored.

samples: Application in the multilabel problem. It is not calculated for each category, instead, it will evaluate the data by calculating the difference of the real class, and class prediction of metrics, for averaging (sample_weight-weighted)

average: average = None will return an array that contains scores for each
category. ----------------

roc_curve
the ROC receiver operating characteristic curve means / receiver operating characteristic (receiver operating characteristic, ROC) curve is a reflection of the sensitivity index and comprehensive effects of continuous variables, to reveal the relationship between sensitivity and specificity by patterning method , which sets a plurality of different threshold values by a continuous variable, to calculate a series of sensitivity and specificity. The ROC curve is a range of different binary manner (decision threshold or cut-off value), the rate of cases with real (i.e., sensitivity) (True Positive Rate, TPR) as the ordinate, the false positive rate in Example (1-effects of) ( false Positive Rate, FPR) curve plotted as abscissa.

ROC observation model correctly identify the proportion of positive cases and negative cases of Model mistakenly identifying data as a trade-off between the proportion of positive cases. TPR FPR increased to increase the expense. The area under the ROC curve is a measure of the accuracy of the model, AUC (Area under roccurve).

Ordinate: the real rate (True Positive Rate, TPR) or sensitivity (Sensitivity)

TPR = TP / (TP + FN) (Number of positive samples predictor / positive actual number of samples)

Abscissa: false positive rate (False Positive Rate, FPR)

FPR = FP / (FP + TN) (predicted number of samples is a positive result of negative / negative actual number of samples)

形式:
sklearn.metrics.roc_curve(y_true,y_score, pos_label=None, sample_weight=None, drop_intermediate=True)

The function returns three variables: fpr, tpr, and threshold Thresholds;

Here understand thresholds:

An important feature classifier "probability output", it means that the classifier think a probability sample has much belongs to the positive samples (or the negative samples).

"Score" indicates that each test sample belongs probability of positive samples.

Next, we high to low, turn the "Score" value as a threshold value threshold, when the probability of a test sample belongs positive samples is greater than or equal to this threshold, we think it is a positive sample, otherwise negative samples. Every time selecting a different threshold, we can get a set of FPR and TPR, i.e. point on the ROC curve. When we set the threshold to 1 and 0, respectively, can be obtained (0,0) and (1,1) two points on the ROC curve. These (FPR, TPR) connected together, the ROC curve is obtained. The more threshold value, the smoother the ROC curve. In fact, we do not have to get a sample of each test sample is positive probability values, as long as the classifier get the "scores" of test samples can be (not necessarily in scores (0,1)). The higher the score, the more classifiers represent positive that this test sample is positive samples, but at the same value as the use of each rating threshold. I think the scores into easier to understand some of probability.
----------------

Auc calculated AUC values, where x, y are in the form of an array, according to (xi, yi) on the coordinates of the point, the generated curve, and AUC values were calculated;

form:

sklearn.metrics.auc(x, y, reorder=False)

————————————————

roc_auc_score
directly from the true value (value must be two), the predicted value (which may be 0/1, or may be proba value) calculated value auc, ROC intermediate calculation process is omitted.

形式:
sklearn.metrics.roc_auc_score(y_true, y_score, average='macro', sample_weight=None)

average : string, [None, ‘micro’, ‘macro’(default), ‘samples’, ‘weighted’]
————————————————

confusion_matrix

形式:
sklearn.metrics.confusion_matrix(y_true, y_pred, labels=None, sample_weight=None)

Returns a confusion matrix;

labels: confusion matrix index (e.g., cats and dogs rabbit above example), if no assignment, in accordance with the y_true, y_pred median sort appeared.
----------------
sklearn in classification_report function for displaying text reporting major categories of indicators. The accuracy of the display information of each class, recall, and other values in the Fl report. 
The main parameters: 
y_true:. 1-dimensional array, or an array of labels indicator / sparse matrix, the target value. 
y_pred: 1-dimensional array, or an array of labels indicator / sparse matrix estimated value returned by the classifier. 
labels: array, shape = [n_labels ], selectable list tab index included in the report. 
target_names: list of strings, matching optional display tag name (same sequence). 
sample_weight: similar shape = [n_samples] array of options, sample weights. 
digits: int, float value of output digits.

Guess you like

Origin www.cnblogs.com/liunaiming/p/12079307.html