Locate an axis error in a feature table

Preserve the order of coordinates and the signs of values. · 181 words

A feature table stores examples as rows and features as columns. The weight vector must follow the column order exactly. Suppose a delivery-time model uses [distance_km, weight_kg] with weights [1, 2]. One parcel has row [10, 5], so its score is 1(10) + 2(5) = 20. If preprocessing swaps the columns and sends [5, 10], the model computes 1(5) + 2(10) = 25. The error is an axis-order mismatch: distance now uses weight 2, and weight uses weight 1. Checking one row against the feature names reveals the swap.

Another axis error swaps rows and columns. A soccer table has three players as rows and two features, goals and assists, as columns: [2, 1], [3, 4], and [1, 2]. With weights [0.5, 1], correct player scores are 2, 5.5, and 2.5. If the table is transposed, its shape changes from 3x2 to 2x3. It then has goals and assists as rows and can produce only two feature summaries, not one score per player. The expected matrix has 3 examples by 2 features. Checking the shape and axis labels catches this error.

Check your recall

A delivery model expects [distance_km, weight_kg] but receives [5, 10] for a parcel whose actual features are [10, 5]. What axis error occurred, and what is the correct score?

Check your answer

The feature columns were swapped, so distance was paired with weight 2 and package weight with weight 1. The correct row is [10, 5], giving a score of 1(10) + 2(5) = 20 instead of 25.

Sources and credits

Original KeyTouch lesson. Background reading · Zhang et al. · Linear Algebra.