When would you choose an SVM over a decision tree based on the geometry of the data?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: medium
Interview Round: Other
When would you choose an SVM over a decision tree based on the geometry of the data?
Explain how the shape of the boundary between the classes, and the kind of features you have, should drive the choice, and say when the decision tree is the better pick.
```hint Draw the boundaries
Sketch, in two dimensions, the boundary a single tree can produce when every split tests one feature against a threshold. Then draw a diagonal line through the same plot.
```
```hint Many perfect separators
When several boundaries all separate the training data perfectly, ask which of the two models has a rule for choosing among them.
```
### What a Strong Answer Covers
- The kind of boundary each model can represent: axis-parallel splits for a tree, a hyperplane or smooth kernel contour for an SVM
- What happens when a tree has to approximate an oblique or curved boundary, in terms of the number of splits, variance and generalization
- How the maximum margin decides where the boundary sits when there is a gap between the classes
- Data conditions that favor each model, such as feature types, feature scaling, dimensionality and sample size
- Cases where the tree is the better choice, including rule-like structure and interpretability
### Follow-up Questions
- If you suspect the boundary is oblique, how could you help a decision tree without switching to an SVM?
- How do random forests and gradient-boosted trees change this comparison?
- Why does an SVM need feature scaling when a tree does not?
- How does the training cost of a kernel SVM grow with the number of samples, and when does that rule it out?
Overview: Asks when the shape of the class boundary makes a support vector machine a better choice than a decision tree, and when the tree wins instead. Tests understanding of axis-parallel splits, max-margin hyperplanes, RBF kernels, and how feature types and sample size affect the choice.