This page

Citing

Please consider citing the scikit-learn.

9.8.1.4. sklearn.metrics.precision_score

sklearn.metrics.precision_score(y_true, y_pred, pos_label=1)

Compute the precision

The precision is the ratio tp / (tp + fp) where tp is the number of true positives and fp the number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative.

The best value is 1 and the worst value is 0.

Parameters :

y_true : array, shape = [n_samples]

true targets

y_pred : array, shape = [n_samples]

predicted targets

pos_label : int

in the binary classification case, give the label of the positive class (default is 1). Everything else but ‘pos_label’ is considered to belong to the negative class. Not used in the case of multiclass classification.

Returns :

precision : float

precision of the positive class in binary classification or weighted avergage of the precision of each class for the multiclass task