Works on this device
Model Evaluation Calculator
Measure how well a model does on examples where you know the right answer. Paste counts, a confusion matrix, two lists of labels or two lists of numbers. Everything is worked out in your browser.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose the kind of data you have: the four counts of a two-class test, a confusion matrix, two lists of labels, or two lists of numbers.
- For a language model that sorts texts into classes, paste the correct labels in one box and the model’s answers in the other, in the same order. The page builds the confusion matrix for you.
- Choose Calculate. Download the results as a CSV file if you want to keep them.
Two classes
- Accuracy = (TP + TN) ÷ all examples.
- Precision = TP ÷ (TP + FP): of the examples called positive, the share that really are.
- Recall (sensitivity) = TP ÷ (TP + FN): of the real positives, the share that were found. Specificity = TN ÷ (TN + FP).
- F1 = 2·TP ÷ (2·TP + FP + FN), the harmonic mean of precision and recall. Fβ = (1 + β²)·TP ÷ ((1 + β²)·TP + β²·FN + FP); F2 weighs recall more, F0.5 weighs precision more.
- MCC (Matthews correlation coefficient) = (TP·TN − FP·FN) ÷ √((TP + FP)(TP + FN)(TN + FP)(TN + FN)). It runs from −1 to 1 and stays fair when one class is much larger than the other.
- Balanced accuracy = (recall + specificity) ÷ 2.
- A value whose formula would divide by 0 is shown as not defined, with the reason. Optional Wilson score intervals show how sure each share is.
Several classes
- Each class is taken in turn as the positive class, which gives its own precision, recall and F1.
- Macro average: the plain mean over the classes. A value that is not defined counts as 0, as scikit-learn does by default.
- Weighted average: the mean weighted by the number of actual examples in each class.
- Micro average: when every example has one label, micro precision, recall and F1 all equal the accuracy.
- Balanced accuracy: the mean recall of the classes that have actual examples. MCC uses the formula of Gorodkin (2004) for several classes.
Regression
- Error = predicted − actual. MAE is the mean absolute error, MSE the mean squared error and RMSE its square root.
- MAPE = mean of |error ÷ actual| × 100%. Pairs whose actual value is 0 are left out of MAPE, and the page says how many.
- R² = 1 − Σ error² ÷ Σ (actual − mean)². It is below 0 when the predictions are worse than the mean of the actual values.
Worked example
A spam filter is tested on 1,000 emails: TP = 80, FP = 20, FN = 10 and TN = 890. Accuracy is 970 ÷ 1,000 = 0.97, precision 80 ÷ 100 = 0.8, recall 80 ÷ 90 = 0.888889 and F1 = 160 ÷ 190 = 0.842105. MCC is (80 × 890 − 20 × 10) ÷ √(100 × 90 × 910 × 900) = 71,000 ÷ 85,854.5 = 0.82698.
For the actual values 3, −0.5, 2, 7 and the predictions 2.5, 0, 2, 8, MAE is 0.5, MSE is 0.375 and R² is 0.948608.
Limits you should know
- The page measures predictions you already have. It does not run a model, call a service or judge whether an answer is true.
- Metrics from a small test set can change a lot with a few more examples. Use the intervals, and test on more examples when you can.
- ROC curves and AUC need scores, not labels; they are not worked out here.
- For agreement between two people who label the same items (Cohen’s kappa and others), use the Reliability & Agreement Calculator. For cosine similarity of vectors, use the Cosine Similarity Calculator.