#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🎯 FREE · 9 METRICS

Confusion Matrix Calculator: Precision, Recall and F1 in One Place

Turn four counts from your classifier into every metric interviewers ask about.

  • ✅ Precision, recall, F1
  • ⚖️ MCC and balanced accuracy
  • 📋 Matrix layout shown

How to use the Confusion Matrix Calculator

  1. 1. Enter the four countsType true positives, false positives, false negatives and true negatives.
  2. 2. CalculatePress the button to get every metric with its formula.
  3. 3. Pick the right metricUse the notes to choose the metric that fits your problem.

Formulas and a worked example

  • Precision = TP ÷ (TP + FP): of everything flagged positive, how much was right.
  • Recall = TP ÷ (TP + FN): of all real positives, how many were caught.
  • F1 = 2 × precision × recall ÷ (precision + recall), the harmonic mean of the two.
  • MCC = (TP·TN − FP·FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN)).

Example: a spam filter on 100 emails gets TP = 50, FP = 10, FN = 5 and TN = 35. Accuracy is 85%. Precision is 50 ÷ 60 = 0.8333 and recall is 50 ÷ 55 = 0.9091, so F1 = 0.8696. Specificity is 35 ÷ 45 = 0.7778 and MCC is 0.6975.

Which metric should you report?

Accuracy is fine when classes are balanced and both mistakes cost the same. Real problems rarely look like that. In fraud or disease detection, positives are rare, so a model that always says "no" can score 99% accuracy and still be useless.

  • Recall first when missing a positive is costly: cancer screening, fraud, safety defects.
  • Precision first when false alarms are costly: spam filters that might hide real mail, or legal flags.
  • F1 when you need one number that balances both.
  • MCC uses all four cells and stays honest on imbalanced data; many data scientists prefer it.

These match scikit-learn's classification_report for the positive class. To see how the numbers move as you change the decision threshold, try the ROC curve and AUC calculator.

Frequently asked questions

What does undefined mean for a metric?

The formula would divide by zero. For example, precision is undefined if the model never predicts positive.

Is the positive class always the rare one?

By convention you pick the class you care about catching as positive, which is often the rare one.

Is the Confusion Matrix Calculator free?

Yes, the Confusion Matrix Calculator is free. The first time you see your first result, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools