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

Vectors and norms interview questions

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

  1. What is a vector in machine learning, and what is its dimension?

    An ordered list of numbers, usually one row of features. Its dimension is the number of components: Grace's shop-day (981, 1, −1.2, 33) is in ℝ⁴. Order matters, because each position is a feature.

  2. What is the difference between shapes (d,), (1, d) and (d, 1) in NumPy?

    (d,) is a 1-D array with one axis, neither a row nor a column; (1, d) is a row matrix and (d, 1) a column matrix. .T leaves a 1-D array unchanged, so use reshape when the orientation matters.

  3. Name three norms and when you would use each.

    L2, √(Σ vᵢ²), the straight-line length and the default; L1, Σ |vᵢ|, the grid length, less affected by one large component and the basis of the lasso penalty; L∞, max |vᵢ|, the largest single deviation. For (3, −4) they give 5, 7 and 4.

  4. Why does lasso set weights to exactly zero and ridge does not?
  5. Why must features be scaled before k-nearest neighbours?
  6. What does the dot product tell you geometrically?
  7. When would you use cosine similarity instead of Euclidean distance?
  8. What is a projection, and where is it used?
  9. What does w · x + b = 0 describe, and what are w and b?
  10. Is a larger score w · x + b a larger distance from the boundary?
  11. A linear classifier gets 14 of 16 on a small dataset. Could another line do better?
  12. What is the curse of dimensionality?
  13. Does having 64 features mean nearest neighbours will fail?
  14. Why do decision trees struggle with diagonal boundaries?