Course 2 · Machine Learning Basics · about 15 min
Rules in, or rules out?
By the end of this course you can tell the main types of machine learning apart, explain why models overfit, and pick a sensible first algorithm.

Machine learning pays off when the rules are too messy to write by hand. Nobody can write a rule for "what a cat looks like", but a model can learn it from thousands of labelled photos.
Try itYou are the algorithm
Here are six labelled examples. Study them, then label the three new fruits.
| Weight | Skin | Label |
|---|---|---|
| 150 g | smooth | Apple |
| 180 g | smooth | Apple |
| 140 g | smooth | Apple |
| 170 g | bumpy | Orange |
| 230 g | bumpy | Orange |
| 190 g | bumpy | Orange |
You just learned from labelled examples. That is exactly what a machine learning model does, only with millions of examples and many more features.
CheckIn machine learning, what does the computer produce?
Step 2
Learning with and without answers
Supervised learning uses labelled data: every example comes with the right answer. It handles two kinds of task:
- Classification: predict a category. Spam or not spam? Cat or dog?
- Regression: predict a number. What will this house sell for?
Unsupervised learning gets data with no answers. It looks for structure on its own. The most common task is clustering: grouping similar things together, like customers who shop in similar ways.
Try itWhich task is it?
CheckYou have customer data with no labels and want to find natural groups. Which type of learning is that?
Step 3
From data to a working model
Every machine learning project follows roughly the same workflow. One step matters more than beginners expect: you hide part of your data from the model while it trains. That hidden part is the test set.
Think of an exam. If students saw the exact questions in advance, a perfect score proves nothing. The test set gives the model questions it has never seen, so its score tells you how it will do in the real world.
Try itPut the workflow in order
Tap the first step, then the next one.
CheckWhy keep a test set that the model never trains on?
Step 4
Too simple, too clever
A model can fail in two opposite ways:
- Underfitting: the model is too simple to catch the pattern. It does badly on training data and on new data.
- Overfitting: the model is so flexible it memorises the training data, noise and all. It looks brilliant in training and disappoints on new data.
Think of two students facing new exam questions. One memorised last year's answers and is lost. The other learned the ideas behind them and can work out anything new. You want your model to be the second student.

Try itFind the sweet spot
Turn up the model's complexity and watch both scores. Which level would you ship?
Leo Breiman, a Berkeley statistician, introduced random forests in 2001. Instead of one very flexible model, they combine many simple decision trees, which makes overfitting much less likely.
CheckA model scores 99% on training data and 70% on new data. What is going on?
Step 5
Your first algorithms
There are hundreds of algorithms, but three cover most beginner projects:
- Linear regression draws the best straight line through your data to predict a number, like rent from flat size.
- Decision tree asks a series of yes/no questions to reach a category. You can read and explain every decision it makes.
- k-means splits unlabelled data into k groups of similar items. You choose k.
Start simple. A simple model is quick to train, easy to explain, and gives you a baseline that any fancier model has to beat.
Try itPick the algorithm
Andrew Ng, who co-founded Google Brain and Coursera, taught machine learning to millions online. His standing advice: get a simple version working quickly, then improve it based on where it fails.
CheckWhy start with a simple algorithm?
Step 6 · Recap
What you learned
- Machine learning turns data plus answers into rules, called a model.
- Supervised learning uses labelled data for classification (categories) and regression (numbers). Unsupervised learning finds structure, such as clusters, without labels.
- Always judge a model on a test set it never saw during training.
- Underfitting is too simple, overfitting is memorising. Aim for the best score on new data.
- Start with a simple algorithm as your baseline.
Quick reviewThree questions from memory. No scrolling back.
Want to try this for real? scikit-learn, a free Python library, has all three algorithms from this course built in. When you're ready, mark the course complete below.