Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 8: Classification

Classification: how a machine assigns an object to a class

Regression predicts a number. But often you need to predict a category: spam or not spam, sick or healthy, will the customer churn or stay. That is classification. Before counting errors, let's understand the principle itself β€” how a machine decides which class an object belongs to at all. Move the sliders and watch the line divide the classes.

feature 1: share of links β†’feature 2: "urgent/money"
● spam● not spamβ—‹ errorErrors: 1 of 20

Tune the slope and the shift so the line separates the classes with the fewest errors. That is what a classifier does β€” searches for a hyperplane in feature space.

To a model, any object is a set of numeric features. An email is described by, say, two features: the share of links in the text (horizontal) and how many words like "urgent", "money", "prize" it contains (vertical). Each point is one email. Teal β€” spam, gray β€” regular: you can see the spam is shifted up and to the right.

What it means

Picking good features is half the battle. For an email it is the share of links and the "spam words"; for customer churn β€” recency of the last purchase, visit frequency, average order value; for anti-fraud β€” amount, time, geography of the transaction. A model is exactly as strong as the features it was given are informative.

The threshold is a separate knob, turned after training, to match the cost of errors. The same model with different thresholds behaves as a "cautious" or a "picky" filter.

Where it shows up

Classifiers are everywhere: spam filters, bank anti-fraud, medical diagnostics, credit scoring, content moderation, "will buy / won't buy" recommendations. Everywhere the object is described by features, and the model draws a boundary.

Modern neural networks are more intricate than a linear boundary, but the principle holds: features in, class scores out, and the decision comes from a threshold.

Definitions
Classification
predicting a category (a class), not a number: spam / not spam, sick / healthy, churn / stay.
Feature
one measurable property of an object as a number. The model draws its conclusions from the set of features.
Hyperplane
the separating surface in feature space: a line in 2D, a plane in 3D, a hyperplane in many dimensions.
Score and threshold
the score β€” how much the object resembles the class; the threshold β€” the score cutoff above which the object is assigned to the class. The threshold is tuned to the task.
Next β†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words β€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel