KatInterview

Linear Regression, Tree Ensembles, Rare Fraud, and Seasonal Forecasting

Machine LearningModel answer
HardModel answerMachine Learningolsensemblesclass-imbalance

Last updated

Explain OLS and its assumptions, compare bagging, random forests and boosting, handle a 0.2% positive class, and outline a forecasting pipeline for data with trend and seasonality.

Context

You are the ML lead for an online marketplace. Two projects are on your plate:

  1. A fraud classifier, where only about 0.2% of examples are fraudulent.
  2. A demand forecaster whose history shows both a long-run trend and repeating seasonal cycles.

Questions

Answer each part as you would in a technical discussion, with reasoning and trade-offs rather than a list of buzzwords.

  1. Ordinary least squares. Describe how OLS fits a model. Give the objective, the closed-form solution and how it is computed in practice. List the assumptions it relies on and say what each one is needed for.
  2. Tree ensembles. Compare bagging, random forests and gradient-boosted trees. Cover how each is built, which source of error it mainly reduces, how much tuning it needs, and when you would choose each.
  3. Rare positives. With a 0.2% positive rate, explain how you would handle the imbalance during training and during evaluation. Cover splitting, reweighting or resampling, probability calibration, metrics, and threshold choice.
  4. Forecasting workflow. Lay out an end-to-end process for building a forecasting model when trend and seasonality are present, from problem framing through validation and deployment.

What a strong answer shows

  • Preprocessing and feature engineering choices
  • Resampling or weighting strategies and their pitfalls
  • Metrics that stay meaningful under heavy imbalance
  • Validation that respects the order of time

Hints

Hint 1

For OLS, start from the squared-error objective, set its gradient to zero, and ask which assumptions are needed for unbiasedness versus for valid standard errors and tests.

Hint 2

Frame the ensemble comparison around bias versus variance: bagging and random forests average independent trees, while boosting adds trees one after another to correct earlier errors.

Hint 3

At 0.2% positives, a model that always predicts the majority class is 99.8% accurate. Think about which metrics have a meaningful baseline, where resampling must happen relative to the split, and what weighting does to predicted probabilities.

Hint 4

For forecasting, avoid random shuffles. Use rolling-origin validation, build strong naive baselines first, and make sure every feature would have been known at forecast time.