April 2019
Intermediate to advanced
426 pages
11h 13m
English
In Chapter 10, Machine Learning for Finance, we discussed the confusion matrix, accuracy score, precision score, recall score, and F1 score in measuring classification-based predictions. We can reuse those metrics on our model as well.
Since the model output is in the normalized decimal format between 0 and 1, we round it up to the nearest 0 or 1 integer to obtain the predicted binary classification labels:
In [ ]: predictions = model.predict(test_scaled_x) pred_values = predictions.round().ravel()
The ravel() command presents the result as a single list stored in the pred_values variable.
Compute and display the confusion matrix:
In [ ]: from sklearn.metrics import confusion_matrix matrix = confusion_matrix(test_y, ...
Read now
Unlock full access