SchoolWhool
Quizzes and saved progress, freeSign in freeSign in
Maths · Module 0Module material

Maths for machine learning interview questions

12 questions interviewers ask on why maths matters, from first principles to the follow-ups. The first 3 model answers are free to read; Pro opens the rest.

  1. What does a linear model compute for one row?

    A weighted sum: each feature times its weight, all added, which is the dot product of the feature vector and the weight vector. The first feature is a constant one, so its weight, the intercept, is added to every prediction. For Grace's shop on 1 January 2025 the five products add up to 3,051.11 with the full weights.

  2. How do you compute predictions for a whole table, and why not a loop?

    As one matrix–vector product, X @ w: every row of X dotted with the same w. For the shop year that is 2,920 predictions in one line. A Python loop gives the same numbers, but NumPy runs the products and sums in compiled code over the whole array, which is much faster and is what every library does.

  3. A feature has the largest weight in a linear model. Is it the most important feature?

    Not from that alone. A weight is measured per unit of its feature. In the shop model, promotion's weight is 287.17 dollars per promotion and footfall's is 2.66 dollars per visitor, but a day has 0 or 1 promotions and hundreds of visitors, so on Grace's day footfall's product is about 9.09 times promotion's. Compare contributions (weight times value), or compare weights only after putting the features on one scale.

  4. Why is the mean squared error used, rather than the mean error?
  5. The mean squared error is 26,841.46. How far off is the model on a typical day?
  6. What does the derivative of the loss with respect to a weight tell you?
  7. What is the gradient, and how does gradient descent use it?
  8. How would you check that a hand-written gradient is correct?
  9. Why do probabilistic models work with sums of log-probabilities?
  10. What is underflow, and where does a float64 hit it?
  11. Two models both give the data a likelihood that prints 0.0. How do you compare them?
  12. Multiplying the day-by-day probabilities assumes something. What?