RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
Glossary / Evaluation metrics / Confusion Matrix
Evaluation metrics

Confusion Matrix

A confusion matrix is a table that summarizes the performance of a classification model by comparing predicted labels against actual labels. Rows represent true classes, columns represent predicted classes (or vice versa). Diagonal cells show correct predictions; off-diagonal cells show errors. For binary classification, the matrix yields true positives, true negatives, false positives, and false negatives. Operators use it to compute metrics like precision, recall, and F1-score. It matters because accuracy alone can mislead on imbalanced datasets—e.g., a model that always predicts 'not spam' gets 99% accuracy on 99% non-spam data but fails entirely on spam.

Practical example

Suppose you fine-tune a DistilBERT model on a sentiment dataset (positive/negative) using Hugging Face Transformers. After evaluation on 1000 test samples, the confusion matrix shows: 400 true positives, 350 true negatives, 100 false positives, 150 false negatives. From this, precision = 400/(400+100) = 0.8, recall = 400/(400+150) ≈ 0.727, F1 ≈ 0.762. If you only looked at accuracy (750/1000 = 75%), you'd miss that recall for positive class is low.

Workflow example

In a classification workflow with scikit-learn, after training a model you run from sklearn.metrics import confusion_matrix; cm = confusion_matrix(y_true, y_pred). In Hugging Face Trainer, the compute_metrics function often returns a confusion matrix via evaluate.load('accuracy') or custom code. In LM Studio, you'd export predictions and compute the matrix externally. The matrix helps decide threshold tuning—e.g., lowering the decision threshold increases recall but may raise false positives.

Reviewed by Fredoline Eruo. See our editorial policy.

Buyer guides
  • Best GPU for local AI →
  • Best laptop for local AI →
  • Best Mac for local AI →
When it doesn't work
  • CUDA out of memory →
  • Ollama running slowly →
  • ROCm not detected →