Perceptron Learning Visualizer
PythonnumpyuvCLI
A Python implementation of the perceptron learning algorithm for educational purposes. Demonstrates how a single perceptron learns to approximate binary logic functions step by step.
Screenshots

Features
- Interactive command-line interface
- Support for any logical function using Python syntax
- Detailed step-by-step explanation of the learning process
- Visualizations of weights, biases, and thresholds
- Option to use simple perceptron or full perceptron with bias and learning rate
- Non-interactive demo mode showcasing multiple common logic functions
Run
uv sync
# Interactive mode
python script.py
# Demo mode (AND, OR, NOT, NAND, XOR)
python demo.py
# CLI
python cli.py --function "a and b" --detail detailed Sample Output
PERCEPTRON CONFIGURATION
+----------------+----------+
| Logic Function | a and b |
| Learning Rate | 1 |
| Threshold | 1.50 |
| Initial Bias | -0.1 |
+----------------+----------+
Final weights: [1.00, 1.00]
Final bias: -0.10
Accuracy: 100.0% Limitations
Single-layer perceptrons can only learn linearly separable functions:
- Can learn: AND, OR, NOT, NAND, NOR
- Cannot learn: XOR and other non-linearly separable functions
XOR demonstrates this limitation — the tool shows why it fails and explains multi-layer networks as the solution.