ML Metrics Calculator
Accuracy, precision, recall, F1, specificity and MCC from a confusion matrix.
How it works
Enter the four counts of a confusion matrix (true positives, false positives, false negatives, true negatives) and get accuracy, precision, recall, specificity, F1 and the Matthews correlation coefficient.
The formula
precision = TP / (TP + FP) recall = TP / (TP + FN) F1 = 2 x precision x recall / (precision + recall) MCC = (TP x TN - FP x FN) / root((TP+FP)(TP+FN)(TN+FP)(TN+FN))
Worked example
TP 85, FP 10, FN 15, TN 90: accuracy 87.5%, precision 89.47%, recall 85%, F1 0.8718, MCC 0.7509.
Good to know
- Accuracy misleads when classes are very uneven. A model that always says no is 99 percent accurate on a 1 percent disease.
- Use recall when missing a positive is costly, precision when a false alarm is costly.
- MCC stays honest on imbalanced data.
Common questions
- Which metric should I report?
- Report several, and say which error matters more for your problem.
- What is specificity?
- TN / (TN + FP), the recall of the negative class.
- What is F1?
- The harmonic mean of precision and recall, so it is low if either is low.
More in CS Labs & Coding.
Watch 10 sorting algorithms animate step by step with live counters and pseudocode, or race them on the same input.
CS Labs & CodingTOP PICKGraph Algorithm VisualizerTOP PICKDraw your own graph and watch BFS, DFS, Dijkstra, Bellman-Ford, Prim, Kruskal, topological sort and more run step by step, with the queue, the distance table and the reason for every move.
Big-O Estimator from TimingsTime your code on a few input sizes, paste the numbers, and see which growth rate fits best.
OPEN →