Skip to content
CoreSource checked

Perceptron

Learns a linear binary classifier by updating weights after mistakes.

Quick Facts

Compact metadata for implementation and discovery.

Category
Machine Learning
Difficulty
Beginner
Family
Linear Classifier
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
3
Code example
Ready
Visualization
Ready

Overview

The Perceptron predicts from a linear score and adjusts weights toward misclassified positive examples and away from misclassified negative examples.

Core Concepts

linear scoremistake-driven updatedecision boundaryonline learning

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(d)

Average

O(e n d)

Worst

O(e n d)

Space

O(d)

When to Use

  • Use when a simple online linear classifier is enough.
  • Use when introductory classification is a central requirement.

When Not to Use

  • Avoid when classes are not close to linearly separable and nonlinear features are unavailable.
  • Avoid when the data size, labels, or feature assumptions do not match the model.

What It Does

  • Computes a linear score
  • Predicts a binary label
  • Updates weights on mistakes

Use Cases

  • Introductory classification
  • Online linear learning
  • Linearly separable data

Inputs

  • Feature vectors
  • Binary labels
  • Learning rate

Outputs

  • Linear classifier weights

Key Formulas (1)

Perceptron update

weightsnext = weights + learningrate · label · features
weights_next = weights + learning_rate * label * features

Updates weights when the current example is misclassified.

Pseudocode

  1. 1.Initialize weights to zero or small values
  2. 2.For each training example, compute the sign of the score
  3. 3.If the prediction is wrong, update weights toward the correct label
  4. 4.Repeat for several passes

Canonical Example

Input
point = [2, 1], label = +1, prediction = -1
Output
weights increase toward [2, 1]
Explanation
A mistake causes the classifier to move its boundary toward the correct side.

Implementation Notes

  • Shuffle examples between epochs to reduce ordering effects.
  • Split data for validation and keep preprocessing identical between training and inference.
  • Keep a tiny example with known output beside the implementation.
  • Treat examples as educational sketches; production models need validation, monitoring, and domain checks.

Common Pitfalls

  • Using labels 0 and 1 directly can break the usual update rule, which expects signs such as -1 and +1.
  • Evaluating only on training data can hide overfitting and poor generalization.
  • Not defining boundary, empty, or degenerate inputs before implementation.
  • Data leakage, unscaled features, and validation on training data can make results look better than they are.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show a separating line shifting after each misclassified point.

Perceptron mechanism walkthrough step 1 of 4x₀x₁x₂x*
Step 1 of 4: Initialize weights to zero or small values
model-training

Notes

Perceptron operates in O(e n d) time and O(d) space within the Linear Classifier family. Key governing relation: weights_next = weights + learning_rate * label * features. Often compared with Logistic Regression and Multilayer Perceptron.

Sources (1)

What each reference supports for this entry.

Deep Learning Book

Book

Deep learning reference for neural model, loss, or training concepts in Perceptron.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Alternative toLinear Regression

Perceptron and linear regression both learn linear models, but target classification and regression respectively.

Prerequisite ofMultilayer Perceptron

Multilayer perceptrons stack neuron-like units beyond a single perceptron.

Tags

Machine LearningClassificationSupervised LearningNeural Networks