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 follows:
For this example, we are going to use a binary test dataset obtained as follows:
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
X, Y = make_classification(n_samples=nb_samples, n_features=2, n_informative=2, n_redundant=0,
n_clusters_per_class=1, random_state=1000)
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.25, random_state=1000)
In scikit-learn, the accuracy can be assessed using the built-in accuracy_score() function:
from sklearn.metrics import accuracy_score
print(accuracy_score(Y_test, lr.predict(X_test)))
0.968
Another very common approach is based on the zero-one loss function, which we saw in Chapter...