Perceptron & Linear Classification

The Foundation of All Neural Networks

Difficulty
Beginner
Duration
10-15 minutes
Prerequisites
Basic graphs

What You'll Discover

From raw weather data to a trained AI predictor in 10 clear steps

Binary Classification

Learn to sort data into two categories - predicting rain vs sunny using humidity and temperature measurements.

Perceptron Architecture

Meet the simplest neural network - a single neuron with inputs, weights, bias, and a decision rule.

Learning from Mistakes

Watch the perceptron adjust its weights every time it makes a wrong prediction, gradually improving its accuracy.

Training & Convergence

See how epochs of training lead to convergence - stable weights that correctly classify all data points.

Generalization

Test the trained model on new, unseen data - the real measure of whether it learned a rule, not just memorized answers.

Foundation for Neural Networks

Understand how this simple building block scales up to power modern AI systems with multiple layers.

Key Concepts Covered

Binary Classification

Sorting data into two categories using a simple decision rule

Decision Boundaries

The line that separates different classes in a scatter plot

Perceptron Learning Rule

How the algorithm adjusts weights when it makes mistakes

Epochs & Training

Iterating through all data points to gradually improve accuracy

Convergence

When the perceptron finds stable weights that classify all data correctly

Generalization

Testing the trained model on new, unseen data to verify real learning

Step
1/ 11

Can We Predict Rain?

Imagine you want to predict the weather using just two measurements: humidity and temperature. You have 6 days of historical data.

Can you spot the pattern? Rainy days tend to have high humidity and cooler temperatures. Sunny days tend to have lower humidity and warmer temperatures.

Our Dataset:

  • Day 1: 85% humidity, 18°C → Rain
  • Day 2: 75% humidity, 16°C → Rain
  • Day 3: 65% humidity, 22°C → Rain
  • Day 4: 40% humidity, 30°C → Sunny
  • Day 5: 45% humidity, 28°C → Sunny
  • Day 6: 55% humidity, 25°C → Sunny

The Goal: Teach the simplest possible AI (a perceptron) to find this pattern automatically.

Can you see the two clusters on the scatter plot? Blue dots (rainy) tend to be in the upper-left region, yellow dots (sunny) in the lower-right.

Weather Dataset (6 Days)

DayHumidityTemperatureWeather
Day 185%18°C🌧️ Rain
Day 275%16°C🌧️ Rain
Day 365%22°C🌧️ Rain
Day 440%30°C☀️ Sunny
Day 545%28°C☀️ Sunny
Day 655%25°C☀️ Sunny

Weather Data: Can You See the Pattern?

Humidity (normalized)Temperature (normalized)0.000.000.250.250.500.500.750.751.001.00Weather Data Classification
Rain (Class 1)
Sunny (Class 0)