8.19.1.1. sklearn.metrics.accuracy_score

sklearn.metrics.accuracy_score(y_true, y_pred)

Accuracy classification score

Parameters:

y_true : array-like, shape = n_samples

Ground truth (correct) labels.

y_pred : array-like, shape = n_samples

Predicted labels, as returned by a classifier.

Returns:

score : float

The fraction of correct predictions in y_pred. The best performance is 1.

See also

zero_one_loss

Examples

>>> from sklearn.metrics import accuracy_score
>>> y_pred = [0, 2, 1, 3]
>>> y_true = [0, 1, 2, 3]
>>> accuracy_score(y_true, y_pred)
0.5
Previous
Next