ML Evaluation Metrics, Text Representation, and Experiment Rigor
Easy · Machine Learning · Machine Learning Engineer · Online Assessment
Prompt
Walk through an end-to-end applied machine-learning evaluation framework for a text-centric product (such as classifying incoming technical articles and ranking search results), without assuming any proprietary internal tooling. Before diving into formulas, clarify the product goal, dominant operational constraints (data volume, serving latency, reliability, or privacy), integration boundaries, and success criteria.
Structure your walkthrough across six foundational areas, illustrating each with concrete numerical examples, edge-case behavior, and practical validation checks:
- Human label reliability: How you verify whether human annotators agree beyond random chance, why raw agreement breaks down under skewed class distributions, and how your choice of agreement statistic changes with three or more raters or ordinal relevance grades.
- Classification metrics: How confusion-matrix counts translate into precision, recall, F1, and accuracy; how you tune decision thresholds for asymmetric business costs; when to prefer PR-AUC over ROC-AUC; micro vs. macro multi-class averaging; and how to check probability calibration.
- Search & ranking metrics: How Precision@k, MRR, MAP, and NDCG@k differ in sensitivity to rank position and graded relevance, and which conventions must be fixed before comparing two rankers.
- NLP & language-model fundamentals: Trade-offs in subword tokenization and text normalization, sparse lexical weighting (TF-IDF) versus dense semantic embeddings, and how perplexity measures language-model quality (including when two perplexity numbers cannot be compared).
- Reproducibility & leakage prevention: What artifacts, random seeds, and split strategies (entity-grouped and chronological) are needed so another engineer can reproduce offline scores without hidden train-test contamination.
- Statistical significance & experiment reporting: How to quantify finite-sample uncertainty, compare baseline and challenger models on the same held-out items using paired statistical tests or bootstrap intervals, and summarize findings clearly for launch decisions.
Scope & Expectations
- Ground abstract metrics in explicit assumptions: Define a concrete binary classification task and a graded search-ranking task up front so every formula and trade-off connects to real user and operational costs.
- Demonstrate mastery via small worked traces and code checks: Back up definitions with hand-verifiable mini-tables (such as
2 x 2rater/confusion tables and a 5-item ranked list) and concise Python snippets that validate your arithmetic. - Call out silent failure modes: Highlight where naive defaults mislead teams — such as high accuracy or raw agreement on rare classes, tokenizer mismatches in perplexity, random row splits on related documents, and division-by-zero edge cases.
- Close the loop from offline scores to decisions: Explain how multi-seed variance, paired confidence intervals, slice breakdowns, and human-agreement ceilings work together to prevent shipping noise.
Step-by-step walkthrough
Frame the assessment and pick one concrete running scenario
An applied machine-learning assessment tests whether you can turn a vague question like "is our model good enough to ship?" into concrete numbers you can defend. Rather than memorizing isolated formulas, think of evaluation as six checkpoints along one pipeline:
[1. Human Labels] ---> [4. Text Features] ---> [2. Classifier / 3. Ranker] Can we trust Tokens, TF-IDF, Precision, Recall, F1, ground truth? embeddings, PPL MRR, MAP, NDCG@k | | +---------------> [5. Reproducibility] <-----------+ Seeds, frozen group splits, versions | v [6. Experiment Reporting] Confidence intervals & paired testsBecause the scenario leaves the exact application open, state clean, realistic assumptions up front without inventing proprietary systems:
- Task A (binary classification): Predict whether a technical article or incident report is relevant to a target topic
T, evaluated on1,000held-out documents where120(12%) are truly relevant. - Task B (search ranking): Order candidate documents for a user query, evaluated on human relevance grades from
0(irrelevant) to3(exact match). - Operational goal: Every metric below is paired with a tiny hand-checkable example, runnable Python validation code, and the edge case most likely to mislead a team.
- Task A (binary classification): Predict whether a technical article or incident report is relevant to a target topic
Check label quality first with Cohen's kappa
Before scoring a model against human labels, verify that two humans given the same instructions actually agree. Raw percent agreement (the fraction of items where two annotators give the same label) is misleading because two people guessing mostly "not relevant" will agree almost every time by pure luck.
Cohen's kappa measures agreement beyond random chance. It compares observed agreement
p_oagainst the agreementp_eexpected if both annotators guessed independently using their own yes/no rates:kappa = (p_o - p_e) / (1 - p_e) p_o = observed fraction of items where A and B agree p_e = P(A says yes) * P(B says yes) + P(A says no) * P(B says no)Suppose two annotators label
100documents:B: relevant B: not relevant Row total A: relevant 40 10 50 (A yes = 0.50) A: not relevant 5 45 50 (A no = 0.50) Column total 45 55 100 (B yes = 0.45) (B no = 0.55) p_o = (40 + 45) / 100 = 0.85 p_e = (0.50 * 0.45) + (0.50 * 0.55) = 0.225 + 0.275 = 0.50 kappa = (0.85 - 0.50) / (1 - 0.50) = 0.35 / 0.50 = 0.700A kappa of
0.700indicates substantial agreement (0means no better than chance;1means perfect agreement). Now watch the prevalence paradox when positives are rare (3%):both yes = 1, A yes / B no = 2, A no / B yes = 2, both no = 95 p_o = (1 + 95) / 100 = 0.9600 p_e = (0.03 * 0.03) + (0.97 * 0.97) = 0.0009 + 0.9409 = 0.9418 kappa = (0.9600 - 0.9418) / (1 - 0.9418) = 0.0182 / 0.0582 = 0.3127Raw agreement looks great (
96%), yet kappa drops to0.313because the annotators disagreed on4of the5documents that either person thought might be relevant. Always report kappa alongside the2 x 2table, send disagreements to an adjudicator to tighten guidelines, and treat human agreement as an approximate ceiling on model performance. For3+raters labeling every item, use Fleiss' kappa (a multi-rater generalization of chance-corrected agreement); for missing ratings or ordered0-3relevance scales, use Krippendorff's alpha (a distance-weighted disagreement metric that handles incomplete and ordinal labels).def cohens_kappa(both_yes: int, a_yes_b_no: int, a_no_b_yes: int, both_no: int) -> float: total = both_yes + a_yes_b_no + a_no_b_yes + both_no p_observed = (both_yes + both_no) / total a_yes_rate = (both_yes + a_yes_b_no) / total b_yes_rate = (both_yes + a_no_b_yes) / total p_expected = a_yes_rate * b_yes_rate + (1 - a_yes_rate) * (1 - b_yes_rate) # If every item falls in a single class for both raters, p_expected == 1.0. if p_expected == 1.0: return 1.0 return (p_observed - p_expected) / (1 - p_expected) print(round(cohens_kappa(40, 10, 5, 45), 4)) # 0.7 print(round(cohens_kappa(1, 2, 2, 95), 4)) # 0.3127Measure binary classification from the four confusion counts
Once a classifier outputs a probability score and we pick a decision threshold (say
>= 0.50), every prediction falls into one of four cells in a confusion matrix (a2 x 2table comparing true vs predicted labels). On our1,000test documents (120truly relevant,880not relevant):Predicted relevant Predicted not relevant Truly relevant TP = 80 FN = 40 (120 actual positives) Truly not relevant FP = 20 TN = 860 (880 actual negatives) (100 predicted pos) (900 predicted neg) Precision = TP / (TP + FP) = 80 / 100 = 0.800 (of docs flagged relevant, fraction truly relevant) Recall = TP / (TP + FN) = 80 / 120 = 0.667 (of truly relevant docs, fraction we found) F1 score = 2 * P * R / (P + R) = 0.727 (harmonic mean of precision and recall) Accuracy = (TP + TN) / N = 940 / 1000 = 0.940 (overall fraction correct)Why use the harmonic mean (
2 * P * R / (P + R)) for F1 instead of a plain average(P + R) / 2? A plain average gives0.50to a useless model that flags every document (R = 1.0,P ≈ 0), whereas the harmonic mean stays near the smaller number unless both precision and recall are high. Likewise, watch the accuracy paradox: predicting "not relevant" for every single document scores880 / 1000 = 0.880accuracy while finding zero relevant documents (recall = 0).Four follow-up distinctions interviewers expect:
- Threshold tuning: Lowering the threshold raises recall and lowers precision. Pick the operating point from business costs (missing a critical incident report vs wasting
30seconds of reviewer time), or maximize recall subject to a floor such asprecision >= 0.90. - ROC-AUC vs PR-AUC: ROC-AUC (area under the true-positive-rate vs false-positive-rate curve) equals the probability that a random positive receives a higher score than a random negative. When negatives outnumber positives
50:1,200false alarms barely move the false-positive rate, so ROC-AUC can look high (0.95) while precision is poor. PR-AUC (area under the precision-recall curve, whose random baseline equals the positive prevalence0.12) exposes false-positive inflation on rare classes. - Multi-class averaging: Micro-F1 sums
TP,FP, andFNacross all classes first (large classes dominate); Macro-F1 computes F1 per class and averages them equally (protecting rare classes). Always state which one you report. - Calibration: Ranking order does not guarantee honest probabilities. If downstream code treats
score = 0.80as an80%chance of relevance, check a reliability diagram (binning predicted probabilities against empirical positive rates) or the Brier score (mean squared error(y - p_hat)^2between binary outcomes and predicted probabilities).
tp, fp, fn, tn = 80, 20, 40, 860 precision = tp / (tp + fp) recall = tp / (tp + fn) f1_score = 2 * precision * recall / (precision + recall) print(round(precision, 3), round(recall, 3), round(f1_score, 3)) # 0.8 0.667 0.727- Threshold tuning: Lowering the threshold raises recall and lowers precision. Pick the operating point from business costs (missing a critical incident report vs wasting
Evaluate search order with Precision@k, MRR, MAP, and NDCG@k
Search and recommendation models return an ordered list, where putting a great document at rank
1is worth much more than burying it at rank10. Trace one query whose top5returned documents have human relevance grades[0, 3, 1, 0, 2]:- Precision@k (
P@k): Fraction of the topkresults that are relevant (grade > 0). HereP@3looks at[0, 3, 1]and scores2 / 3 = 0.667. It ignores order within the topk. - Mean Reciprocal Rank (
MRR): For one query, reciprocal rank is1 / (rank of first relevant hit)(0if none). Here the first hit is at rank2, giving1 / 2 = 0.500. Averaging across three queries with first hits at rank2, rank1, andnonegivesMRR = (0.5 + 1.0 + 0.0) / 3 = 0.500. Best when the user only needs one right answer. - Mean Average Precision (
MAP): For binary relevance, Average Precision (AP) averagesP@iat every rankiwhere a relevant document lands, divided by the total number of relevant documentsRfor that query. Relevant hits sit at ranks2,3, and5(P@2 = 1/2,P@3 = 2/3,P@5 = 3/5). IfR = 3,AP = (1/2 + 2/3 + 3/5) / 3 = 1.767 / 3 = 0.589; if a4threlevant document was missed outside the top5(R = 4),APdrops to1.767 / 4 = 0.442. MAP averagesAPacross queries. - Normalized Discounted Cumulative Gain (
NDCG@k): Rewards multi-level grades (2^rel - 1) while discounting lower ranks bylog2(rank + 1), then divides by the best possible ordering (IDCG@k) so every query sits on[0, 1]:
Rank i 1 2 3 4 5 Grade rel_i 0 3 1 0 2 Gain 2^rel - 1 0 7 1 0 3 1 / log2(i+1) 1.000 0.631 0.500 0.431 0.387 Contribution 0.000 4.417 0.500 0.000 1.161 -> DCG@5 = 6.077 Ideal order [3, 2, 1, 0, 0] Ideal contrib 7.000 1.893 0.500 0.000 0.000 -> IDCG@5 = 9.393 NDCG@5 = DCG@5 / IDCG@5 = 6.077 / 9.393 = 0.647Always document two conventions before comparing models: whether gain is exponential (
2^rel - 1) or linear (rel), and what happens when a query has zero relevant documents (IDCG = 0, division by zero) — either exclude empty queries and report the count, or defineNDCG = 0, consistently across all models.import math def dcg_at_k(grades: list[int], k: int) -> float: total = 0.0 for rank, grade in enumerate(grades[:k], start=1): gain = (2 ** grade) - 1 discount = math.log2(rank + 1) total += gain / discount return total def ndcg_at_k(grades: list[int], k: int) -> float | None: ideal_dcg = dcg_at_k(sorted(grades, reverse=True), k) if ideal_dcg == 0.0: return None # No relevant items exist; handle explicitly across models. return dcg_at_k(grades, k) / ideal_dcg print(round(ndcg_at_k([0, 3, 1, 0, 2], 5), 3)) # 0.647- Precision@k (
Turn text into numbers: tokenization, TF-IDF, embeddings, and perplexity
- Tokenization and normalization: Splitting on whitespace leaves unseen words as out-of-vocabulary unknowns. Subword tokenizers such as Byte-Pair Encoding (
BPE) (an algorithm that iteratively merges the most frequent character or byte pairs into subword units) split rare words like"reconfiguration"into known pieces, eliminating unknown-word failures. Be careful with aggressive text normalization: lowercasing merges"US"(country) with"us"(pronoun). Stemming chops suffixes heuristically ("studies" -> "studi"), whereas lemmatization uses part-of-speech rules to return real dictionary roots ("studies" -> "study","better" -> "good"). - TF-IDF: Multiplies Term Frequency (how often a word appears in document
d) by Inverse Document Frequency (how rare that word is across allNdocuments). Usingtf = count / doc_lengthandidf = ln(N / df)acrossN = 3mini-documents:
d1 = "the server dropped the packet" (5 words) d2 = "the server rebooted" d3 = "the query timed out" Term Docs containing term (df) idf = ln(3 / df) tf in d1 tf-idf in d1 the 3 0.000 2/5=0.4 0.000 server 2 0.405 1/5=0.2 0.081 dropped 1 1.099 1/5=0.2 0.220 packet 1 1.099 1/5=0.2 0.220"the"appears everywhere so its weight collapses to0, while"dropped"and"packet"uniquely identifyd1. Note that libraries like scikit-learn smooth the formula (idf = ln((1 + N) / (1 + df)) + 1) and L2-normalize each document vector, so always state the exact variant.- Dense embeddings vs TF-IDF: Embeddings map text into fixed-length continuous vectors where similar meanings point in similar directions, measured by cosine similarity
cos(u, v) = (u . v) / (||u|| * ||v||). TF-IDF is fast, interpretable, and excels on exact error codes or rare identifiers; embeddings catch paraphrases ("outage"vs"downtime"). Production search usually combines both (hybrid retrieval). - Perplexity: Evaluates an autoregressive language model by asking "how many equally likely choices is the model effectively hesitating between at each token?" Formally,
PPL = exp(mean negative log-likelihood per token). If a model assigns probabilities[0.5, 0.25, 0.125, 0.5](1/2, 1/4, 1/8, 1/2) to a 4-token sentence, the per-token surprises in bits (-log2 p) are1, 2, 3, 1, averaging1.75bits, soPPL = 2^1.75 = 3.364(identical using natural logs:e^1.213 = 3.364). Lower is better, but perplexity is only comparable when the tokenizer and test corpus are identical — splitting words into finer subwords artificially lowers per-token perplexity while multiplying token count.
import math token_probs = [0.5, 0.25, 0.125, 0.5] mean_nll = -sum(math.log(p) for p in token_probs) / len(token_probs) perplexity = math.exp(mean_nll) print(round(mean_nll, 3), round(perplexity, 3)) # 1.213 3.364- Tokenization and normalization: Splitting on whitespace leaves unseen words as out-of-vocabulary unknowns. Subword tokenizers such as Byte-Pair Encoding (
Guarantee reproducibility and zero data leakage
An offline metric is trustworthy only if a teammate can rerun your pipeline next month and reproduce the number without hidden leakage:
- Control all sources of randomness: Seed Python's
random, NumPy, the deep-learning framework, and data-loader workers, and enable deterministic GPU kernels when verifying exact parity (noting the throughput trade-off). - Freeze and version data splits: Persist exact train/validation/test document IDs alongside a cryptographic hash of the dataset snapshot, the Git commit SHA, hyperparameters, and locked package versions.
- Split by entity group and time, not by random row: If three revisions of the same postmortem or support thread land across train and test, the model memorizes phrasing instead of generalizing (data leakage). Group near-duplicates into the same split, and split chronologically (
train < val < test) whenever language, topics, or product behavior drift over time. - Measure seed variance: A single training run hides initialization noise. Suppose
5random seeds yield F1 scores[0.812, 0.805, 0.821, 0.809, 0.816]. Their mean is0.813and sample standard deviation iss = 0.0062; a two-sided 95% Student-t interval (df = 4,t = 2.776) is0.813 ± 2.776 * 0.0062 / sqrt(5) = 0.813 ± 0.008. Claiming victory over a+0.003single-seed gain mistakes random initialization luck for progress.
- Control all sources of randomness: Seed Python's
Report experiments with confidence intervals and paired tests
Every test-set score is a finite-sample estimate, so report uncertainty and compare models using paired tests on the exact same held-out items rather than eyeballing two separate intervals:
- Single-metric uncertainty: For accuracy
p_hat = 0.940onn = 1,000independent items, the standard error issqrt(0.94 * 0.06 / 1000) = 0.0075, giving a 95% confidence interval of0.940 ± 1.96 * 0.0075 = [0.925, 0.955]. - McNemar's test (paired binary classification): Two models evaluated on the same
1,000documents cancel out easy and impossible items if we inspect only disagreements. Suppose Model A is right and Model B is wrong onb = 30documents, while B is right and A is wrong onc = 15documents. With continuity correction,chi2 = (|30 - 15| - 1)^2 / (30 + 15) = 196 / 45 = 4.36(1degree of freedom,p = 0.037; exact two-sided binomialp = 0.036), confirming A beats B at the5%level even though standalone intervals overlap! - Paired bootstrap (for F1, NDCG, or MRR): Resample the
Ntest documents or queries with replacement2,000times, computemetric(A) - metric(B)on the same resampled indices each time, and report the2.5thand97.5thpercentiles:
import numpy as np def paired_bootstrap_ci( scores_a: list[float], scores_b: list[float], n_boot: int = 2000, seed: int = 0, ) -> tuple[float, float]: """Return a 95% CI for mean(A) - mean(B) by resampling items together.""" rng = np.random.default_rng(seed) arr_a = np.asarray(scores_a, dtype=float) arr_b = np.asarray(scores_b, dtype=float) diffs = np.empty(n_boot) for i in range(n_boot): sample_idx = rng.integers(0, len(arr_a), size=len(arr_a)) diffs[i] = arr_a[sample_idx].mean() - arr_b[sample_idx].mean() low, high = np.percentile(diffs, [2.5, 97.5]) return float(low), float(high)Close every experiment report with the frozen dataset version, exact metric parameters (
k, gain formula, threshold chosen on validation only), overall point estimate + 95% paired CI, multi-seed spread, slice breakdowns (document length, domain, language) to catch hidden regressions, and the human kappa ceiling.- Single-metric uncertainty: For accuracy
Intuition & how it works
Think of evaluating an applied machine-learning system like inspecting a newly built bridge before opening it to traffic: first you verify that your measuring tape is accurate (human annotator agreement), then you pick gauges that match how vehicles actually cross it (precision and recall for yes/no decisions, rank-discounted metrics like NDCG for ordered search results), lock down the blueprints so another engineer can rebuild the exact test (reproducibility), and test old vs new designs under the exact same load to separate real strength from random luck (paired statistical tests).
The naive approach — splitting rows at random, training one seed, printing overall accuracy, and shipping whichever run scores 0.3% higher on the test set — breaks down at every stage. Raw accuracy looks high (88%) even when a classifier misses every rare positive, noisy human labels create an invisible ceiling that no model can beat, near-duplicate documents leak across random splits to inflate offline metrics, and tiny score bumps vanish when you change the random seed.
Walk through a concrete 4-step mini-trace on our document task to see how rigorous evaluation catches these traps:
- Audit labels (
100double-labeled docs): When positives are rare (3%), two annotators can agree96%of the time yet have a Cohen's kappa (chance-corrected agreement) of just0.313because they disagree on almost every positive, signaling you must tighten labeling guidelines first. - Score classification (
1,000docs,120relevant): WithTP = 80, FP = 20, FN = 40, TN = 860, reporting precision (80 / 100 = 0.800), recall (80 / 120 = 0.667), and F1 (0.727, the harmonic mean that drops if either precision or recall is weak) reveals40missed documents that0.940accuracy hides. - Score search order (
[0, 3, 1, 0, 2]): NDCG@5 (Normalized Discounted Cumulative Gain, which weights higher relevance grades and discounts deeper positions against the ideal[3, 2, 1, 0, 0]order) scores6.077 / 9.393 = 0.647, penalizing the irrelevant result sitting at rank1. - Compare models on the same items: When Model A beats Model B on
30test documents and loses on15(tying on the other955), McNemar's test (a paired chi-squared test on disagreements only) yieldsp = 0.037, proving a statistically significant win without wasting power on shared easy examples.
Key points
- Audit label reliability before blaming the model: Cohen's kappa
(p_o - p_e) / (1 - p_e)strips out chance agreement (0.700on balanced labels vs0.313despite96%raw agreement under3%prevalence). Use Fleiss' kappa for3+raters and Krippendorff's alpha when ratings are ordinal or partially missing. - Derive classification metrics from
TP, FP, FN, TNand business cost: Choose decision thresholds on the validation set to balance false alarms vs missed documents, prefer PR-AUC (precision-recall area) over ROC-AUC (true-positive vs false-positive area) when positives are rare, and check probability calibration (whether a0.80score truly happens80%of the time) via reliability diagrams or the Brier score. - Match ranking metrics to user behavior: Use MRR (Mean Reciprocal Rank) when one right answer suffices, MAP (Mean Average Precision) for binary multi-hit recall, and NDCG@k for graded relevance (
0-3), stating the gain formula (2^rel - 1vsrel), cutoffk, and empty-query rule. - Keep NLP baselines and language-model comparisons apples-to-apples: Subword BPE (Byte-Pair Encoding) avoids unknown words, TF-IDF downweights ubiquitous words (
idf = ln(3/3) = 0) as a strong keyword baseline alongside dense semantic embeddings, and perplexity (exp(mean NLL),3.364in our 4-token trace) can never be compared across different tokenizers. - Lock down reproducibility and report paired uncertainty: Freeze group-aware and chronological splits, version data/code/environments, report mean ± spread across multiple seeds, and test model differences with McNemar's test or a paired bootstrap (resampling test items with replacement to build a confidence interval for the metric gap) while touching the test set only once.
Common mistakes
- Quoting raw percent agreement on imbalanced labels, or reporting accuracy / ROC-AUC alone when rare-class precision is what users actually experience.
- Averaging precision or F1 across uneven data batches instead of summing
TP,FP, andFNglobally first (the average of ratios does not equal the ratio of sums). - Comparing perplexities across two models that use different subword vocabularies, or comparing NDCG scores computed with different gain conventions or empty-query rules.
- Splitting rows randomly when multiple versions, chunks, or citations of the same source document exist, leaking test text into training.
- Tuning thresholds, hyperparameters, or "best of 20 runs" directly on the test set, which turns test noise into fake improvement (winner's curse).
- Checking whether two models' standalone 95% confidence intervals overlap instead of running a paired test on per-document or per-query differences.
Follow-up questions
- How do your labeling audit and metric computations adapt when dataset volume grows tenfold? Full double-annotation becomes too expensive, so double-label a stratified
5-10%audit slice to track kappa continuously and route uncertain examples to annotators with active sampling. Compute distributed metrics from additive sufficient statistics — sumTP,FP,FN, or per-queryDCGacross workers before dividing — and approximate global metrics like ROC-AUC with fine-grained score histograms rather than sorting billions of rows on one machine. Finally, store immutable, hashed evaluation snapshots so weekly model comparisons never drift as live production tables grow. - Which live telemetry and human-review signals would you track after deploying the model? Since ground-truth labels arrive late or not at all, monitor leading indicators first: input feature drift (document length, language mix, subword fertility), predicted score histograms, positive prediction rate, p99 latency, and error rates. Pair those with online ranking proxies (click-through rate at rank
1, query reformulation rate, zero-result rate) to catch regressions within minutes. Most importantly, send a small stratified daily sample of live traffic to human raters to measure true live precision, recall, calibration, and annotator kappa over time. - Which corner case in evaluation formulas most frequently causes silent discrepancies? Zero denominators on empty slices or queries: precision is
0 / 0when a model predicts zero positives on a small segment, Cohen's kappa divides by0when both raters put every item in one class (p_e = 1), andNDCG@kdivides byIDCG = 0when a query has no relevant documents. Different libraries silently pick0.0,1.0, orNaN(for example, scikit-learn'sndcg_scorereturns0.0with no warning when all true labels are zero), which can swing macro-averages across small slices. Always define the fallback rule explicitly, apply the exact same rule to baseline and challenger, and log how many items hit it. - If asked to code this evaluation suite in one hour, what would you build first versus defer? Implement clean, zero-dependency Python functions for the core building blocks: confusion-matrix counts (
precision,recall,F1), two-rater Cohen's kappa,MRRandNDCG@kwith explicit zero-denominator handling, and a 500-iteration paired bootstrap confidence interval. Verify every function immediately with tiny hand-worked unit tests like the100-doc kappa table and the5-item NDCG trace before touching any larger dataset. Defer multi-rater Krippendorff's alpha, distributed histogram AUC, and reliability plots, stating clearly how you would add them in production.
Follow-up questions
- How do your labeling audit and metric computations adapt when dataset volume grows tenfold?
- Which live telemetry and human-review signals would you track after deploying the model?
- Which corner case in evaluation formulas most frequently causes silent discrepancies?
- If asked to code this evaluation suite in one hour, what would you build first versus defer?
Similar questions
- Low-Latency Tree Ensemble Inference
- Select Score Cutoff for Target Precision
- Payment Fraud Detection Under Class Imbalance and Drift
- Diagnosing and Fixing Overfitting in Supervised Learning
- Correlation Bounds, Equicorrelated Variables, and Box-Muller Sampling
- Feed Click-Through Rate Feature Engineering and Modeling