Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Linear algebra is how machine learning turns business tables into predictions. If data can be stored in rows and columns, linear algebra gives us a compact and scalable way to operate on it.## Core Objects| Object | Meaning | Business example || --- | --- | --- || Scalar | one number | one product price || Vector | ordered list | one customer’s feature values || Matrix | table of numbers | a feature table for many customers || Dot product | weighted combination | a score built from multiple inputs |mermaidflowchart LR A[Feature matrix X] --> B[Multiply by weights beta] --> C[Predictions y-hat]Alt text: A feature matrix is multiplied by a weight vector to produce predictions.## Worked Example

X=[10587],β=[23]X = \begin{bmatrix} 10 & 5 \\ 8 & 7 \end{bmatrix}, \qquad \beta = \begin{bmatrix} 2 \\ 3 \end{bmatrix}

Then:

Xβ=[3537]X\beta = \begin{bmatrix} 35 \\ 37 \end{bmatrix}

That gives one prediction for each row of business data.## Guided Practice1. What does one row of a feature matrix typically represent?2. What is the job of the coefficient vector?3. Why is the dot product important in a linear model?

Answers
1. One observation 2. It stores feature weights 3. It combines features into a weighted prediction
Next: Calculus Essentials

import numpy as npX = np.array([[10, 5], [8, 7]])beta = np.array([2, 3])predictions = X @ betaprint('X =\n', X)print('beta =', beta)print('predictions =', predictions)
import numpy as npcustomer_a = np.array([3, 1, 4])customer_b = np.array([2, 1, 5])similarity = customer_a @ customer_bprint('customer_a =', customer_a)print('customer_b =', customer_b)print('dot product similarity =', similarity)