Neural Networks (Supervised Learning)
Supervised learning — someone must have looked and labeled things beforehand. That person is usually underpaid.
Neural Networks (Supervised Learning)
Analogy:
Definition:
How It Works
This interactive demonstration shows supervised learning in action. You provide labeled examples (clues vs. red herrings), and the neural network learns to classify new evidence. The system uses backpropagation to adjust weights and improve its decision-making over time.
Important Parameters
- Learning Rate:Controls how quickly the network adapts to new information. Higher values learn faster but may overshoot optimal solutions.
- Training Speed:Determines how many learning steps per second are executed during automatic training. Adjust to observe learning patterns at different speeds.
- Evidence Types:Three categories: Clues (genuine evidence), Red Herrings (misleading clues), and Uncertain (unlabeled data for testing predictions).
Visualization Elements
The demo offers multiple ways to understand how the neural network makes decisions and learns from your data.
- Data Points:Blue circles represent clues, red circles are red herrings, and gray circles show uncertain evidence with prediction borders.
- Decision Boundary:The colored regions show where the network would classify evidence as clues (blue) or red herrings (red), with opacity indicating confidence.
- Neural Network:Visual representation of the 2-3-1 network architecture showing nodes, connections, and real-time weight updates during training.
Tips for Effective Training
- Start with some clear examples in each category to establish basic patterns.
- Add uncertain points to test the network's predictions on unlabeled data.
- Watch the accuracy indicator - it should improve as you add more diverse training examples.
- Experiment with different learning rates to see how they affect convergence speed and stability.
Interactive Sharlock Helmes Training Ground
Help Sharlock Helmes learn to distinguish genuine clues from red herrings by training a neural network. Click on the canvas to add data points and watch how the network learns from your examples. The visualization below shows how Sharlock's artificial neural network processes evidence: input neurons receive coordinates, hidden neurons analyze patterns, and the output neuron determines whether a piece of evidence is a clue or a red herring from Dr. Moriarty.
What you see on the investigation field
Here Sharlock Helmes learns to tell real clues from red herrings — not from fixed rules, but from known examples. Here is what the picture shows.
- What you see
- A square investigation field with points in two classes: blue clues and red herrings. The background is filled as a coloured area and splits the field into two regions — one blue, one red. Where blue turns into red, the dividing line runs. Next to it, a small diagram shows the neural network that makes this split.
- What happens
- From a few points with a known answer the model draws a first rough border. With every training step the coloured area shifts, until the line cleanly separates the blue points from the red ones. The more examples you give, the sharper and better-fitting the transition between the colours becomes.
- What you can do
- Pick an evidence type at the top and click to place new points on the field. Train in single steps or automatically, adjust the learning rate and speed, or load a ready-made case from Sharlock's case file. Reset clears the field.
- What to watch for
- Supervised learning means drawing a rule from known examples that come with an answer. Watch that the final border also sorts new, not-yet-placed points correctly — not just the ones it learned from.
Sharlock's Detection Laboratory
Evidence Collection
Learning Rate: 0.80
Training Speed: 2 Steps/Second
Sharlock's Neural Deduction Network
Supervised Learning Explained
Learning with a Teacher
Supervised Learning is like learning with a teacher: The model receives labeled training data - examples with the correct answer. It learns to map inputs (features) to outputs (labels) by recognizing patterns in the training data.
Training occurs iteratively: The model makes predictions, compares them with the true labels, calculates the error, and adjusts its parameters to minimize the error. This process repeats until the model makes good predictions.
Classification vs. Regression
Classification: Predicting categories (e.g. spam/not-spam, cat/dog). Regression: Predicting continuous values (e.g. house prices, temperature).
Advantages
- Precise predictions: Very accurate with good training data
- Well understood: Established methods and best practices
- Measurable performance: Clear metrics (Accuracy, F1-Score, etc.)
- Broad applicability: Works for many problem types
Challenges
Requires many labeled data - labeling is expensive and time-consuming. Overfitting (too good adaptation to training data) and underfitting (too simple models) are common problems. Data quality is crucial.
Practical Applications
Image and speech recognition, spam filters, medical diagnosis, credit risk assessment, stock price prediction, recommendation systems, and autonomous driving.
Try the demo! Train a model and see how it learns from examples.
1
# Supervised Learning Algorithm
2
function train_model(data, labels):
3
# Main function: Learns patterns from labeled data
4
X, y = load_data() # Features and target values
5
X_train, X_test, y_train, y_test = split_data(80/20)
6
7
# Initialize model
8
model = create_neural_network(layers=[100, 50, 10])
9
learning_rate = 0.001, batch_size = 32, epochs = 100
10
11
for each epoch in epochs:
12
# One epoch = One pass through all training data
13
for each batch in training_data:
14
# Forward pass: Make predictions
15
input = batch.features
16
predictions = model.forward(input)
17
18
# Calculate loss: How wrong were we?
19
loss = calculate_error(predictions, batch.labels)
20
21
# Backward pass: Learn from mistakes
22
gradients = calculate_gradients(loss)
23
model.update_weights(gradients, learning_rate)
24
25
# Validation: How good are we?
26
val_predictions = model.predict(X_val)
27
accuracy = calculate_accuracy(val_predictions, y_val)
28
29
if accuracy > best_accuracy:
30
save_model('best_model.pkl')
31
32
# Final testing on unseen data
33
test_accuracy = test_model(X_test, y_test)
34
return model, test_accuracy
📊 Prepare Data
Load labeled data: inputs (X) and correct answers (y). Split into training (80%) and test data (20%) for later evaluation.
X, y = load_data() # Features and target values
X_train, X_test, y_train, y_test = split_data(80/20)
💾 Data Collection
Gather labeled examples: images with categories, texts with sentiment, numbers with predictions. Data quality determines success!
🔧 Preprocessing
Prepare data: Normalization (0-1 scaling), fill missing values, categories to numbers. Clean data = better learning.
🎓 Training
Iterative learning: Show examples, make predictions, calculate errors, adjust. Repeat hundreds of times until model is good.
📋 Validation
Continuous checking during training. Prevents overfitting (memorization). Stop early if validation gets worse.
🚀 Deployment
Trained model in production: Predict new, unseen data. Monitor performance and retrain if needed.
Supervised Learning Quiz
What is the main goal of supervised learning?
1. What is the main goal of supervised learning?
- ☐ A) Find patterns in unknown data
- ☐ B) Make predictions based on known examples
- ☐ C) Cluster data without target specification
- ☐ D) Let algorithms develop themselves
2. What kind of data does supervised learning require?
- ☐ A) Only input data
- ☐ B) Only output data
- ☐ C) Input and target output data (labels)
- ☐ D) No specific data
3. What distinguishes classification from regression?
- ☐ A) Classification only works with numbers
- ☐ B) Regression predicts categories, classification continuous values
- ☐ C) Classification predicts categories, regression continuous values
- ☐ D) There is no difference
4. You train a model with 1000 cat images and 10 dog images. What will happen?
- ☐ A) The model will work perfectly
- ☐ B) The model will classify almost everything as cat
- ☐ C) The model will guess randomly
- ☐ D) The model will only recognize dogs
5. Why is it called 'supervised' learning?
- ☐ A) Because a human must watch during training
- ☐ B) Because we provide the correct answers (labels)
- ☐ C) Because the computer is supervised
- ☐ D) Because it is very slow
6. In the demo, you see that your trained model has 100% accuracy on training data, but only 60% on new test data. What happened?
- ☐ A) This is normal and desirable
- ☐ B) The model has overfitting - it memorized the training data
- ☐ C) The test data is faulty
- ☐ D) The model needs more training
Related Content
Article
The Spark: Activation Functions
The one small kink in the line without which neural networks wouldn't learn anything at all.
The AI Winters
Why artificial intelligence was written off multiple times without caring.
The Heart of Learning
How a neural network sends its errors home — and makes everything along the way a little better.
Bayes & Conditional Probability
Conditional probability: the tool that identifies statisticians — they calculate differently.
Bias & Data Quality
Bad data in, bad AI out — with the uncomfortable punchline that there is no "perfectly fair".
Measures of Central Tendency: Where Is the Middle?
Three ways to find the "center" of data — and the entertaining question of which one is being dishonest right now.
The Chain Rule: Differentiating Nested Functions
A high school math rule that made the AI revolution possible in the first place.
Computer Vision (CNNs): How Machines Learned to See
How machines learned to read images and could suddenly tell dogs from cats — most of the time.
Correlation vs. Causation
Why every statistician flinches when someone says "correlates with" and means "causes".
Generative Image Models (Diffusion)
How an algorithm learned to generate dogs from snowfall — with the patience of a monk.
Distributions: The Shape of Data
The shape of data explained — and why a bell curve is rarer than you think.
The Path to the Valley: Gradient Descent
How gradient descent finds the lowest point in a landscape with millions of hills — most of the time.
The Network
What the middle layers of a neural network learn — and can't explain to anyone.
The Machine's Knobs — Parameters vs. Hyperparameters
The fine line between "learned by the machine" and "guessed by you".
Learning with AI (Instead of Cheating)
How to use AI as a learning partner instead of a cheat sheet with internet access.
Linear & Logistic Regression
The mathematical foundation that every deep learning course only gets to after three hours.
How AI Measures Its Mistakes: Loss Functions
Loss functions are a model's pain threshold — without them, no learning.
Data Tables & Transformations (Matrices)
The 2D grid of numbers where every ML library primarily thinks.
Programming vs. Training
How programming changed when people stopped writing every rule themselves.
How Good Is Your Model? Metrics That Actually Matter
Evaluating models without self-deception — metrics that do more than just look good.
When the Model Memorizes (Overfitting)
How to notice that the model didn't learn but memorized.
Partial Derivatives & The Gradient
The gradient: the vector that every optimization follows — downhill, hopefully.
The Artificial Neuron
Frank Rosenblatt's 1958 idea that suddenly became relevant again 60 years later.
Probability & Expected Value
Expected value: the average of futures, weighted by probability.
Supervised Learning — Learning with a Teacher
Supervised Learning: the ML paradigm where someone diligently labeled things beforehand.
Tensors: The Language of GPUs
Tensors: the term that sounds more intimidating than the thing actually is.
Transfer Learning & Fine-Tuning
How to win over an AI model instead of raising it from scratch — invaluable from the start.
Spaces and Directions (Vectors)
Why AI constantly works with arrows in n-dimensional space.
Demo
Decision Tree
Interactive decision-tree demo: set points, tune depth, watch splits appear live and experience overfitting.
Gradient Descent
Interactive demo to understand gradient descent: click a starting point on the loss landscape, watch the algorithm roll into the valley, and experiment with learning rate and optimizers.
K-Means Clustering
Interactive demo of the K-Means clustering algorithm with Dr. Elana Vasquiz
Naive Bayes (Classification)
Learn about the probabilistic classifier that detects spam emails
Neural Network Playground
Click layers and neurons together, choose a dataset and activation function, and watch the network learn to separate the data in real time.
Perceptron (Neural Networks)
Discover the first artificial neuron - the Big Bang of machine learning from 1957.
Q-Learning
Interactive demonstration of the Q-Learning algorithm with an intelligent agent in the Temple of Learning