Skip to main content

Start here · no maths needed

What is machine learning?

A plain-language start in about 15 minutes. It covers the big idea, the two main kinds of learning, how a model trains, why we split data into train and test, and why we look at data first. At the end: exactly what this course teaches (supervised learning) and what it does not.

The full story · about 15 minutes

What is machine learning?

1 · The big idea

What machine learning is, in one sentence

Ordinary software follows rules a person wrote. Machine learning flips that: you show the computer many examples, and it works out the rules itself. Show it eight flat sales and it finds the rule 'price rises about ₹0.78 lakh for each extra square metre'. Show it a million emails marked spam or not, and it finds a rule for spotting spam.

Ordinary software against machine learning
Ordinary softwareMachine learning
Who writes the rule?A programmerThe computer, from examples
What do you give it?Rules and dataData (and often the answers)
What do you get?AnswersA rule you can reuse on new data
Good forClear, fixed rulesPatterns too complicated to write down

2 · Two main kinds

Supervised and unsupervised learning

The first question to ask is: do my examples come with the answer I want to predict? If yes, that is supervised learning. The answer is called the label, and the computer is supervised because it can compare its guess with the label. If no, that is unsupervised learning: the computer looks for structure, such as groups, with nothing to check against.

Supervised: every dot comes with its answer
4060801001205075100125Area (sq m)Price (₹ lakh)
  • Flats with known prices
  • Learned line
See the numbers behind this picture
Supervised: every dot comes with its answer
Area (sq m)Flats with known pricesLearned line
30–34.602
3540–
4544–
5556–
6558–
8076–
9584–
110101–
130110–
135–116.414
Unsupervised: the same flats with no answers
-1-0.500.51406080100120Area (sq m)
  • Group 0
  • Group 1
See the numbers behind this picture
Unsupervised: the same flats with no answers
Area (sq m)Group 0Group 1
350–
450–
550–
650–
800–
95–0
110–0
130–0
The same eight flats, learned two ways
import numpy as np

area  = np.array([35, 45, 55, 65, 80, 95, 110, 130.0])      # square metres
price = np.array([40, 44, 56, 58, 76, 84, 101, 110.0])      # ₹ lakh

# SUPERVISED: every row comes with the answer we want to predict (the label)
w, b = np.polyfit(area, price, 1)
print(f"supervised: learned 'price = {w:.2f} x area + {b:.1f}' from labelled sales")
print("            prediction for an unsold 75 sq m flat:", round(float(w * 75 + b), 1), "lakh")

# UNSUPERVISED: same flats, answers hidden. Can the computer still find structure?
rng = np.random.default_rng(0)
x = (area - area.mean()) / area.std()
centres = np.array([x.min(), x.max()])                       # start two groups at the extremes
for _ in range(10):
    group = np.argmin(abs(x[:, None] - centres[None, :]), axis=1)
    centres = np.array([x[group == k].mean() for k in (0, 1)])
print("unsupervised: found two groups of flats by size alone:")
for k in (0, 1):
    print(f"            group {k}: areas {area[group == k].astype(int).tolist()}")
print("no price was used, so there is nothing to 'check' the groups against")
supervised: learned 'price = 0.78 x area + 11.2' from labelled sales
            prediction for an unsold 75 sq m flat: 69.7 lakh
unsupervised: found two groups of flats by size alone:
            group 0: areas [35, 45, 55, 65, 80]
            group 1: areas [95, 110, 130]
no price was used, so there is nothing to 'check' the groups against
Edit and run this code in your browser

Live Python

The same eight flats, learned two ways

Runs in your browser on your device. Nothing you type is sent anywhere, and nothing here changes your saved progress.

Press Ctrl+Enter (⌘+Enter on Mac) to run. Tab moves focus to the next control, as usual; use spaces to indent.

Supervised, the computer learns 'price = 0.78 × area + 11.2' and predicts ₹69.7 lakh for an unsold 75 sq m flat. Unsupervised, it splits the flats into five smaller and three larger ones, with no way to say whether that split is 'right'.

Where each kind is used
KindQuestion it answersExamples
Supervised: regressionHow much?House price, delivery time, demand
Supervised: classificationWhich one?Spam or not, will this customer leave, loan default
Unsupervised: clusteringWhich belong together?Customer groups, similar articles
Unsupervised: dimensionality reductionWhat are the main directions of variation?Compressing many columns into a few

3 · How training happens

Measure the miss, nudge, repeat

Training is a loop with three moves. First, measure how wrong the current rule is, as a single number called the loss. Second, work out which way to nudge each adjustable number to make the loss smaller. Third, nudge them a little and go round again. That is what you watched in the demo on the home page.

  1. Start with a rule that knows nothing, for example 'always quote the average price'.
  2. Measure the average miss across all examples.
  3. Nudge the slope and the height in the direction that reduces the miss, by a small step.
  4. Repeat until the miss stops getting smaller.
The training loop, written out
import numpy as np

area  = np.array([35, 45, 55, 65, 80, 95, 110, 130.0])
price = np.array([40, 44, 56, 58, 76, 84, 101, 110.0])
a = area - area.mean()
w, level, rate_w, rate_l = 0.0, price.mean(), 0.00012, 0.06          # start from "always quote the average"

def avg_miss(w, level):
    return float(np.mean(np.abs(w * a + level - price)))

print(f"step   0: slope {w:.3f}  average miss {avg_miss(w, level):5.2f} lakh")
for step in range(1, 121):
    miss = w * a + level - price                  # 1. how wrong is the line right now?
    w     -= rate_w * np.mean(2 * miss * a)       # 2. nudge the slope so the squared miss falls
    level -= rate_l * np.mean(2 * miss)           # 3. nudge the height the same way
    if step in (1, 5, 10, 20, 40, 120):               # 4. repeat
        print(f"step {step:3d}: slope {w:.3f}  average miss {avg_miss(w, level):5.2f} lakh")
step   0: slope 0.000  average miss 21.62 lakh
step   1: slope 0.179  average miss 16.82 lakh
step   5: slope 0.567  average miss  6.37 lakh
step  10: slope 0.722  average miss  2.45 lakh
step  20: slope 0.775  average miss  2.45 lakh
step  40: slope 0.779  average miss  2.48 lakh
step 120: slope 0.779  average miss  2.48 lakh
Edit and run this code in your browser

Live Python

The training loop, written out

Runs in your browser on your device. Nothing you type is sent anywhere, and nothing here changes your saved progress.

Press Ctrl+Enter (⌘+Enter on Mac) to run. Tab moves focus to the next control, as usual; use spaces to indent.

Training is the miss getting smaller
5101520010203040Training stepAverage miss (₹ lakh)
See the numbers behind this picture
Training is the miss getting smaller
Training stepAverage miss
021.625
116.821
213.12
310.267
48.069
56.375
65.07
74.064
83.289
92.763
102.447
112.265
122.247
132.301
142.342
152.374
162.399
172.418
182.433
192.444
202.453
212.459
222.464
232.468
242.471
252.474
262.476
272.477
282.478
292.479
302.48
312.48
322.48
332.481
342.481
352.481
362.481
372.481
382.481
392.482

The miss falls from ₹21.62 lakh, when the model just quotes the average, to about ₹2.45 lakh within 10 steps, and then barely moves. The step size is deliberately small, because a step that is too big overshoots. Bigger models and more data need many more steps, but the loop is the same.

4 · Train and test

Never grade a model on the examples it studied

A model that has seen the answers can score perfectly by memorising them. What we want to know is how it does on examples it has not seen, because that is what happens in real life. So before training we split the data: most rows are the training set the model learns from, and a few are held back as the test set, used once at the end to judge it.

A flexible model aces what it studied and fails what it didn't
import numpy as np

area  = np.array([35, 45, 55, 65, 80, 95, 110, 130.0])
price = np.array([40, 44, 56, 58, 76, 84, 101, 110.0])
train, test = [0, 2, 3, 5, 6, 7], [1, 4]                  # hold two flats back; the model never sees them while learning
z = (area - 80) / 30
print("degree | training miss | miss on held-back flats")
for degree in [1, 2, 3, 5]:
    coef = np.polyfit(z[train], price[train], degree)
    miss = lambda idx: float(np.mean(np.abs(np.polyval(coef, z[idx]) - price[idx])))
    print(f"{degree:6d} | {miss(train):13.2f} | {miss(test):.2f}")
coef = np.polyfit(z[train], price[train], 5)
print("degree 5 prediction for a 100 sq m flat:", round(float(np.polyval(coef, (100 - 80) / 30)), 1), "lakh  (sales near 100 sq m were about 84 to 101)")
degree | training miss | miss on held-back flats
     1 |          2.34 | 2.58
     2 |          2.29 | 2.75
     3 |          2.03 | 2.46
     5 |          0.00 | 8.83
degree 5 prediction for a 100 sq m flat: 90.1 lakh  (sales near 100 sq m were about 84 to 101)
Edit and run this code in your browser

Live Python

A flexible model aces what it studied and fails what it didn't

Runs in your browser on your device. Nothing you type is sent anywhere, and nothing here changes your saved progress.

Press Ctrl+Enter (⌘+Enter on Mac) to run. Tab moves focus to the next control, as usual; use spaces to indent.

Why we hold some data back
0246812345Model flexibility (polynomial degree)Average miss (₹ lakh)
  • Training flats
  • Held-back flats
See the numbers behind this picture
Why we hold some data back
Model flexibility (polynomial degree)Training flatsHeld-back flats
12.342.58
22.292.75
32.032.46
508.83

A straight line misses the training flats by about ₹2.3 lakh and the held-back flats by ₹2.6 lakh, a fair estimate of real-life performance. The degree 5 curve has no miss at all on the training flats and a miss of ₹8.8 lakh on the held-back ones: it memorised. Its prediction for a 100 sq m flat is ₹90.1 lakh, too close to a lucky guess to trust. This is overfitting, and a held-back test set is how you catch it.

The three sets
SetUsed forRule
TrainingLearning the weightsThe model may study it freely
Validation (or cross-validation)Choosing between models and settingsUse it as often as you like
TestOne final honest scoreLook once, at the very end

5 · Look first

Explore and plot your data before modelling

Before fitting anything, spend ten minutes looking at the table. How many rows and columns? What are the typical values and the extremes? Which columns move together? Are there odd values? This is exploratory data analysis, and a few plots catch most problems that would otherwise silently ruin a model.

A ten-line look at a small table
import numpy as np

area  = np.array([35, 45, 55, 65, 80, 95, 110, 130.0])
price = np.array([40, 44, 56, 58, 76, 84, 101, 110.0])
age   = np.array([12, 3, 20, 8, 15, 2, 6, 25.0])           # a second column: years since construction
print("rows:", len(area), "| columns: area, age, price")
for name, col in [("area", area), ("age", age), ("price", price)]:
    q1, med, q3 = np.percentile(col, [25, 50, 75])
    print(f"{name:5s} min {col.min():6.1f}  median {med:6.1f}  max {col.max():6.1f}  mean {col.mean():6.1f}  std {col.std():5.1f}")
print("correlation with price: area", round(float(np.corrcoef(area, price)[0, 1]), 3), "| age", round(float(np.corrcoef(age, price)[0, 1]), 3))
z = (price - price.mean()) / price.std()
print("any price more than 2 std from the mean?", bool((abs(z) > 2).any()))
counts, edges = np.histogram(area, bins=4)
for c, lo, hi in zip(counts, edges[:-1], edges[1:]):
    print(f"area {lo:5.0f}-{hi:5.0f} | {'#' * int(c)}")
rows: 8 | columns: area, age, price
area  min   35.0  median   72.5  max  130.0  mean   76.9  std  30.9
age   min    2.0  median   10.0  max   25.0  mean   11.4  std   7.7
price min   40.0  median   67.0  max  110.0  mean   71.1  std  24.2
correlation with price: area 0.994 | age 0.26
any price more than 2 std from the mean? False
area    35-   59 | ###
area    59-   82 | ##
area    82-  106 | #
area   106-  130 | ##
Edit and run this code in your browser

Live Python

A ten-line look at a small table

Runs in your browser on your device. Nothing you type is sent anywhere, and nothing here changes your saved progress.

Press Ctrl+Enter (⌘+Enter on Mac) to run. Tab moves focus to the next control, as usual; use spaces to indent.

Look at the shape before you model
012335–5959–8282–106106–130Area band (sq m)Number of flats
See the numbers behind this picture
Look at the shape before you model
Area band (sq m)Flats
35–593
59–822
82–1061
106–1302

Price and area move almost together (correlation 0.994), while age is only weakly related (0.26), so area is the column to model first. No price is more than two standard deviations from the mean, so no obvious outliers. Four lines of text histogram already show the sizes are spread fairly evenly.

6 · Your map

Where to learn each piece in this course

Each idea and where to go next
You want to learn…Go to
What a model looks like as mathsMath: algebra and functions
How to read and chart dataPython: pandas and visualization
Why and how to split data without leakingPython: Data Preparation
Honest scores and the test setAlgorithms: Evaluation Foundations
Your first model, step by stepAlgorithms: Linear Regression
Which model to use whenAlgorithms: How to choose a model
How averages and uncertainty workMath: statistics and the normal curve

You do not need to read these in order. Pick whichever question you have, and every page links onward.

Check yourself

A model scores 99% on the data it trained on and 70% on new data. What is the most likely problem?

Check yourself

You have customer records with a column saying whether each customer left. Which kind of learning predicts that column?

Ready? Go back to the home page demo, or open the Linear Regression lessons to build the model you just watched.

What you will learn

Supervised machine learning, end to end.

Supervised learning means learning from examples whose answers are known, such as house prices or customers who left. It is the part of machine learning behind most real products, and the best place to build solid foundations.

  1. 01

    Explain why a model works

    Read the maths behind a prediction (functions, derivatives, probability, optimization) and say what the model is doing, not only which function to call.

  2. 02

    Write the Python for it

    From your first line of Python to NumPy, pandas, scikit-learn and your own small classes, with every code cell runnable in the browser.

  3. 03

    Prepare data without fooling yourself

    Split first, build a baseline, put preparation inside a pipeline and avoid leakage.

  4. 04

    Build and compare supervised models

    Regression and classification: linear and logistic regression, k-nearest neighbours, naive Bayes, decision trees, random forests, gradient boosting, SVMs and a first neural network.

  5. 05

    Judge the result honestly

    Choose a metric that matches the decision, use validation and a locked test set, and test whether a gain is real or luck.

  6. 06

    Take a problem from question to a shipped model

    Frame it, build it, evaluate it, package it and see how it is deployed, practised on House Price, Customer Churn and Titanic.

How the course gets you there

  1. Math: algebra, calculus, linear algebra, probability, statistics, optimization and 12 bridges to ML, including hypothesis tests.
  2. Python: six short beginner lessons, then Essentials, NumPy, pandas, visualization, data preparation and scikit-learn.
  3. Algorithms: 13 supervised paths with playbooks, a model-choice guide and an end-to-end workflow.
  4. Projects: three guided Kaggle-style projects on real public data.

Not on the roadmap yet

So you know exactly what you are signing up for. Everything else you might expect is under Coming next, below.

  • Reinforcement learning
  • Time-series forecasting
  • Running models at scale: monitoring, retraining and MLOps beyond a first deployment

Coming next

Where this path leads.

Planned modules, in the order that makes sense: natural language processing and computer vision both rest on deep learning, so it comes first. They are plans, not dates, and none of them is available yet. Until then, the lessons listed under each one are the best preparation.

  1. 01

    Unsupervised learningComing soon

    Finding structure when there are no answers: grouping similar customers, spotting unusual transactions, squeezing many columns into a few.

    You will be able to: Cluster with k-means, reduce dimensions with PCA, and judge whether the groups mean anything.

    Start preparing: Distance and norms · SVD · k-nearest neighbours

  2. 02

    Deep learning foundationsComing soon

    Neural networks with many layers, trained by backpropagation, built and debugged in code.

    You will be able to: Train a deeper network, read its learning curves and fix one that will not learn.

    Start preparing: Gradient descent · Neural networks (MLP) · Optimization

  3. 03

    Natural language processingComing soon

    Working with text: turning words into numbers, classifying messages, searching by meaning, and how language models work.

    You will be able to: Build a text classifier and explain what a language model is predicting.

    Start preparing: Naive Bayes · Logistic regression · Information and entropy

  4. 04

    Computer visionComing soon

    Learning from images: how a picture becomes numbers, convolutional networks, and checking what a model looks at.

    You will be able to: Train an image classifier and explain why it got a picture wrong.

    Start preparing: Linear algebra · Neural networks (MLP)

Build your first model: Linear Regression → · Math for machine learning · How to choose a model