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
Then:
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
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)