Plain, bold and capital letters; hats, bars and stars
Bold, capital and plain letters are different kinds of object, and a hat, a bar or a star changes what a letter means. The widget ties three of them together.
1. The idea
The same letter in a different style is a different kind of object. Plain italic x is a single number, a scalar. Bold lowercase 𝐱 is a list of numbers, a vector. A capital X is a table, a matrix. Papers rarely say this out loud; they expect you to see it in the font.
Marks above a letter tell you its role. A hat, ŷ, is an estimate: what the model predicts for y. A bar, ȳ, is an average. A star, θ*, is the best value of something: the parameters that make the loss as small as it can be.
The widget puts all three in one picture. A model that predicts the same number θ for every example makes predictions ŷ = θ. Its squared-error loss is lowest at θ*, and θ* turns out to be exactly ȳ, the mean of the data. The steps below show why.
2. Try it: hat, bar and star
The model predicts one number θ for all six examples. Slide θ and watch the loss on the right. Where is it lowest, and what is the mean of the data?
3. The math
4. How it works
5. The code (python)
import numpy as np
y = np.array([2.0, 3.0, 4.0, 5.0, 6.0, 10.0])
def loss(theta): # predict y_hat = theta for every example
return np.mean((y - theta) ** 2)
thetas = np.linspace(0, 10, 101) # try 0.0, 0.1, ..., 10.0
theta_star = thetas[np.argmin([loss(t) for t in thetas])]
print(y.mean(), theta_star) # 5.0 5.0
print(round(loss(theta_star), 3)) # 6.6676. You’ll see this in
- Core Course chapter 3: Measuring error the mean, and why squared error loves it
- The linear model, read with the seven questions ŷ, 𝐰 and 𝐱 in one line
7. Check yourself
Finished this chapter?
What changed in ML architectures this week
New models worth knowing, benchmark moves, and one architecture explained in plain words. Free, once a week, unsubscribe anytime.