AI Dictionary › Fondamenti AI

Confusion matrix

Matrice di confusione

A confusion matrix is a table that summarizes a classification model's performance by comparing its predictions with the true labels, showing exactly where the model got things right and where it got them wrong. It is the basic diagnostic tool for understanding not just how much a model errs, but in which direction it errs.

Definition

What it is

A confusion matrix is a table that summarizes a classification model's performance by comparing its predictions with the true labels, showing exactly where the model got things right and where it got them wrong. It is the basic diagnostic tool for understanding not just how much a model errs, but in which direction it errs.

How it works

In the simplest case, binary classification, the matrix has four cells: true positives, positive cases correctly identified as such, true negatives, negative cases correctly identified, false positives, negative cases mistaken for positive, and false negatives, positive cases mistaken for negative. Almost all commonly used evaluation metrics, such as precision, recall and accuracy, are computed from these four numbers. With more than two classes, the matrix expands into a larger grid, with one row and one column per category.

Applications

It is especially revealing when the two types of error carry very different consequences: in a medical diagnostic system, a false negative, missing a disease that is present, can be far more serious than a false positive, which only triggers an additional check. The confusion matrix makes this imbalance immediately visible, something a single aggregate metric like accuracy risks hiding, especially with imbalanced classes.

History & etymology

The term confusion literally describes the cells off the main diagonal of the table, where the model confuses one class for another. The concept has roots in statistics applied to diagnostics and psychological testing in the first half of the twentieth century, and it was adopted systematically in machine learning and pattern recognition literature starting in the 1960s and 70s as a standard tool for evaluating classifiers.

Definizione (italiano)

La matrice di confusione è una tabella che riassume le prestazioni di un modello di classificazione confrontando le previsioni fatte con le etichette reali, mostrando esattamente dove il modello ha avuto ragione e dove si è sbagliato. È lo strumento diagnostico di base per capire non solo quanto un modello sbaglia, ma in quale direzione sbaglia.

Nel caso più semplice, la classificazione a due classi, la matrice ha quattro celle: i veri positivi, casi positivi correttamente identificati come tali, i veri negativi, casi negativi correttamente identificati, i falsi positivi, casi negativi scambiati per positivi, e i falsi negativi, casi positivi scambiati per negativi. Da questi quattro numeri si calcolano quasi tutte le metriche di valutazione più usate, come precisione, richiamo e accuratezza. Con più di due classi la matrice si estende a una griglia più grande, con una riga e una colonna per ciascuna categoria.

È particolarmente rivelatrice quando i due tipi di errore hanno conseguenze molto diverse: in un sistema diagnostico medico, un falso negativo, non individuare una malattia presente, può essere molto più grave di un falso positivo, che genera solo un controllo aggiuntivo. La matrice di confusione permette di vedere questo squilibrio in modo immediato, cosa che una singola metrica aggregata come l'accuratezza rischia di nascondere, specialmente con classi sbilanciate.

Il termine confusion, confusione in inglese, descrive letteralmente le celle fuori dalla diagonale principale della tabella, dove il modello confonde una classe con un'altra. Il concetto affonda le radici nella statistica applicata alla diagnostica e ai test psicologici della prima metà del Novecento, e viene adottato sistematicamente nella letteratura di machine learning e pattern recognition a partire dagli anni '60 e '70 come strumento standard per valutare i classificatori.

Related terms

More in Fondamenti AI

Put it into practice

From our network

INDACO TMS — Transport Management for European Logistics

Shipment tracking, multi-carrier EDI and automated invoicing in one cloud platform. Invoices generated in under 10 seconds.

Visit indacotms.com →

From the Agora Intelligence blog

More on agora-intelligence.com →

📱 Download the Android app (beta) iOS coming soon

Say what you mean. Get what you need.

Grace Certified — the AI coach that trains and certifies your prompt engineering — by Agora Intelligence.