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.

  1. Raw Table Has Row IDs

    primary keys locate records in databases, not points in feature space

  2. Choose Feature Columns

    fix the exact predictor list and keep the target column out of X

  3. Build X Matrix

    observations on rows, features on columns—and transpose, never reshape

  4. Build y Vector

    unsqueeze y to (n, 1) so pred - y never broadcasts into (n, n)

  5. Add Intercept Column

    prepend ones at column 0 to fold the baseline offset into X_aug @ beta

  6. What the Matrix Does and Does Not Say

    X @ beta spans only the columns inside X and never proves causation