What Is a Machine Learning Model, Really?

A machine learning model is a rule with blanks, plus the numbers that training found for them. This first post in a five-part series builds that idea from zero with one tiny example: predicting an exam score from study hours. It covers weights, biases and parameters, and why big models are called big.

Some problems are too hard to write rules for. So instead of writing the rules, we show the computer many examples and let it find the rules itself. That is machine learning.

This post is the first of five. It needs no background in AI, statistics or advanced math. If you can multiply and add, you can follow every example.

By the end, you'll know what a "model" actually is. We'll get there in four steps:

  1. What machine learning is. How it differs from normal programming.
  2. A model is a rule with blanks. The one idea everything else builds on.
  3. Weights and bias. The two kinds of blanks, and what each one means.
  4. Parameters. The name for all the blanks together, and why big models are "big".

Normal programming vs. machine learning

In normal programming, a person writes the rules, and the computer follows them.

Take tax. A programmer writes a rule like "tax = 15% of income". The computer applies that rule to every input. Give it an income of 40,000, and it gives back 6,000.

But some problems are too hard to write rules for. Think about spam emails. You could try a rule like "if the email contains 'free money', mark it as spam". But spammers change their wording all the time. You would need thousands of rules, and they would still miss a lot of spam.

Machine learning flips this around. You don't write the rules yourself. Instead, you give the computer many examples, each with the correct answer. The computer then works out the rules on its own.

For spam, you would give it thousands of emails. Each one is labelled "spam" or "not spam". The computer finds the patterns that separate the two groups.

Two flows compared. In normal programming, an input (income 40,000) and rules written by a person (tax = 15% of income) go into the computer, which gives an output (tax 6,000). In machine learning, examples (thousands of emails) and their correct answers (each labelled spam or not spam) go into training, which gives back the rules: the model.

The rules are the thing that moved. In normal programming, they go in. In machine learning, they come out.

The kind of machine learning this series covers

Learning from examples that come with correct answers is called supervised learning. It is the most common kind, and it is what this series is about.

There are two other main kinds. You'll hear their names, so here they are:

  • Unsupervised learning. The examples have no answers. The model looks for structure on its own, such as groups of similar customers.
  • Reinforcement learning. The model learns by trial and error. It tries actions and gets rewards or penalties, like a game-playing AI learning which moves win.

Many core ideas in this series carry over to those two kinds as well.

Where machine learning is used

  • Spam filters in email
  • Loan approval at banks
  • Recommendations for products, music and videos
  • Recognizing faces and objects in photos
  • Speech recognition in voice assistants
  • Chatbots and AI assistants

Two phases: training and prediction

Every machine learning model goes through two phases:

  1. Training. The model learns from examples. This usually happens once, or from time to time. It can take a long time, and it needs a lot of data.
  2. Prediction. The trained model is put to use. You give it a new input, and it gives you an output. This is fast, and it happens many times. Prediction is also called inference.

Here is an example. A bank trains a loan-approval model once, using thousands of past applications. After that, it uses the trained model every day to make predictions about new applicants.

A few basic words

Four words come up in every post of this series:

WordMeaningExample
DatasetA collection of examples10,000 past loan applications
ExampleOne item, or one row, in the datasetOne person's loan application
Feature (also called an input)One piece of information given to the modelIncome, debt, credit score
Label (also called the output or target)The answer the model should produceApproved or rejected

So a dataset is a table. Each row is an example. Some columns are features. One column is the label.

A model is a rule with blanks

Let's start with a very small problem. We want to predict a student's exam score from the number of hours they studied.

Suppose you believe that more study leads to a higher score, in a simple, steady way. You might guess the rule looks like this:

score = ? × hours

This is a rule, but it has a blank: the ?. You don't know which number belongs there. Nobody tells you. You have to work it out from data.

Training means filling in the blank

To find the missing number, you collect real examples from past students:

Hours studiedReal score
220
550
880

Now try different numbers for the blank. Check how close the rule gets to the real scores:

TryRule gives for 2 hoursReal scoreVerdict
? = 33 × 2 = 620Way too low
? = 77 × 2 = 1420Closer, but still too low
? = 1010 × 2 = 2020Correct

With ? = 10, the rule also gives 50 for 5 hours and 80 for 8 hours. It matches every example. Here are the three tries drawn against the data:

So the finished rule is:

score = 10 × hours

Finding the number 10 is called training. A computer does exactly this, just in a smarter and faster way. It tries a number, checks how wrong the results are, adjusts the number, and repeats. The next post shows how.

Prediction means using the finished rule

Now a new student says they studied 6 hours. You don't know their score yet. But you have a trained rule:

score = 10 × 6 = 60

You give the model an input (6 hours), and it gives you an output (60 points). This is prediction.

What a model really is

This tiny example holds the core idea behind all of machine learning:

  • A model is a rule (a formula) that contains some unknown numbers.
  • Training finds good values for those numbers, using examples.
  • Prediction uses the rule, with those numbers filled in, on new inputs.

Even the largest AI systems follow this same pattern. The only difference is how big the rule is, and how many blanks it has.

Weights: how much each input matters

In real life, a result usually depends on more than one thing. A student's score might depend on how much they studied and how much they slept.

So the rule now needs two blanks, one for each input. We'll call them w1 and w2. The "w" stands for weight.

score = w1 × study_hours + w2 × sleep_hours

Each input gets its own weight. The weight is multiplied with that input.

What a weight means

A weight tells you how much an input matters to the result.

Suppose training finds w1 = 8 and w2 = 3. That means:

  • Every extra hour of study adds 8 points.
  • Every extra hour of sleep adds 3 points.
  • So in this data, study has a bigger effect than sleep.

Some general rules for reading weights:

  • A large weight means the input has a strong effect.
  • A small weight means the input has a weak effect.
  • A weight of zero means the input has no effect at all.
  • A negative weight means the input pulls the result down. For example, "hours spent on social media" might get a negative weight.

Making a prediction with two inputs

A student studied 5 hours and slept 6 hours:

score = 8 × 5 + 3 × 6
      = 40 + 18
      = 58

Bias: the starting value

Our rule still has a small problem. What if a student studied 0 hours and slept 0 hours?

score = 8 × 0 + 3 × 0 = 0

The rule says the score must be exactly 0. But maybe every student gets at least 10 points just for writing their name and guessing a few answers. Our rule has no way to say that. Every part of it is attached to an input, so with no input, there is no score.

The fix is to add one more blank that stands on its own:

score = w1 × study_hours + w2 × sleep_hours + b

This new number, b, is called the bias.

What a bias means

  • A bias is added, not multiplied.
  • It is not attached to any input.
  • It is the starting value of the output, before any input has a say. The weights then add to or take away from this starting point.

Training finds the bias, just like it finds the weights. Suppose training finds b = 10. Now take the same student, who studied 5 hours and slept 6 hours:

score = 8 × 5 + 3 × 6 + 10
      = 40 + 18 + 10
      = 68

It's easiest to see with one input. Picture the rule score = 8 × hours + 10 as a line on a chart. The bias is where the line starts, at 0 hours. The weight is how steeply it climbs.

Two charts of exam score against hours studied. The left chart shows the trained rule score = 10 × hours as a line through the points at 2, 5 and 8 hours, with a hollow point at 6 hours and 60 points for the new student's prediction. The right chart illustrates score = 8 × hours + 10: the line starts at a height of 10 at zero hours, which is the bias, and climbs 8 points for every extra hour, which is the weight.

A note on the word. In machine learning, "bias" is the technical name for this added number. Here, it has nothing to do with unfairness or prejudice. Models can be unfair, though. The last post in this series comes back to fairness.

Parameters: all the learned numbers

We now have two kinds of learned numbers. Together, they share one name: parameters.

TermWhat it isWhat it does
WeightA learned number that is multiplied with an inputControls how much that input matters
BiasA learned number that is added at the endSets the starting value
ParametersAll the learned numbers together (weights + biases)Everything that training finds

The exam model score = w1 × study + w2 × sleep + b has 3 parameters: w1, w2 and b.

A common shortcut. People often say "weights" when they mean all of a model's parameters. When a company "releases a model's weights", it has published all of the model's learned numbers.

An analogy: the mixing board

Picture a sound mixing board in a music studio, covered in knobs. Sound goes in. Each knob shapes it a little. The final sound comes out.

  • At first, the knobs are set at random, and the music sounds terrible.
  • A sound engineer listens, then turns each knob a little. Then listens again, and turns them again.
  • After many rounds, the music sounds right.

In this picture:

  • Each knob's position is a parameter.
  • The engineer turning the knobs is training.
  • The board itself is the model's structure: which knobs exist, and how they're connected.

Take the same board and set the knobs differently, and you get a completely different sound. In the same way, one model structure with different parameter values is a completely different model.

Why big AI models are called "big"

Our exam model has 3 parameters. The large models behind modern chatbots use the same idea, but they have billions of parameters. When you hear "an 8-billion-parameter model", it means the model holds 8 billion learned numbers.

Why so many? More parameters let a model capture more complicated patterns, such as the patterns of human language.

But there's a catch. More parameters only help if there is enough data to set them well. Post 4 of this series explains what goes wrong when there isn't.

New words in this post

WordMeaning
Machine learningLearning rules from examples, instead of writing them by hand
Supervised learningLearning from examples that come with correct answers
Unsupervised learningLearning from examples without answers, by finding structure such as groups
Reinforcement learningLearning by trial and error, from rewards and penalties
TrainingFinding good values for a model's unknown numbers, using examples
Prediction (inference)Using a trained model on a new input
DatasetA collection of examples
ExampleOne row in the dataset
Feature (input)One piece of information given to the model
Label (output, target)The correct answer for an example
ModelA rule with blanks, plus the numbers training found for them
WeightA learned number multiplied with an input; how much that input matters
BiasA learned number added at the end; the starting value
ParametersAll the learned numbers together: weights and biases

Recap

  • Machine learning means learning rules from examples, instead of writing the rules by hand.
  • Every model has two phases. Training learns from examples. Prediction uses what was learned on new inputs.
  • A model is a rule with blanks. Training fills in the blanks. Prediction uses the filled-in rule.
  • A weight is multiplied with an input. It shows how much that input matters.
  • A bias is added at the end. It sets the starting value, before any input has a say.
  • Weights and biases together are the parameters. Big models have billions of them.

Next up: we filled in the blank by trying 3, 7 and 10 by hand. A real model has millions of blanks, so it can't do that. How Does a Model Learn From Its Mistakes? shows how training finds the numbers on its own.