sklearn.metrics.balanced_accuracy_score(y_true, y_pred, sample_weight=None, adjusted=False)
[source]
Compute the balanced accuracy
The balanced accuracy in binary and multiclass classification problems to deal with imbalanced datasets. It is defined as the average of recall obtained on each class.
The best value is 1 and the worst value is 0 when adjusted=False
.
Read more in the User Guide.
Parameters: |
|
---|---|
Returns: |
|
See also
Some literature promotes alternative definitions of balanced accuracy. Our definition is equivalent to accuracy_score
with class-balanced sample weights, and shares desirable properties with the binary case. See the User Guide.
[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. |
[2] | John. D. Kelleher, Brian Mac Namee, Aoife D’Arcy, (2015). Fundamentals of Machine Learning for Predictive Data Analytics: Algorithms, Worked Examples, and Case Studies. |
>>> 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
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.metrics.balanced_accuracy_score.html