Why are linear models often preferred when data is high-dimensional and sparse?
Quick Overview
Asks why regularized linear models are a common choice for high-dimensional sparse data such as text n-grams and one-hot IDs. Tests reasoning about linear separability in high dimensions, variance control with L1 and L2, the cost of sparse dot products, and why trees and nearest neighbors struggle there.
Why are linear models often preferred when data is high-dimensional and sparse?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: medium
Interview Round: Other
Typical examples are bag-of-words text features, one-hot encoded user or item IDs, and feature crosses, where each row has a handful of non-zero values out of hundreds of thousands or millions of columns.
Why are linear models often preferred when data is high-dimensional and sparse?
```hint Count the dimensions
Compare the number of features with the number of training rows, and think about how many points a hyperplane can separate as the dimension grows.
```
```hint Count the work
Work out what one prediction costs when almost every feature value is zero, and how other model families use a feature that is rarely non-zero.
```
### What a Strong Answer Covers
- Why high dimension relative to the sample count makes classes close to linearly separable, and what that means for the value of nonlinear capacity.
- How regularization controls variance when features outnumber samples, and what L1 adds.
- The computational advantages of a dot product over sparse inputs and of solvers that work on sparse matrices.
- Why trees and nearest-neighbor methods struggle in this setting.
- Where linear models fall short, and how interactions can be added.
### Follow-up Questions
- If the training set is linearly separable, what happens to unregularized logistic regression, and how does regularization change that?
- How would you add feature interactions to a linear model on sparse data without an explosion in the number of parameters?
- When would gradient-boosted trees beat a linear model on the same problem?
- How does the hashing trick bound memory for a linear model with an open-ended vocabulary, and what does it cost?
Overview: Asks why regularized linear models are a common choice for high-dimensional sparse data such as text n-grams and one-hot IDs. Tests reasoning about linear separability in high dimensions, variance control with L1 and L2, the cost of sparse dot products, and why trees and nearest neighbors struggle there.
Typical examples are bag-of-words text features, one-hot encoded user or item IDs, and feature crosses, where each row has a handful of non-zero values out of hundreds of thousands or millions of columns.
Why are linear models often preferred when data is high-dimensional and sparse?
What a Strong Answer Covers Guidance
Why high dimension relative to the sample count makes classes close to linearly separable, and what that means for the value of nonlinear capacity.
How regularization controls variance when features outnumber samples, and what L1 adds.
The computational advantages of a dot product over sparse inputs and of solvers that work on sparse matrices.
Why trees and nearest-neighbor methods struggle in this setting.
Where linear models fall short, and how interactions can be added.
Follow-up Questions Guidance
If the training set is linearly separable, what happens to unregularized logistic regression, and how does regularization change that?
How would you add feature interactions to a linear model on sparse data without an explosion in the number of parameters?
When would gradient-boosted trees beat a linear model on the same problem?
How does the hashing trick bound memory for a linear model with an open-ended vocabulary, and what does it cost?