AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

Classification Metrics Foundations

Count the cases behind each score.

Your dataset

Twelve fixed actual labels in each preset. Edit predictions, not the truth. Positive is the class of interest; true or false says whether a prediction is correct. Scenario changes restore all predictions Negative.

TP 0 · FP 0 · FN 2 · TN 10 · Actual positives 2 · Predicted positives 0 · Total 12

Rows are actual labels; columns are predictions. Positive class first; every case appears in exactly one cell.
Actual / PredictedPredicted positivePredicted negative
Actual positiveTrue positive (TP)0False negative (FN)2
Actual negativeFalse positive (FP)0True negative (TN)10

Case 1: Actual positive · Predicted negative · False negative (FN)

Choosing a case changes only selection, preserving counts and explanations. Editing predictions or selecting a scenario clears completion. No probabilities, threshold or model fitting are involved.

Accuracy

Correct positive and negative labels among all twelve cases.

83.3%

(TP + TN)/12 = 10/12

Precision

Correct positives among predicted positives.

—

TP/(TP + FP) = 0/0

Undefined: no predicted positives, so 0/0.

Recall

Found positives among actual positives.

0.0%

TP/(TP + FN) = 0/2

F1

Harmonic balance of precision and recall where defined; ignores true negatives.

0.0%

2TP/(2TP + FP + FN) = 0/2

Ratios are shown as one-decimal percentages. — means undefined, not zero. With actual positives but no positive predictions, precision is undefined while count-form F1 is zero because its FN denominator is nonzero.

All twelve cases
Actual labels stay fixed within a preset. Selection preserves every prediction; each row contributes to one confusion cell.
CaseActualPredictedConfusion cell
Case 1PositiveNegativeFalse negative (FN)
Case 2PositiveNegativeFalse negative (FN)
Case 3NegativeNegativeTrue negative (TN)
Case 4NegativeNegativeTrue negative (TN)
Case 5NegativeNegativeTrue negative (TN)
Case 6NegativeNegativeTrue negative (TN)
Case 7NegativeNegativeTrue negative (TN)
Case 8NegativeNegativeTrue negative (TN)
Case 9NegativeNegativeTrue negative (TN)
Case 10NegativeNegativeTrue negative (TN)
Case 11NegativeNegativeTrue negative (TN)
Case 12NegativeNegativeTrue negative (TN)
Metric definitions and limits

Precision uses the predicted-positive set TP+FP; recall uses the actual-positive set TP+FN. Accuracy includes TN and all cases. F1=2TP/(2TP+FP+FN); where precision P and recall R permit, it is 2PR/(P+R), a harmonic rather than arithmetic balance. F1 does not include TN and does not encode every task’s error costs. High recall can coexist with many false positives.

Zero denominators remain undefined here. No predicted positives makes precision 0/0; no actual positives makes recall 0/0. F1 is0 when TP 0 and FP+FN is positive, but undefined when all cases are TN. Library zero_division choices may replace undefined values with 0,1 or a missing value; this page displays the raw undefined ratio explicitly. These are unweighted binary positive-class metrics, with no multiclass averaging.

Case IDs are fixed synthetic examples: Rare positives has actual-positive Cases 1/2, Balanced has 1..6, No positives has none. Scenarios change the labelled toy dataset and reset its predictions, not a real population. Editing predictions does not demonstrate training, a causal intervention, calibrated probabilities or expected future accuracy. Choosing the right metric requires task priorities, representative data and acceptable error costs beyond these counts.

scikit-learn · Confusion matrix axes
scikit-learn · Precision
scikit-learn · Recall
scikit-learn · F1 and zero division