Why does a decision tree approximate a diagonal decision boundary with a staircase?
answer
- one feature per question
- cuts perpendicular to an axis
- leaves are boxes, never slanted
- steps get finer, never tilt
- a summed feature turns it into one cut
basics
~20 sEvery split tests one feature against one threshold, so each cut is a line perpendicular to one axis. A boundary that depends on two features jointly can only be tiled by many small axis-parallel steps.
solid answer
~40 sA tree node asks a question of the form `feature <= threshold`, which is a cut perpendicular to that feature's axis. The regions it carves are therefore always axis-parallel boxes, and the boundary between them is made of horizontal and vertical pieces only. Suppose delivery eligibility is really `latitude + longitude <= c`, a 45-degree line: the tree has to tile the eligible side with rectangles, so it spends one split per step, and it needs the most steps exactly where data is scarcest, right along the boundary. More depth makes the steps finer but never tilts them, and rescaling the features changes nothing at all. The effective fix is a feature: hand the tree `latitude + longitude` as a column and a single split reproduces the rule exactly.
go deeper
Be ready to state that each node tests one feature against one threshold, so the regions are axis-parallel boxes, and to sketch a staircase hugging a 45-degree line.
Explain the cost mechanics: one split per step, error concentrated in the triangles along the boundary, depth growing where data is thinnest, and why scaling changes nothing.
Show the diagnosis-to-fix path: spot that a rule is a sum or ratio, add it as a feature, and demonstrate that the tree becomes shallower and its extracted rules readable.
Own the framing question of whether the feature space is the right coordinate system for the problem at all, and weigh engineered combinations against oblique splits or a different model family.
## What "axis-aligned" means A CART-style decision tree grows by asking, at each internal node, a question of exactly one shape: `feature_j <= t`. One feature, one threshold, one comparison. Geometrically that question is a hyperplane perpendicular to the j-th coordinate axis. Applying such a question recursively partitions the input space into **hyperrectangles** — boxes whose faces are all parallel to the axes. In two dimensions each leaf is a rectangle (possibly unbounded), and the model's decision boundary is a union of horizontal and vertical segments. It can never contain a slanted edge, because no node is allowed to ask about two features at once. ## Where the staircase comes from Take a delivery-zone rule where a customer is eligible when `latitude + longitude <= c`. In the latitude-longitude plane that is a single straight line at 45 degrees. Neither feature alone tells you the answer: for any fixed latitude there is a longitude cutoff, and that cutoff moves as latitude moves. The tree can only approximate this by chopping latitude into bands and, inside each band, picking a longitude cutoff — which is precisely a staircase hugging the diagonal. The cost has a shape worth internalising. Each step costs a split, and the misclassified area is the set of little triangles between the true line and the step edges. Halving the width of the steps roughly halves that error area but doubles the number of leaves. Meanwhile every threshold has to be estimated from the rows near it, and the rows near the boundary are the scarce, ambiguous ones. So the tree is most data-hungry exactly where it has the least usable signal — that is why a diagonal boundary shows up as a deep, jagged, sample-sensitive region of the model rather than as an outright failure. ## Consequences you can name in an interview 1. **Sample cost.** Accuracy near the boundary improves only as fast as you can afford new splits, and each split needs rows. 2. **Jagged behaviour.** Two customers a hundred metres apart, on either side of one step, get opposite decisions for no reason a domain expert would accept. 3. **Unreadable explanations.** The extracted rules read as an arbitrary list of coordinate thresholds when the real rule is a one-line sum. 4. **Ensembles do not remove it.** Combining many axis-aligned trees produces a finer, smoother-looking staircase — the steps shrink, they do not tilt. ## Scale invariance is not rotation invariance A tree compares a value to a threshold, so it only uses the **order** of the values, not their spacing. Apply any strictly increasing transform to a single feature — multiply by 1000, switch from metres to feet, take a log of a positive quantity — and every threshold maps across one-for-one. The tree structure and every prediction are unchanged. That is why standardising features does nothing for a tree. Rotation is a different operation: it mixes features. Rotate two vibration-sensor axes by 45 degrees and the data cloud is geometrically identical, but the informative direction now lies diagonally in the new coordinates. The tree that used one clean cut now needs a staircase, and its node count explodes for the same accuracy; a linear model fits the rotated data just as well as the original, with rotated coefficients. Trees are invariant to monotone transforms of individual features, and sensitive to linear combinations of them. Candidates who have half-memorised "trees do not care about scaling" usually over-generalise it into "trees do not care about the coordinate system," which is the opposite of true. ## What actually helps - **Engineer the combination.** If you suspect a sum, difference, or ratio drives the outcome, add it as a column. One split on `latitude + longitude` reproduces the diagonal exactly, and the model gets shallower, more stable, and more readable at once. This is the highest-value move by a wide margin. - **Oblique (multivariate) trees.** These split on a linear combination of several features, so a node can express a slanted cut directly. They are more expressive but costlier to fit and harder to explain. - **Pick a different family.** If the true structure is a smooth or rotated boundary, a model whose boundary is naturally oblique will need far less data. - **Or accept it.** Many real tabular rules genuinely are axis-aligned — a price threshold, an age cutoff, a sensor limit, a policy band. That is a large part of why trees do so well on tabular business data; the staircase is only a liability when the truth is diagonal. ## What does not help Deeper trees give finer steps, not slanted ones. Feature scaling has literally no effect. More data shrinks the steps but leaves the staircase in place. Recognising this trio as non-fixes is what separates a real answer from a recited one.
- Would standardising latitude and longitude help the tree find that diagonal boundary?No. A split only compares a value to a threshold, so it depends on the order of values, not their units or spread. Any strictly increasing rescaling maps each threshold one-for-one and leaves the fitted tree and its predictions identical. Standardisation matters for distance-based and penalised models, not for this one.
- What single engineered feature would let one split capture the rule?The sum itself: add a column equal to latitude plus longitude, and the rule becomes a threshold on that one column, which is exactly what a node can express. The same trick applies to differences (price minus cost), ratios (debt to income), and any combination you can state in domain terms.
- Does axis alignment also make a tree rotation-invariant?No, and this is the common over-generalisation. Trees are invariant to monotone transforms of a single feature, but rotating the axes mixes features. Rotate two sensor channels by 45 degrees and the same signal now needs a staircase of many nodes instead of one cut, while a linear model's fit is unaffected.
It is like drawing a diagonal line on graph paper by filling in whole squares: you can hug the line as closely as you like by using smaller squares, but the edge is always made of corners.
saying these in an interview costs you the question
- Claims a deeper tree eventually produces a truly diagonal boundary
- Says standardising the features would fix the staircase
- Believes one node can test two features at once
- Confuses scale invariance with invariance to rotating the axes
- Assumes more training data removes the steps rather than shrinking them