Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Blog › Explore in 3D

25 November 2026 · 3 min readInteractive 3D

A group of colourful blocks arranged in a grid
Photo by Google DeepMind on Unsplash

How does a spam filter draw a line?

Sorting things into two groups can be as simple as placing a flat wall between them. Move the wall yourself and watch the score.

A spam filter has to answer one question about each email: spam or not? One of the simplest ways to answer is to describe each email with a few numbers and then place a flat wall in that space. Emails on one side are spam; on the other, not.

Turn, tilt and slide the wall. Dots on the wrong side swell up.

Turn, tilt, slide

A flat wall in 3D needs only a few numbers: which way it faces and where it sits. In the model those are the turn, the tilt and the slide. A linear classifier is just those numbers, and training means finding the values that put the most dots on the right side.

Where the numbers come from

  • How many times words like “free” or “winner” appear.
  • How many links the email contains.
  • Whether the sender is in your contacts.

Real filters use hundreds of such numbers, so the wall lives in hundreds of dimensions. The idea is identical.

Try to get 100%. If the two clouds overlap at all, you cannot: some emails really do look like spam. That is why no filter is perfect.

A worked example

A filter looks at two numbers for each email: how many times “free” appears (f) and how many links it has (l). It calls an email spam if 2f + l − 6 > 0.

  1. Email A: f = 3, l = 2 → 6 + 2 − 6 = 2 > 0 → spam
  2. Email B: f = 0, l = 4 → 0 + 4 − 6 = −2 → not spam
  3. Email C: f = 2, l = 2 → 4 + 2 − 6 = 0 → right on the line

The line 2f + l = 6 divides the plane in two. With three features it becomes a flat plane in 3D, and with more features a “hyperplane” we cannot draw but can still compute with.

Measuring how well it works

Accuracy is the share of emails classified correctly, but it can mislead. If 99% of emails are not spam, a filter that never flags anything is 99% accurate and useless. Precision (of the emails flagged, how many really are spam) and recall (of the real spam, how much was caught) tell the full story.

Learning the line

The weights 2, 1 and −6 are not chosen by hand. A learning method such as logistic regression starts with random weights and nudges the line every time it misclassifies an example, until mistakes are as few as possible.

Real spam filters use thousands of features, but many still rely on a linear model at their core because it is fast and easy to check.

Logistic regression

Instead of a hard yes or no, logistic regression passes the score through a sigmoid to get a probability. A score of 0 gives 50%, a score of 3 gives about 95%. You can then choose the threshold: a hospital might flag anything above 20% for a second look, while a spam filter might wait for 90%.

Glossary

  • Decision boundary: where the score is exactly zero.
  • Threshold: the cut-off for saying yes.
  • False positive: wrongly saying yes.
  • False negative: wrongly saying no.

Try these yourself

  1. Q1. Rule 2f + l − 6 > 0: f = 1, l = 5? 2 + 5 − 6 = 1, spam
  2. Q2. 90 spam flagged, 10 wrongly flagged: precision 90%
  3. Q3. 100 real spam, 80 caught: recall 80%
  4. Q4. With 3 features, the boundary is a … plane

In short

A linear classifier scores each example with weights and checks which side of a line or plane it falls on. Judge it by precision and recall, not accuracy alone.

Keep going

  • Glossary: classifier
  • Lesson: measuring a classifier
  • When a straight line is not enough
  • What is supervised learning?
  • What is weight?
  • What is the normal distribution? Correlation in 3D
  • What is conditional probability? A visual guide

Read and listen in

Indian languages

World languages

Questions people ask

What is a linear classifier?

A model that separates two classes with a straight line, flat plane or hyperplane, deciding by which side a point falls on.

How does a spam filter decide?

It scores each email from its features with learned weights and marks it as spam if the score is above a threshold.

What is the difference between precision and recall?

Precision is how many flagged items were truly positive; recall is how many true positives were found.

More articles

  • What if a straight line cannot separate data?
  • What is the normal distribution? Correlation in 3D
  • What is conditional probability? A visual guide