Feature Matrix, Exactly
Excluding row identifiers, selecting ordered predictor columns, shaping X as (n, p) and y as (n, 1), prepending an intercept column of ones, and what a design matrix can and cannot say.
From Raw Tables to Design Matrices
Drop identifier columns, pick ordered predictors, align (n, p) design matrices with (n, 1) target vectors, and prepend a unit intercept column.
- Raw Table Has Row IDs
primary keys locate records in databases, not points in feature space
- Choose Feature Columns
fix the exact predictor list and keep the target column out of X
- Build X Matrix
observations on rows, features on columns—and transpose, never reshape
- Build y Vector
unsqueeze y to (n, 1) so pred - y never broadcasts into (n, n)
- Add Intercept Column
prepend ones at column 0 to fold the baseline offset into X_aug @ beta
- What the Matrix Does and Does Not Say
X @ beta spans only the columns inside X and never proves causation