BIZNIQUE / LINEAR ALGEBRA / 04
Turn repeated calculations into array operations
Turn repeated calculations into array operations
Connect a row-by-row calculation with the matrix expression that performs the same work.
BIZNIQUE / LINEAR ALGEBRA / 04
Connect a row-by-row calculation with the matrix expression that performs the same work.
THE IDEA
Each prediction is a dot product between one data row and the same weights. Writing all predictions as Xw expresses the repeated calculation in one operation and gives an implementation room to use efficient numerical routines.
ŷ = Xw
Vectorization is not the same as inventing a better feature representation. It can preserve exactly the same model, answers and statistical limitations.
TRY IT YOURSELF
For X = [[1, 2, 3], [4, 5, 6]] and w = (1, 0, −1), find Xw.
Both predictions are −2. The two row-wise calculations and the matrix product agree.