Model evaluation workbench
Evaluate a classifier or regressor from its predictions — paste or upload a CSV, or generate a seeded synthetic model — with confusion matrices (micro, macro and weighted precision, recall and F1, MCC, κ), ROC and precision–recall curves (trapezoid AUC against average precision), lift and gain, a cost-matrix threshold chooser, calibration (reliability diagram, ECE, Brier, Platt and isotonic), class imbalance, per-group fairness, and regression residuals.
Added
How to use it
Everything here starts from a table of predictions: what really happened and what the model said. Eight tabs look at it from different sides. The numbers match scikit-learn’s (the tests check them against scikit-learn 1.9.1), so you can use this to sanity-check a notebook. Every setting can be put in a link, and each example has a preset — see Linking to an example.
⛶ Full screen (or the F key) gives the whole tool the window, with larger charts; F or Esc leaves. Tabs keep working inside it.
Data
Synthetic builds a seeded model you can steer:
-
Binary classifier — the binormal model: on a hidden scale negatives are N(0, 1) and positives N(d′, 1), and each score is the exact probability of being positive, so at temperature 1 the model is perfectly calibrated and its ROC AUC is Φ(d′/√2) (shown beside the slider). Prevalence sets how common positives are. Temperature below 1 pushes scores towards 0 and 1 (over-confident, as modern neural networks tend to be), above 1 towards the middle. Round scores creates tied scores.
-
Binary, two groups — the same, with a group column; group B’s positives are less separated and its scores pushed down by the group B penalty, while the model treats both groups alike.
-
Multi-class — 3 to 6 classes (cat, dog, fox …) with softmax probabilities; dog and fox share part of their signal, so they get confused with each other.
-
Regression — y = 5 + 1.5x + noise, optionally with curvature the linear model misses and a constant bias.
Your predictions (CSV): paste, upload or drop a file. Layouts (a header row is optional; commas, tabs or semicolons):
-
binary:
label,score[,group]— labels 0/1, true/false, yes/no or any two names; the score may be a probability or any number where higher means more positive; -
multi-class:
label,p_cat,p_dog,…— one probability column per class, named in the header — orlabel,predicted_labelfor hard predictions (confusion matrix only); -
regression:
actual,predicted.
Your CSV stays in this browser (it is remembered for next time) and is never put in a share link. Download as CSV saves the current data in the same format, so a synthetic set can be opened in Python.
Confusion
The 2 × 2 table at the chosen threshold (positive when score ≥ t, scikit-learn’s rule) — or, for a multi-class model, the K × K table of argmax predictions — as counts or normalised by true class (each row becomes recall), by prediction (each column becomes precision) or overall. Below: accuracy, balanced accuracy, precision, recall, specificity, FPR, NPV, F1, Matthews correlation, Cohen’s κ and Youden’s J; for multi-class, per-class precision, recall, F1, support and one-vs-rest AUC with micro (pools all decisions: equals accuracy), macro (plain mean: rare classes count fully) and weighted (by support) averages, and the log loss. Multi-class data also gets a positive class picker: the curve, threshold, imbalance and calibration views then treat that class against the rest.
ROC & PR
The ROC curve with its AUC and the current operating point; the precision–recall curve twice: as
average precision (the step function Σ ΔRecall × Precision that average_precision_score
computes) and as the trapezoid under straight lines between the points (auc(recall,
precision)). They differ because precision does not change linearly between two operating
points: the achievable curve between them bends below the straight line (Davis & Goadrich, 2006),
so the trapezoid is usually optimistic, most visibly with few points or many tied scores (the
ties example: AP 0.727, trapezoid 0.748). Report AP. The PR baseline is the prevalence, not 0.5.
Below, the cumulative gain chart (share of positives found against share of people contacted,
with random and perfect lines), lift (gain ÷ share contacted) and a decile table.
Threshold
Type a cost matrix (the cost of each outcome per case, negative for a benefit) and, optionally, a deployment prevalence — the rate of positives the model will meet in use, applied as weights. The tool shows both score distributions with the threshold on top (drag on the chart), the expected cost per case at every threshold with the minimum marked, TPR, FPR, precision and F1 against threshold, the thresholds that maximise Youden’s J and F1, and Bayes' rule for calibrated probabilities: flag when p > (CFP − CTN) / CFP − CTN) + (CFN − CTP, shifted by the prior odds ratio when the prevalence changes (Elkan, 2001). A big gap between the data’s optimum and Bayes' threshold is a sign the scores are not calibrated.
Calibration
The reliability diagram (fraction positive against mean score in each bin, equal-width or equal-count bins) with the number of cases per bin; the expected and maximum calibration error, the Brier score with Murphy’s decomposition (reliability − resolution + uncertainty) and the log loss. Two recalibrations are fitted on alternate rows and scored on the others: Platt scaling (a logistic fit σ(a·x + b) by Newton’s method, on the raw score as Platt (1999) did or on its logit — a < 1 shrinks over-confident scores) and isotonic regression (the best non-decreasing step function, by pool-adjacent-violators; Zadrozny & Elkan, 2002). Both keep the ranking, so the AUC barely moves. Multi-class models are checked on their top label: confidence is the largest probability, correct means it was the right class (Guo et al., 2017).
Imbalance
Multiply the positives and the negatives (as exact weights — the expected result of over- or undersampling, without the noise) and compare the original and resampled numbers side by side. TPR, FPR, the ROC curve and its AUC do not move; precision, F1, accuracy, the PR curve and average precision all do. Buttons undersample or oversample to 50/50.
Fairness
Needs a group column. Per group: size, base rate, threshold, selection rate, TPR, FPR, PPV, accuracy and AUC, and the gaps that fairness definitions compare — equal opportunity (TPR; Hardt, Price & Srebro, 2016), equalised odds (TPR and FPR), predictive parity (PPV), demographic parity (selection rate) and the disparate-impact ratio with the four-fifths rule. Per-group thresholds picks each group’s threshold so all reach the overall TPR, and shows what that costs elsewhere. When base rates differ these criteria cannot all hold at once (Chouldechova, 2017; Kleinberg, Mullainathan & Raghavan, 2016).
Regression
MAE, MSE, RMSE, R², explained variance, MAPE (with a warning when actual values are zero), median and maximum absolute error and the mean residual; predicted against actual with the y = x line, residuals against predictions with a binned mean (curves, funnels and offsets show up here), and the residual histogram.
Limits
-
Up to about 50,000 rows stay responsive; synthetic data is capped at 50,000.
-
Multi-class threshold, imbalance and fairness views are one-vs-rest for the chosen class; there is no multi-label mode, and probabilities in a multi-class CSV are used as given (rows are not required to sum to 1, but log loss normalises them).
-
ECE depends on the bins; the Brier decomposition is exact only when scores are constant within a bin, so the three terms are shown with their sum.
-
Platt scaling here fits hard 0/1 targets (like
LogisticRegressionwith no penalty), not Platt’s smoothed targets thatCalibratedClassifierCVuses, so small sets give slightly more extreme parameters. Recalibration uses a fixed even/odd split, not cross-validation. -
Confidence intervals are not shown; with small data, re-run with New sample to see how much the numbers move.
Related: Test accuracy and risk (the binormal ROC and predictive values against prevalence, for medical tests), Statistics, Probability, The maths of machine learning (logistic regression and cross-entropy), Neural network designer, Embedding explorer and Classic ML, step by step.
Sources: scikit-learn’s metrics and calibration documentation (model evaluation, probability calibration); T. Fawcett, “An introduction to ROC analysis”, Pattern Recognition Letters 27 (2006); J. Davis and M. Goadrich, “The relationship between precision-recall and ROC curves”, ICML 2006; C. Elkan, “The foundations of cost-sensitive learning”, IJCAI 2001; J. Platt, “Probabilistic outputs for support vector machines”, 1999; B. Zadrozny and C. Elkan, KDD 2002; C. Guo et al., “On calibration of modern neural networks”, ICML 2017; M. Hardt, E. Price and N. Srebro, “Equality of opportunity in supervised learning”, NeurIPS 2016; A. Chouldechova, “Fair prediction with disparate impact”, Big Data 5 (2017).
Linking to an example
A link opens the tool with the given settings: /tools/model-eval/?<parameters>#<tab>, where the
tab is data, confusion, curves, threshold, calibration, imbalance, fairness or
regression. Share link (top right) builds one from whatever is on screen. Links carry the
synthetic-data settings and the evaluation settings, never pasted CSV data.
| Parameter | Meaning | Example |
|---|---|---|
|
a preset (list below); other parameters in the same link override it |
|
|
generator: |
|
|
rows |
|
|
separation d′ between classes |
|
|
prevalence of positives (binary) |
|
|
temperature (< 1 over-confident, > 1 under-confident) |
|
|
random seed |
|
|
number of classes (multi) |
|
|
round scores to this many decimals (0 = off) |
|
|
group B penalty (groups) |
|
|
regression noise σ, model bias, missed curvature |
|
|
|
|
|
CSV layout: |
|
|
threshold |
|
|
positive class index for one-vs-rest views (multi) |
|
|
confusion matrix: |
|
|
cost of a true positive, false positive, false negative, true negative |
|
|
deployment prevalence (0 = as in the data) |
|
|
calibration bins |
|
|
bins: |
|
|
Platt scaling on |
|
|
weights (resampling factors) for positives and negatives |
|
|
per-group thresholds for equal TPR ( |
|
Presets for example=:
| Name | Tab | Shows |
|---|---|---|
|
curves |
Separation 2, 30% positive: ROC AUC 0.91, AP 0.81 |
|
curves |
Separation 0.5: ROC AUC 0.61, close to the diagonal |
|
curves |
40 cases with scores rounded to one decimal: AP 0.727 against a trapezoid of 0.748 |
|
threshold |
2% fraud, a miss costs 50 and a false alarm 1: the cheapest threshold is about 0.025 (Bayes: 1/51 ≈ 0.020) |
|
threshold |
A model built on balanced data used where 5% are positive, misses cost 10: the threshold moves from 0.09 to about 0.67 |
|
confusion |
The 2 × 2 table at 0.5, normalised by true class |
|
confusion |
Four classes, accuracy 75%; dog and fox are confused with each other |
|
calibration |
Temperature 0.5: held-out ECE 0.083 falls to 0.023 with Platt (a ≈ 0.52) and 0.029 with isotonic |
|
calibration |
Temperature 2: ECE 0.111; Platt finds a ≈ 2.1 |
|
calibration |
Top-label calibration of an over-confident four-class model |
|
imbalance |
10% positive; undersampling negatives to 1 in 9 leaves the ROC AUC at 0.924 and lifts AP from 0.67 to 0.92 |
|
fairness |
Two groups at one threshold: TPR 72% in A against 27% in B |
|
fairness |
The same with per-group thresholds that equalise TPR |
|
regression |
A linear model on linear data: R² 0.82, residuals are noise |
|
regression |
A straight line through a curve with a bias of 1: the residuals curve, R² 0.65 |
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.