研究挑战Research challenge
Weeks 11 and 12. In pairs, research one evaluation metric the book doesn't cover, build it from scratch, and teach it to the class in five minutes.
Chapter 16 grades one classifier against known labels. Real evaluation asks more than that:
- Has the data drifted since training?
- How good is a language model?
- What breaks when you replace one model with another?
- Does the ranking put the best items first?
- Does the model treat every group the same?
Each question has its own metric. In this challenge, you and a partner pick one metric, become the class expert on it, and teach it to everyone else.
How it runs
| When | What happens |
|---|---|
| Week 11 | Form a pair. Pick a metric from the menu. Each metric can only be taken once, so claim it early |
| Weeks 11 and 12 | Research it, build it, and write the metric card |
| Week 12 session | Five-minute talks, one per pair |
Plan on about six hours each, spread over the two weeks. Your capstone model report is also due in week 12, so start in week 11.
Studying alone? Do it on your own, with any metric. Give the talk to a friend, or record it for yourself. The card and the notebook are the core.
The menu
None of these are evaluation metrics in the book. KL divergence appears in Chapter 5 as an idea from information theory. Here it's used as a metric.
| Metric | The question it answers | Check your code against | Start with |
|---|---|---|---|
| KL divergence | How much information is lost when one distribution stands in for another? | scipy.stats.entropy(p, q) |
Kullback and Leibler (1951), and Chapter 5 |
| Jensen-Shannon divergence | How far apart are two distributions, measured both ways and bounded? | scipy.spatial.distance.jensenshannon |
Lin (1991) |
| Wasserstein distance | How much probability mass must move, and how far, to turn one distribution into the other? | scipy.stats.wasserstein_distance |
Peyré and Cuturi (2019), chapter 2 |
| Population stability index | Has a feature drifted since the model was trained? | A hand count on a tiny example | Yurdakul and Naranjo (2020) |
| Perplexity | How surprised is a language model by text it hasn't seen? | A uniform model over V words must score exactly V | Jurafsky and Martin, chapter 3 |
| Flip rate and negative flip rate | When a new model replaces an old one, how many predictions change, and how many right answers become wrong? | A hand count on an old-against-new table | Yan and others (2021) |
| Expected calibration error | Do predicted probabilities match observed rates? | sklearn.calibration.calibration_curve |
Guo and others (2017) |
| Matthews correlation coefficient | One number for an imbalanced confusion matrix that uses all four cells | sklearn.metrics.matthews_corrcoef |
Chicco and Jurman (2020) |
| Cohen's kappa | How much do two raters agree beyond what chance gives? | sklearn.metrics.cohen_kappa_score |
Cohen (1960) |
| NDCG | Does a ranking put the most relevant items near the top? | sklearn.metrics.ndcg_score |
Järvelin and Kekäläinen (2002) |
| Pinball loss | How good is a predicted quantile, such as the 90th percentile? | sklearn.metrics.mean_pinball_loss |
Koenker and Bassett (1978) |
| Interval coverage and the interval score | Do 90% prediction intervals hold 90% of outcomes, and how wide are they? | A hand count on a tiny example | Gneiting and Raftery (2007) |
| Demographic parity difference | Does the model flag every group at the same rate? | fairlearn.metrics.demographic_parity_difference |
Barocas, Hardt, and Narayanan, the classification chapter |
| Equalised odds difference | Does the model make the same kinds of error for every group? | fairlearn.metrics.equalized_odds_difference |
Hardt, Price, and Srebro (2016) |
You can propose a metric that isn't on the menu. Check it with your instructor first.
fairlearn isn't in the course requirements. Install it in a notebook with %pip install -q fairlearn.
What you hand in
A metric card. One page:
- the definition and the formula, with every symbol explained;
- the question it answers, in one sentence;
- its range, and what a good and a bad value look like;
- when to use it instead of a Chapter 16 metric.
A from-scratch implementation. NumPy only, no library call for the metric. Show it agrees with the check in the menu on at least three inputs, including an edge case.
A demo on real data. Any public dataset. The labs' datasets are a good place to start:
Metrics Suggested data KL, Jensen-Shannon, Wasserstein, PSI Bike Sharing (week 11): a column in 2011 against the same column in 2012 Perplexity 20 Newsgroups: sklearn.datasets.fetch_20newsgroups. Train a bigram model on one subset and score anotherFlip rate Two of your week 9 models on the same test set, or one model trained with two random seeds Calibration error, MCC, kappa Bank Marketing (week 12) NDCG Bank Marketing: rank clients by predicted score. A subscription is a relevant result Pinball loss, intervals Bike Sharing: GradientBoostingRegressor(loss="quantile")Fairness gaps Bank Marketing, grouped by age band or marital status A failure case. Build or find an input where the metric misleads: it looks good when the model is bad, or the other way round. Explain why.
A five-minute talk. Three or four slides. Teach the class what the metric is for, show the demo and the failure case, and end with when to use it.
Done when
The challenge is marked like a lab: done or not yet. It isn't graded.
| Check | Done | Not yet |
|---|---|---|
| The card | Every symbol is explained. Someone who missed the talk could use the metric | Formula only |
| The code | Agrees with the check on three inputs, including an edge case | No check, or the check fails |
| The demo | Runs top to bottom from the raw download. Each result has a sentence saying what it means | Numbers without interpretation |
| The failure case | A concrete input, and why the metric gets it wrong | "It can be misleading" with no example |
| The talk | Five minutes. The class can say when to use the metric | Over time, or a list of formulas |
Using it in your capstone
Some of these metrics fit a capstone. A fairness gap or a calibration error by group is part of an error analysis, which criterion 4 of the rubric asks for at exceeds. Use one only when it answers a question your decision-maker has.