A confusion matrix is a table or visualization for evaluating classification predictions by comparing each data point’s actual class with its predicted class. section 9.3.6
In node classification, it reveals which language classes a model confuses. This makes errors more specific than a single overall accuracy measure, especially when the dataset is unbalanced. section 9.3.6
Use the matrix to inspect:
- Which classes were predicted correctly or incorrectly. section 9.3.6
- Whether mistakes are concentrated between particular classes rather than spread across all classes. section 9.3.6
- How predictions relate to other evaluation measures such as the F1 score. section 9.3.6
Inspecting stream-language predictions
A random forest predicts stream languages from node2vec embeddings. The confusion matrix shows that errors occur between English and other languages, while Korean is never incorrectly classified as Portuguese. section 9.2 section 9.3.6
Listing 9.14 Calculating the tweet count and retweet ratio for each user
from sklearn.metrics import ConfusionMatrixDisplay ConfusionMatrixDisplay.from_predictions(y_test, y_pred, normalize="true", cmap="Greys")
Generate a normalized confusion-matrix visualization with scikit-learn using the test labels and predictions. section 9.3.6













