Classification metrics

A classification task can be evaluated in many different ways to achieve specific objectives. Of course, the most important metric is the accuracy, often expressed as:

In scikit-learn, it can be assessed using the built-in accuracy_score() function:

from sklearn.metrics import accuracy_score>>> accuracy_score(Y_test, lr.predict(X_test))0.94399999999999995

Another very common approach is based on zero-one loss function, which we saw in Chapter 2, Important Elements in Machine Learning, which is defined as the normalized average of L0/1 (where 1 is assigned to misclassifications) over all samples. In the following example, ...

Get Machine Learning Algorithms now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.