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 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 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.
Next month's rent
The label is an amount in rupees: regression.
Drills
Answer fast — trust the rule.
Predicting a flat's monthly rent is:
Predicting whether a tenant will pay late (yes or no) is:
What makes a task supervised?
Using size only, k-NN with k = 2 predicts rent for a new 55 m² flat. What does it predict?
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.
