sklearn.metrics
.balanced_accuracy_score¶
-
sklearn.metrics.
balanced_accuracy_score
(y_true, y_pred, sample_weight=None)[source]¶ Compute the balanced accuracy
The balanced accuracy is used in binary classification problems to deal with imbalanced datasets. It is defined as the arithmetic mean of sensitivity (true positive rate) and specificity (true negative rate), or the average recall obtained on either class. It is also equal to the ROC AUC score given binary inputs.
The best value is 1 and the worst value is 0.
Read more in the User Guide.
Parameters: - y_true : 1d array-like
Ground truth (correct) target values.
- y_pred : 1d array-like
Estimated targets as returned by a classifier.
- sample_weight : array-like of shape = [n_samples], optional
Sample weights.
Returns: - balanced_accuracy : float.
The average of sensitivity and specificity
See also
References
[1] Brodersen, K.H.; Ong, C.S.; Stephan, K.E.; Buhmann, J.M. (2010). The balanced accuracy and its posterior distribution. Proceedings of the 20th International Conference on Pattern Recognition, 3121-24. Examples
>>> from sklearn.metrics import balanced_accuracy_score >>> y_true = [0, 1, 0, 0, 1, 0] >>> y_pred = [0, 1, 0, 0, 0, 1] >>> balanced_accuracy_score(y_true, y_pred) 0.625