Analyzing the confusion matrix
A confusion matrix is a table that summarizes the correct and incorrect predictions of a classification model. The confusion matrix is ideal for analyzing imbalanced data because it provides more information on which predictions are correct, and which predictions are wrong.
For the Exoplanet subset, here is the expected output for a perfect confusion matrix:
array([[88, 0], [ 0, 12]])
When all positive entries are on the left diagonal, the model has 100% accuracy. A perfect confusion matrix here predicts 88 non-exoplanet stars and 12 exoplanet stars. Notice that the confusion matrix does not provide labels, but in this case, labels may be inferred based on the size.
Before getting into further detail, let's see the actual confusion matrix using scikit-learn.
confusion_matrix
Import confusion_matrix
from sklearn.metrics
as follows:
from sklearn.metrics import confusion_matrix...