LMLearning Monitor

Linear Regression from Scratch

What is a Model?

8 min · beginner

Your phone guesses the next word you'll type. A bank guesses whether a loan will be repaid. A weather app guesses tomorrow's temperature. None of them know the answer — every one of them is using a model: a small machine that turns things it can see into a guess about something it can't.

100

Drag the sliders. This is exactly the rule from the code below — try to make it predict 150 ice creams sold at 20°C.

A model is just a rule

Suppose you sell ice cream and you notice: the hotter the day, the more you sell. You could write your hunch as a rule:

python
def predict_sales(temperature):
  return 10 * temperature - 50

That's a model. Really — that's all a model is: a function from what you know (temperature) to what you want to know (sales). The only question is whether it's a good rule.

Where the "learning" comes in

You could have written 12 * temperature - 80 instead. Or 9 * temperature. Which rule is best? Instead of guessing, machine learning finds the numbers for you by checking each candidate rule against data you've already collected and keeping whichever one misses by the least.

Those adjustable numbers — the 10 and the -50 — are called parameters. Learning = searching for the parameters that make the fewest mistakes on your data. In the next lesson we'll measure exactly how wrong a rule is, and that measurement will drive everything that follows.

Check yourself

What does a model do?
Which values can learning change in the example?