Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Types of Machine Learning  ›  Lesson

Supervised Learning

Supervised Learning 14 minSupervised learning trains on examples that come with the correct answer, and the type of answer decides the task: a number means regression, a category means classification.

Supervised Learning

Most ML in industry today is supervised: a spam filter trained on emails people marked as spam, a rent model trained on rents actually paid. The "supervisor" is the answer key that comes with every training example. Knowing this lets you name the task in one glance at the data.

The rule

Labelled examples in; numbers out means regression, categories out means classification.

Supervised learning needs every training example to carry its correct answer, the label. What kind of label it is decides the task:

  • Regression: the label is a number on a scale. Predicting monthly rent (14, 22, 26...) is regression. Errors are measured by how far off the number is, for example mean squared error.
  • Classification: the label is a category. "Rented within a week: yes or no" is binary classification; "studio, 1BHK or 2BHK" is multi-class. Classifiers often output a probability for each class, and errors are measured by how often, and how confidently, they pick the wrong class.

The same flats can support both. With a rent column you can do regression; add a "rented fast" column and you can do classification.

Common supervised methods you will meet later include linear regression, logistic regression (despite the name, a classifier), decision trees and k-nearest neighbours (k-NN). k-NN is the simplest to picture: to predict for a new flat, find the kk most similar training flats and average their rents (or take a vote for a category).

A new flat is 65 m². Using size alone, the two nearest flats are B (60 m²) and E (70 m²), both 5 away. Their rents are 22 and 22, so k-NN with k=2k = 2 predicts 22.

The shortcut

Look at the label column. No label column: not supervised. A number: regression. A category: classification. Do not be fooled by numbers that are really codes: a "flat type" column holding 1, 2 and 3 for studio, 1BHK and 2BHK is still a category.

Naming three agency tasksStep 1 of 3
  1. Next month's rent

    The label is an amount in rupees: regression.

Drills

Answer fast — trust the rule.

quick drill

Predicting a flat's monthly rent is:

quick drill

Predicting whether a tenant will pay late (yes or no) is:

quick drill

What makes a task supervised?

quick drill

Using size only, k-NN with k = 2 predicts rent for a new 55 m² flat. What does it predict?

quick drill

A "flat type" column stores 1, 2 and 3 for studio, 1BHK and 2BHK. Predicting it is:

Remember

  • Labelled examples in; numbers out means regression, categories out means classification.
  • Shortcut: read the label column first.
  • Trap: treating category codes as numbers.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainRead the label column

For the agency, describe one regression problem and one classification problem, say what the label is in each, and use k-nearest neighbours with k = 2 on size to predict the rent of a new 55 square metre flat from the five flats.