Confusion matrix
A confusion matrix is a table that counts classification outcomes by comparing predicted classes with actual classes.
Starting Data Analytics with Generative AI and Python
A confusion matrix is a table comparing actual classes with predicted classes to summarize classification outcomes.
- How it is used
- Evaluates review-score predictions and keyword-based positive-review extraction by comparing classifications with reference labels.
- How deep it goes
- Demonstrates multiclass output and binary outcome counts, then calculates sensitivity and specificity for review extraction.
- Examples
- Uses five-point product reviews to assess regression predictions and compare positive keywords with a score threshold.
- What you can do after
- Apply it via Python to inspect classification errors and calculate sensitivity and specificity for a review-extraction workflow.
Read how Starting Data Analytics with Generative AI and Python explains confusion matrix →
Grokking Machine Learning
A tabular representation of classification outcomes divided into true-positive, true-negative, false-positive, and false-negative counts.
- How it is used
- Evaluates classification models by making their correct predictions and error types visible.
- How deep it goes
- Defines binary matrix layout and error counts, then extends the layout to multiclass classification.
- Examples
- Uses medical diagnosis, spam detection, and animal-image classes to illustrate classification outcomes.
- What you can do after
- Evaluate classification models by counting correct predictions and distinguishing false positives from false negatives.
Read how Grokking Machine Learning explains confusion matrix →
Statistics Slam Dunk
A confusion matrix is a table that cross-classifies predicted and observed classes to count correct and incorrect classifications.
- How it is used
- Evaluates binary classification performance after logistic-regression predictions are converted into class labels.
- How deep it goes
- Explains four outcome types, requires binary inputs, and derives sensitivity, specificity, error, and accuracy.
- Examples
- Uses NBA playoff predictions, a 0.50 probability cutoff, R's table() function, and an 80-observation classification result.
- What you can do after
- Diagnose model performance with R by constructing a confusion matrix and calculating key classification measures.
Statistics Every Programmer Needs
A confusion matrix is a table that summarizes classification results by cross-tabulating actual classes against predicted classes.
- How it is used
- Evaluates classification models by exposing class-specific successes and errors beyond a single accuracy score.
- How deep it goes
- Defines binary cells, demonstrates pandas and scikit-learn construction, and derives sensitivity, specificity, accuracy, and error rates.
- Examples
- Uses Turkish raisin classification and fourth-down conversion prediction, with pandas, scikit-learn, and explicit cell counts.
- What you can do after
- Diagnose classification behavior by calculating error types and comparing performance across classes.
Read how Statistics Every Programmer Needs explains confusion matrix →
Knowledge Graphs and LLMs in Action
A confusion matrix is a tabular summary of predicted and actual class assignments, including counts of correct and incorrect classifications.
- How it is used
- Uses class-level error counts to evaluate GNN node classification and link prediction beyond aggregate metrics.
- How deep it goes
- Explains correct and incorrect class assignments through concrete counts and model comparisons, without deriving matrix metrics mathematically.
- Examples
- Compares GCN, GAT, and SAGE on licit–illicit nodes and predicted user–movie rating links.
- What you can do after
- Diagnose model behavior by locating class-specific misclassifications and weighing missed positives against false alarms.
Read how Knowledge Graphs and LLMs in Action explains confusion matrix →
Natural Language Processing in Action, Second Edition
A confusion matrix is a table counting predictions by their actual and predicted classes.
- How it is used
- Diagnoses classification performance by exposing correct predictions, false positives, and false negatives.
- How deep it goes
- Explains error categories, visual interpretation, and recall through a worked binary-classification result.
- Examples
- Uses toxic-comment predictions, a numeric matrix, and a scikit-learn Matplotlib display.
- What you can do after
- Diagnose model mistakes with scikit-learn counts and visual displays, then interpret recall for the toxic class.
Read how Natural Language Processing in Action, Second Edition explains confusion matrix →
Grokking Statistics
A confusion matrix is a table that cross-tabulates predicted classes against actual classes and counts correct and incorrect classifications.
- How it is used
- Evaluates classification performance by separating correct predictions, false alarms, and missed positive cases.
- How deep it goes
- Defines four matrix cells and interprets imbalance, then connects them to precision and recall without covering other negative-focused measures.
- Examples
- Uses a wolf-detection alarm tested over 100 days and a later evaluation involving more wolves across 500 days.
- What you can do after
- Evaluate classification results by identifying correct predictions, false alarms, missed cases, and accuracy failures caused by imbalance.
Grokking Machine Learning, Second Edition
A tabular arrangement of classification outcomes that distinguishes true positives, true negatives, false positives, and false negatives.
- How it is used
- Evaluates classification models by separating correct predictions from false positives and false negatives.
- How deep it goes
- Defines binary and multiclass layouts and connects cells to evaluation metrics, but stops short of implementation details.
- Examples
- Uses medical diagnosis, spam filtering, recommendations, pedestrian detection, and a multiclass animal classifier.
- What you can do after
- Evaluate classification models by identifying error types and reading metric-relevant counts from the matrix.
Read how Grokking Machine Learning, Second Edition explains confusion matrix →
Build AI Drug Discovery Pipelines
A confusion matrix is a tabulation of predicted versus actual class counts, including true positives, true negatives, false positives, and false negatives.
- How it is used
- Evaluates classifier behavior by exposing correct predictions and the types of mistakes made during ligand screening.
- How deep it goes
- Defines four binary outcomes, shows matrix interpretation, and connects counts to precision and recall; multiclass layout is noted.
- Examples
- Uses a scikit-learn matrix containing 119 true negatives, 1 false negative, 13 false positives, and 259 true positives.
- What you can do after
- Evaluate classifiers with error counts and interpret precision and recall rather than relying on accuracy alone.
Read how Build AI Drug Discovery Pipelines explains confusion matrix →
Machine Learning Algorithms in Depth
A confusion matrix is a table counting predictions by combinations of predicted and actual classes.
- How it is used
- Evaluates binary classifiers by organizing correct and incorrect predictions against ground-truth labels.
- How deep it goes
- Defines four outcome counts and connects threshold changes to ROC and precision-recall curves, without deriving matrix internals.
- Examples
- Uses perceptron predictions on the iris dataset and a scikit-learn confusion-matrix utility.
- What you can do after
- Evaluate classifier predictions by identifying TP, TN, FP, and FN and relating them to threshold-based metrics.
Read how Machine Learning Algorithms in Depth explains confusion matrix →
Graph Algorithms for Data Science
A confusion matrix is a table counting classification outcomes by actual class and predicted class.
- How it is used
- Evaluates node-classification predictions by comparing actual and predicted language classes.
- How deep it goes
- Defines the comparison and visualizes normalized results, stopping short of explaining the matrix’s underlying computation.
- Examples
- Uses stream-language predictions, an unbalanced test set, and English-versus-other-language errors.
- What you can do after
- Diagnose/debug with it, identify which language classes a classifier confuses and whether errors concentrate between particular classes.
Read how Graph Algorithms for Data Science explains confusion matrix →
Data-Driven Cybersecurity
A confusion matrix is a table that cross-classifies predicted classes against actual classes to show correct and incorrect classification outcomes.
- How it is used
- Evaluates classification performance by showing correct predictions and the types of errors across classes.
- How deep it goes
- Defines row and column orientation and interprets diagonal and off-diagonal cells, including the risk of missed threats.
- Examples
- Uses high- and low-risk cybersecurity articles and normal-versus-threat network traffic as classification examples.
- What you can do after
- Evaluate classifier errors by identifying correct predictions, false alarms, and missed threats.
Read how Data-Driven Cybersecurity explains confusion matrix →
Effective Conversational AI
A confusion matrix is a tabular summary comparing a classifier's predicted categories with the authoritative categories for evaluation examples.
- How it is used
- Diagnoses problematic intent-classification patterns so recall, precision, and F1 improvements can target specific errors.
- How deep it goes
- Defines four outcomes and works through recall, precision, and F1 calculations using an intent-level evaluation example.
- Examples
- Uses Request_Agent utterances such as “Speak with an agent,” “What can I ask you,” and “Somebody hit my car.”
- What you can do after
- Diagnose over-selection and under-selection by interpreting prediction outcomes and calculating intent-level evaluation metrics.
Read how Effective Conversational AI explains confusion matrix →
Deep Learning with PyTorch, Second Edition
A 2D breakdown of classification outcomes into true/false positives/negatives used to analyze model predictions.
- How it is used
- Measures classification quality when accuracy obscures failures on an imbalanced dataset.
- How deep it goes
- Defines four outcome quadrants through labels and thresholds, then stops short of detailed metric formulas.
- Examples
- Uses lung-nodule classification and a guard-dog scenario involving burglars, harmless animals, and barking thresholds.
- What you can do after
- Evaluate classification errors by separating correct predictions from false alarms and missed positive cases.
Read how Deep Learning with PyTorch, Second Edition explains confusion matrix →
First-Party Data Activation
A confusion matrix is a table that organizes the counts or shares of correct and incorrect outcomes for a classification system.
- How it is used
- Frames identity-resolution sampling results and supports decisions about matching thresholds and strategies.
- How deep it goes
- Explains all four outcomes and their business, analytical, customer, and regulatory consequences.
- Examples
- Uses identity-resolution sampling tests and a shared-household IP attribution scenario.
- What you can do after
- Evaluate identity-resolution risks and choose thresholds that balance false positives against false negatives.
Read how First-Party Data Activation explains confusion matrix →
Financial AI in Practice
A table that summarizes classification results by comparing predicted classes with actual classes.
- How it is used
- Evaluates fraud-classification predictions against actual labels on an unseen, imbalanced test set.
- How deep it goes
- Defines four outcome categories and presents the matrix as one output in a broader quantitative test-set evaluation.
- Examples
- Uses fraud detection results, including 127 of 148 frauds identified and 456 legitimate transactions flagged incorrectly.
- What you can do after
- Evaluate fraud detection by distinguishing correctly identified transactions from false alarms and missed fraud.
Read how Financial AI in Practice explains confusion matrix →
Also covered in
- Fight Fraud with Machine LearningIn early access (MEAP)
- Cyber Threat Hunting
- Graph Neural Networks in Action
- Grokking AI Algorithms, Second Edition
- Transformers in Action
- Human-in-the-Loop Machine Learning: Active learning and annotation for human-centered AI
What to know first
- accuracyAccuracy is the degree to which a result agrees with a specified truth, reference, or criterion, commonly measured as the proportion of evaluated predictions that are correct.
- false negativeA false negative is a result in which a condition that is actually present is incorrectly reported or classified as absent.
- false positiveA false positive is a positive result that incorrectly indicates a target condition is present when it is absent.
- recallRecall is the proportion of all relevant or actual positive items that a system successfully retrieves or correctly identifies.
Related concepts
- false positivehas part · A false positive is a positive result that incorrectly indicates a target condition is present when it is absent.
- classifiermeasures · A classifier is a predictive model that assigns an input to one or more discrete classes or categories.
- true positivehas part · A true positive is a positive prediction or identification that correctly corresponds to an actual positive case.
- false negativehas part · A false negative is a result in which a condition that is actually present is incorrectly reported or classified as absent.
- true negativehas part · A true negative is a classification outcome in which an instance that actually belongs to the negative class is correctly predicted as negative.
- language modelmeasures · A language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
Questions about confusion matrix
What is confusion matrix?
A confusion matrix is a table that counts classification outcomes by comparing predicted classes with actual classes.
Which Manning books explain confusion matrix?
Starting Data Analytics with Generative AI and Python, Grokking Machine Learning, Statistics Slam Dunk, Statistics Every Programmer Needs, Knowledge Graphs and LLMs in Action, Natural Language Processing in Action, Second Edition, Grokking Statistics, Grokking Machine Learning, Second Edition and 8 more.
What should I know before learning confusion matrix?
Manning books that teach confusion matrix usually introduce accuracy, false negative, false positive and recall first.
What are the parts of confusion matrix?
Confusion matrix includes false positive, true positive, false negative and true negative.
What is confusion matrix also called?
Confusion matrix is also called confusion matrices.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.















