Unit 10 · Linear algebra in machine learning
Lesson 86 · Available to read
Data as a matrix
Rows are examples and columns are features. A dataset is one big matrix X.
Remember post 6, where a house became a vector [size, rooms, age, price]? Now stack many houses.
Each row is one example: a house. Each column is one feature: size, rooms or age. Together they form a matrix X. What we want to predict, price, goes in a separate vector y.
10,000 houses with 3 features is just a 10,000 × 3 matrix.
This is how nearly every ML model sees the world. Training means finding how X relates to y, using everything from the last 89 posts.
The takeaway
Rows = examples, columns = features.
Practice
0 of 4 attempted
- 1Calculate
A dataset has 500 houses with 4 features each. What is the shape of X, and how long is y?
Saved in this browser
- 2Recall
In a data matrix, what do rows and columns stand for?
Saved in this browser
- 3Multiple choice
Where does the thing we want to predict (e.g. price) usually go?
- 4Apply
Design a data matrix for predicting whether students pass an exam: what are the rows, three possible columns, and y?
Saved in this browser