About Classifier Playground
This classifier playground is free, needs no sign-up and runs in your browser, so your points are never uploaded. Choose from k-nearest neighbours, logistic regression and Gaussian naive Bayes, pick a two-dimensional dataset or tap the plot to draw your own points of up to three classes, and see the regions each model assigns to each class.
The plot is only half the story. A model that fits the points you can see is not necessarily good at points it has not seen. Switch to cross-validation and the tool splits your points into folds, trains on all but one, tests on the one held out, and shows the accuracy of every fold with its mean and spread.
Everything is written in plain code and runs on your device. That makes the playground a good place to build intuition: watch k = 1 carve jagged islands, see a straight logistic boundary fail on rings and succeed when you raise the polynomial degree, and see naive Bayes struggle with an XOR pattern.
How to use Classifier Playground
- Choose an algorithm: k-nearest neighbours, logistic regression or Gaussian naive Bayes.
- Load a dataset (blobs, moons, circles or XOR), or clear the points and tap the plot to add your own. Choose which class a tap adds.
- Set the algorithm's option: k for nearest neighbours, or the polynomial degree for logistic regression.
- Look at the coloured regions. Each cell takes the colour of the class the model predicts there.
- Switch the view to Cross-validation, choose the number of folds, and read the accuracy per fold and the mean.
- Compare algorithms and settings on the same data using the mean cross-validation accuracy, not the training accuracy.
Features
- Three classic classifiers written from scratch: kNN, softmax logistic regression and Gaussian naive Bayes.
- Decision-region canvas that scales to your screen and accepts taps to add points.
- Polynomial features of degree 1 to 3 for logistic regression, so it can learn curved boundaries.
- Five datasets, up to three classes and up to 800 points.
- k-fold cross-validation from 2 to 10 folds with a per-fold accuracy table, mean and standard deviation.
- Repeatable results: folds are shuffled with a fixed seed.
How each classifier decides
k-nearest neighbours has no training step. To classify a point it finds the k closest training points by straight-line distance and takes a majority vote, with ties broken in favour of the closest neighbour.
Logistic regression learns weights by gradient descent so that a softmax of linear scores matches the classes. With two classes this is the usual sigmoid. Gaussian naive Bayes fits a normal curve to each feature in each class, multiplies the likelihoods as if the features were independent, weights them by the class frequency and picks the largest.
kNN: class(x) = majority class among the k nearest points
Logistic: P(class c | x) = exp(w_c . x) / sum of exp(w_j . x)
Bayes: class(x) = argmax of log P(c) + sum over features of log N(x_f | mean_cf, var_cf)Worked examples
k-nearest neighbours (k = 5) on three blobs of 40 points gives training accuracy 100%, 5-fold CV 100%
The standard deviation across folds is 0 points, because the blobs are well separated.
Logistic regression degree 1 versus degree 2 on circles gives 52.5% versus 100% training accuracy
A straight line cannot separate an inner circle from a surrounding ring. Adding squared terms lets the boundary curve around it.
Which algorithm suits which pattern
| Algorithm | Boundary shape | Good at | Struggles with |
|---|---|---|---|
| k-nearest neighbours | Any shape, jagged for small k | Irregular boundaries | Noise at k = 1, many features, big data |
| Logistic regression | A line, or a curve with polynomial terms | Linearly separable classes, probabilities | Curved classes at degree 1 |
| Gaussian naive Bayes | Smooth curves | Small data, fast training | Correlated features, XOR-like patterns |
Good to know
Why training accuracy is not enough
Training accuracy is measured on the very points the model learned from. A nearest-neighbour model with k = 1 scores 100% by construction, because each point is its own nearest neighbour. Cross-validation fixes this by testing every point exactly once on a model that never saw it. Each fold trains on the other folds and tests on its own, and the mean of the fold accuracies estimates how the model will do on new data.
The spread between folds matters too. A large standard deviation means the result depends heavily on which points happened to be held out, which is common with small datasets. Compare settings by their mean, and use the spread to judge whether a difference is real.
Scope of this playground
The models see only two numeric features, so they are teaching tools, not general-purpose libraries. Distances are in the plot's own units (0 to 100 on both axes). Logistic regression is trained for a fixed number of batch gradient steps, with no regularisation, and the tool does not tune settings for you.
Privacy: how it works
- The points and the models stay in your browser tab. Nothing is sent to Ulkaa or anyone else.
Tips
- Try k = 1, then k = 15, on the moons data and compare the boundary: small k is jagged, large k is smooth and may cut corners.
- Add a single stray point of the wrong class inside a cluster and watch kNN with small k carve a tiny island around it.
- On XOR, naive Bayes and plain logistic regression stay near chance, while kNN and polynomial logistic regression do well.
- Use at least 10 points per class for cross-validation, or fold accuracies jump in large steps.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your points are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your points are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What is a decision boundary?
The line or curve where a classifier switches from predicting one class to another. The coloured regions in the plot show the prediction at every position.
How does k-nearest neighbours work?
It stores the training points. To classify a new point it finds the k nearest ones and predicts the most common class among them.
How does logistic regression make a curved boundary?
By adding polynomial features such as x squared and x times y. The model is still linear in those features, but the boundary in the original plane curves.
Why does naive Bayes fail on XOR?
It treats the two features as independent within each class, and in XOR each class has the same average position, so no pair of independent bell curves can separate them.
What is k-fold cross-validation?
The data is split into k folds. Each fold in turn is held out as a test set while the model trains on the rest, and the k accuracies are averaged.
How many folds should I use?
Five or ten is typical. More folds use more training data per fold but take longer and give a more variable estimate.
Why is kNN training accuracy 100% when k is 1?
Each training point is its own nearest neighbour, so it always predicts its own label. Use cross-validation to see real performance.
Can I use my own data?
You can draw points on the plot, up to three classes and 800 points. CSV input is not part of this tool; the decision tree and PCA tools accept CSV.
Popular Classifier Playground pages
- KNN Classifier VisualizerWatch the nearest-neighbour decision regions change as you vary k.
- KNN Overfitting With Small KSet k to 1 on noisy moons and see the jagged boundary and the 100% training score.
- Logistic Regression VisualizerWatch a straight logistic regression boundary separate two classes.
- Logistic Regression Decision BoundarySee how polynomial features let logistic regression separate a ring from its core.
- Naive Bayes Classifier VisualizerSee the smooth regions of a Gaussian naive Bayes model on three clusters.
- Gaussian Naive Bayes on XORRun naive Bayes on a pattern it cannot learn, and compare it with kNN.
- K-Fold Cross-Validation CalculatorSplit the data into folds, test each in turn, and read the accuracy per fold.
- Cross-Validation for Logistic RegressionCheck a polynomial logistic regression on unseen folds of the two moons data.