← Questions

Timed ML screen: concept questions, then classic models from scratch

0
MetaCodingLast asked Dec 2025

A coding interview question asked in Meta's technical phone screen, last asked Dec 2025. It tests machine learning, logistic regression and naive bayes.

A timed online screen for ML-leaning engineers, about ten items in a little over an hour:

  1. Multiple-choice ML concepts: compute recall from a confusion matrix, compare bagging and boosting, and say what L1 and L2 regularization each do.
  2. Given the weights of a small two-layer network and an input, compute its output by hand.
  3. A short string problem: the longest substring made of one repeated character.
  4. Implement logistic regression and naive Bayes from scratch (fit and predict) without ML libraries.

The questions are not hard on their own; the pressure is getting all of them right in the time.

Clarifying questions

  • Which language and libraries are allowed: NumPy yes, scikit-learn no?
  • Naive Bayes on which features: Gaussian for continuous values, or counts? Should it use Laplace smoothing?
  • Logistic regression: binary only? Gradient descent with a fixed number of steps? Any regularization?
  • For the network by hand, which activation functions?
  • Is credit given per test case, so a partial answer still scores?

What a strong answer covers

  • The concepts stated precisely: recall is true positives over true positives plus false negatives; bagging lowers variance with models trained in parallel on resamples, boosting lowers bias by fitting models in sequence to earlier errors; L1 pushes weights to exactly zero, L2 shrinks them smoothly.
  • The forward pass layer by layer: weights times input, plus bias, then the activation, with the shapes checked at each step.
  • The longest run of one character in one pass, including the empty string.
  • Logistic regression with a vectorized gradient, a numerically stable sigmoid and a bias term; naive Bayes with log-probabilities and smoothing, so an unseen value does not zero out a class.
  • Time management: easy items first, and each implementation checked on a tiny dataset before moving on.

Follow-ups

  • Extend logistic regression to several classes with softmax.
  • Why does naive Bayes work well despite its independence assumption?
  • Add L2 regularization to your logistic regression.

Where it's asked

  • Meta · Technical phone screen · Last asked Dec 202545 min · Two coding problems in CoderPad, about 20 minutes each · Usually no AI; some newer screens are AI-assisted

What it tests

machine learning · logistic regression · naive bayes · sliding window

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding