Machine Learning Playground: 10 Free Interactive Demos
Latest offerBook a free demo class: try a real session before you decide

Machine Learning Playground

Ten free interactive machine learning demos that run in your browser. Drag sliders, click to add data, and watch the algorithms learn.

How to use the playground

Nothing to install: every simulation runs in the browser on your phone or computer. They are simplified versions of the algorithms you build yourself, in Python, in our Machine Learning course. Tip: change one control at a time and watch what happens.

Simulation 1 · Supervised learning (regression)

Gradient descent: how a model learns a line

A linear model predicts y = w·x + b. Gradient descent starts from a poor guess and keeps nudging w and b downhill on the error (MSE) until the line fits the data.

Your lineBest fitError of each point
Error (MSE) at each step, log scale

Click the chart to add your own points.

Step
—
Slope w
—
Intercept b
—
Error (MSE)
—
Press Step or Run to start learning.

Try this

  • Press Run and watch the error curve fall.
  • Drag the learning rate to the far right (about 1.0): the line overshoots and the error explodes. A step that is too big is as bad as one that is too small.
  • Click far from the line to add an outlier and see how much it drags the fit.
Simulation 2 · Supervised learning (classification)

Logistic regression: learning a straight decision boundary

Logistic regression draws a line between two classes. Gradient descent adjusts the line to reduce the log-loss, and the colours show the predicted probability of Class B at every point.

Class A Class B
Dataset
Add by clicking:

Click the map to add a point of the selected class.

Step
—
Log-loss
—
Accuracy
—
Press Step or Run to start learning.

Try this

  • Press Run: the boundary rotates and slides until the two groups are separated.
  • On Overlapping data no straight line is perfect. Watch the accuracy settle below 100%.
  • Choose XOR: a single straight line can never separate it. This is why we need neural networks (see the neural network simulation below).
Simulation 3 · Supervised learning (classification)

k-nearest neighbours: classify by asking the neighbours

To label a new point, k-NN looks at the k closest training points and takes a vote. The shaded regions show what the model would predict at every spot on the map.

Class A Class B
Hover over the map to see the k nearest neighbours.
Dataset
Add by clicking:

Click or tap the map to add a point. On a computer, hover to see the k nearest neighbours.

Points (A / B)
—
Leave-one-out accuracy
—

Leave-one-out accuracy: each point is classified using all the other points, so it is an honest estimate rather than a memorised one.

Try this

  • Set k = 1: the boundary hugs every point (overfitting to noise).
  • On the Moons data raise k to 15: the boundary smooths out. Watch the accuracy number.
  • Switch to XOR. Why might k-NN handle it easily while a single straight-line model cannot?
Simulation 4 · Supervised learning (classification)

Decision trees: splitting the map with simple questions

A decision tree asks yes/no questions like “is x > 0.4?” and splits the map into boxes. Deeper trees make more splits and fit the training points more closely. Hollow points are test data the tree never saw.

Training point (solid)Test point (hollow)
Dataset

Solid points are training data; hollow points are test data. Press “New data” for a fresh sample.

Leaves
—
Training accuracy
—
Test accuracy
—

Try this

  • Set the depth to 1: a single split gives a simple, rough boundary.
  • Raise the depth to 8 on Moons: training accuracy reaches 100% but test accuracy stops improving or falls. The tree has memorised the training set.
  • Try XOR: a tree needs a few levels of splits (depth 4 or 5) to solve it, while logistic regression never can.
Simulation 5 · Deep learning

Neural network playground: learning curved boundaries

A neural network stacks layers of neurons, each a weighted sum plus a non-linear activation. Training (backpropagation) tunes the weights so the colours separate the two classes, even for curved shapes like circles and moons.

Class A Class B
Dataset
Activation function

You can change the sliders while it trains. Changing layers, neurons or activation restarts the network.

Epoch
—
Loss
—
Accuracy
—
Architecture
—
Press Run to train the network.

Try this

  • Choose Circles, keep 1 layer × 4 neurons and press Run: the network carves out a ring.
  • Try XOR with 1 layer and only 2 neurons, then add neurons. More capacity solves harder shapes.
  • A learning rate that is too high makes the loss bounce around; too low and learning crawls. Compare with the gradient descent simulation.
Simulation 6 · Unsupervised learning (clustering)

K-means: finding groups without labels

K-means has no answer key. It repeats two moves: assign every point to its nearest centroid, then move each centroid to the middle of its points, until nothing changes.

Diamonds are centroids. Faint lines join each point to its centroid.

Click the chart to add points.

Iteration
—
Total distance (inertia)
—
Next move
—
Press Step or Run. Each click is one half-iteration.

Try this

  • Set k to the number of blobs you can see, press Run, and watch the centroids settle.
  • Press New start a few times on the same data: random starting positions can give different, even worse, groupings.
  • Set k too high or too low and compare the total distance.
Simulation 7 · Unsupervised learning (dimensionality reduction)

PCA: finding the direction with the most information

Principal Component Analysis rotates the axes to line up with the direction in which the data varies most. Squashing the data onto that first axis keeps as much variation as possible while using one number instead of two.

Your axisPC1PC2

Click the chart to add a point (try an outlier).

Variance kept by your axis
—
Variance kept by PC1
—
Variance kept by PC2
—

Try this

  • Rotate your own axis slowly. The variance it keeps peaks exactly when it lines up with PC1.
  • Lower the elongation toward 0: the cloud becomes round, and PC1 and PC2 keep almost equal variance. Reducing dimensions then gains little.
  • Click far away to add an outlier and see how much it tilts PC1.
Simulation 8 · Model evaluation

Overfitting: when a model memorises instead of learning

The dots follow a sine wave plus random noise. A higher-degree polynomial can bend more, but a model that fits the training dots perfectly can still do badly on new data (the hollow dots).

Training pointsTest points (hidden from the model)Fitted curveTrue curve
Training errorTest errorNoise floor
Error vs. degree (log scale). Training error keeps falling; test error forms a U-shape.
Training error (MSE)
—
Test error (MSE)
—

Try this

  • Degree 1: a straight line cannot follow the wave (underfitting). Both errors are high.
  • Raise the degree to 10–12 with 15 points: training error drops but test error shoots up. That is overfitting.
  • At degree 12, raise the regularisation or add more training points: the curve calms down.
Simulation 9 · Model evaluation

Train/test split and cross-validation

A single random train/test split can be lucky or unlucky. Cross-validation (k-fold) splits the data into k folds, tests on each fold in turn and averages the scores, giving a steadier estimate. Here a k-NN model (k = 5) classifies a moons dataset.

Single split: lowest to highest accuracy
—
Cross-validation: mean ± spread
—

Try this

  • Press “Repeat random split ×20” a few times: the accuracy from one split varies a lot, especially with a small test share.
  • Run k-fold CV: each fold gives a different score, but their average is a steadier estimate of real performance.
  • Use 10 folds and compare the spread. Each model trains on more data, but you do more training runs.
Simulation 10 · Model evaluation

Confusion matrix, precision and recall

A classifier gives each case a score. You choose a threshold: scores above it are predicted positive. Moving the threshold trades false alarms (false positives) against missed cases (false negatives). Think of a disease test: positive = sick.

Negative casesPositive casesThreshold
Distribution of scores
ROC curve: true-positive rate vs false-positive rate

You can also click the top chart to set the threshold.

Predicted positivePredicted negative
Actually positiveTrue positive (TP)0False negative (FN)0
Actually negativeFalse positive (FP)0True negative (TN)0
Accuracy
—
Precision
—
Recall
—
F1 score
—
AUC
—

Try this

  • Lower the threshold to 0.2: recall rises (few sick people are missed) but precision falls (more false alarms).
  • Raise the threshold to 0.8: the opposite happens.
  • Set positive cases to 5% and the threshold to 1.0: the model predicts “negative” for everyone, yet accuracy is still about 95% while recall is 0. This is why accuracy alone can mislead.

Want more demos?

Explore the Deep Learning Playground: six more demos on activation functions, optimizers, convolution filters, SVM, random forests and reinforcement learning.

Open the Deep Learning Playground →

Want to build these models yourself?

In our Machine Learning course in Bathinda you code each of these algorithms in Python, then apply them to a real dataset.