Nine-Part ML Fundamentals and Model Diagnostics Review
Machine LearningModel answerLast updated
Answer nine practical questions on statistical testing, model fit, causality, representations, optimization, imbalanced data, misleading accuracy, and experiment sanity checks.
Imagine a breadth-oriented screen for a senior applied science position. You are asked a series of short conceptual questions and are expected to give, for each one, a clear definition, the situations in which it matters, and the typical mistakes people make.
Answer the following:
- Significance testing. What does a p-value measure? What conclusions does it support, and which ones does it not?
- Model fit. Define overfitting and underfitting. How would you detect each one, and what would you change to fix it?
- Causality. What is causal inference, and which families of methods are used to estimate causal effects? Briefly describe each.
- Representations. What do "encoding" and "decoding" mean in machine learning? Give concrete examples from both feature engineering and neural architectures.
- Optimization. Explain gradient descent and backpropagation at a high level, and how they relate.
- Gradient stability. What are vanishing and exploding gradients? How do you spot them and reduce them?
- Skewed classes. How do you approach a classification problem where one class is extremely rare?
- Misleading accuracy. Describe a case where a model scores 99% accuracy yet is nearly useless. How would you evaluate it properly and improve it?
- Experiments. What is an A/B test? If its result looks strange or too good to be true, what could be going on and how would you investigate?
Aim for roughly one to two minutes of spoken answer per item, with the option to go deeper on any of them.
Hints
Hint 1
For each item, use the same skeleton: definition, when it matters, how to diagnose it, how to fix it, and one common trap.
Hint 2
Many of these topics share a theme: leakage, distribution shift, and wrong metrics are often the real cause behind a symptom that looks like something else (overfitting, a great A/B lift, 99% accuracy).
Hint 3
Separate what computes from what uses: backprop computes gradients, gradient descent consumes them; resampling belongs only in training data; the p-value is about the data under the null, not about the hypothesis.
Hint 4
For the suspicious A/B test, think in layers: assignment integrity (sample ratio mismatch), instrumentation, metric definition, statistical practice (peeking, multiple tests), then real-world effects (novelty, interference, seasonality).
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Approach
For each topic: give a crisp definition, say when it matters, then name the pitfall. Below is a model answer.
1. P-value
It is the probability of seeing data at least as extreme as observed, assuming the null hypothesis is true. Choose the significance level (e.g. 0.05) before looking at the data; reject the null if p is below it.
It is not the probability that the null is true (that needs a prior and Bayes' rule), not an effect size (with huge n, a trivial effect yields a tiny p), and a large p does not prove the null (you may be underpowered).
Pitfalls: peeking and p-hacking, multiple comparisons (use Bonferroni or Benjamini-Hochberg), and reporting p without a confidence interval.
2. Overfitting and underfitting
- Overfitting (high variance): the model fits noise. Training error is low, validation error is much higher, and often validation loss rises while training loss still falls.
- Underfitting (high bias): the model is too simple or undertrained. Both errors are high and close together.
Diagnose with learning curves (error versus training size and versus epochs) and cross-validation; use time-based splits for temporal data.
Fix overfitting: more data or augmentation, L1/L2, dropout, early stopping, simpler model, feature selection, bagging. Fix underfitting: more capacity or better features, less regularization, longer training or tuned learning rate, boosting.
Common mistake: calling something overfitting when it is really leakage or train/test distribution shift. Check those first.
3. Causal inference
The goal is to estimate the effect of an intervention, such as E[Y(1) - Y(0)], not just a correlation. The fundamental problem: only one potential outcome per unit is observed.
- Randomized experiments: randomization removes confounding; the gold standard.
- Propensity matching / inverse-probability weighting: model P(treatment | X) to balance covariates; needs no unmeasured confounding.
- Difference-in-differences: compare pre/post change in treated vs. control; needs parallel trends.
- Instrumental variables: a variable that moves treatment and affects the outcome only through it.
- Regression discontinuity: exploit a cutoff rule.
- Synthetic control: weighted untreated units form a counterfactual for one treated unit.
- Double ML / uplift models: estimate heterogeneous effects with ML for nuisance functions.
Observational methods rest on untestable assumptions; say how you would stress them (placebo tests, sensitivity analysis).
4. Encoding and decoding
Encoding maps raw input to a usable representation; decoding maps a representation to an output.
- Feature encodings: one-hot, ordinal, hashing, learned embeddings, and target encoding (compute out-of-fold to avoid leakage).
- Autoencoders: encoder compresses x to z, decoder reconstructs x.
- Transformers: BERT is encoder-only, GPT decoder-only, T5 encoder-decoder.
- Generation decoding: greedy, beam search, top-k, nucleus sampling, temperature.
5. Gradient descent and backpropagation
Gradient descent updates parameters opposite the gradient: θ ← θ - η∇L(θ). Full-batch uses all data; mini-batch SGD is noisy but scalable. Momentum smooths steps; Adam/RMSProp adapt per-parameter rates; AdamW decouples weight decay.
Backpropagation applies the chain rule over the computation graph: a forward pass caches activations, a backward pass propagates ∂L/∂output layer by layer, at a cost comparable to the forward pass. Backprop computes gradients; gradient descent uses them. Traps: learning rate too high or low, no warmup or schedule, unscaled features.
6. Vanishing and exploding gradients
Gradients are products of many Jacobians. Norms below 1 shrink them exponentially (early layers stall); above 1 they blow up (NaN losses).
Mitigations: ReLU/GELU instead of saturating sigmoid/tanh; Xavier init for tanh and He init for ReLU; BatchNorm/LayerNorm; residual connections; LSTM/GRU for sequences; gradient clipping by norm; lower learning rate with warmup. Diagnose by logging per-layer gradient norms.
7. Highly imbalanced data
- Metrics first: precision, recall, F1, PR-AUC (more informative than ROC-AUC for rare positives), recall at fixed precision.
- Data level: under/oversample or SMOTE, only on training folds.
- Algorithm level: class weights, cost-sensitive loss, focal loss.
- Decision level: tune the threshold on validation data to business cost; recalibrate probabilities after resampling since base rates are distorted.
- For extreme rarity, consider anomaly detection or active labeling.
8. 99% accuracy but a bad model
Example: fraud occurs in 1% of transactions. A model that always predicts "not fraud" scores 99% accuracy with zero recall. Accuracy hides the failure because it is dominated by the majority class.
Evaluate with the confusion matrix, per-class precision and recall, PR curves, and cost-weighted metrics. Compare against a trivial baseline. Then fix with the imbalance toolkit above, threshold tuning, and better features. Also check for leakage if the score seems implausibly high in the other direction.
9. A/B tests and suspicious results
An A/B test randomly assigns units to control or treatment and compares a pre-defined metric to estimate the causal effect, using a hypothesis test and confidence interval, with sample size set via a power analysis.
If results look odd, investigate in this order:
- Sample ratio mismatch: does the observed split match the intended one (chi-square test)? A mismatch signals broken assignment or logging.
- Instrumentation and metric definitions: logging bugs, bots, outliers, changed denominators.
- Statistical practice: peeking, early stopping, many metrics or segments without correction, underpowered design.
- Real effects that mislead: novelty or primacy effects, seasonality, network interference or spillover, and Simpson's-paradox-style segment mixes.
- A/A tests and holdouts to validate the pipeline.
Report effect size with a confidence interval and guardrail metrics, not just a p-value.
Common mistakes across the set
- Interpreting p-values as the probability the hypothesis is true.
- Treating any train/validation gap as overfitting without ruling out leakage or shift.
- Resampling before the train/test split.
- Trusting accuracy on skewed data.
- Declaring an A/B win without checking assignment integrity.