Iris Classifier

04 · About

How this works

The dataset

The Iris dataset was published by statistician Ronald Fisher in 1936, using flowers measured by botanist Edgar Anderson. It has 150 flowers — 50 each of Iris setosa, versicolor and virginica — with four measurements in centimetres: sepal length and width, petal length and width.

Setosa is easy to tell apart from petal size alone. Versicolor and virginica overlap, which is where models make their mistakes.

How training works

  • The data is shuffled with a fixed seed and split 80% train / 20% test, so results are repeatable.
  • Each measurement is standardised (mean 0, standard deviation 1). The scaling is learned from the training rows only, so the test set stays truly unseen.
  • K-nearest neighbours finds the k most similar training flowers and lets them vote. Probabilities are the share of votes.
  • Neural network: 4 inputs → one hidden layer (ReLU) → 3 softmax outputs, trained with the Adam optimiser and cross-entropy loss.
  • Everything runs in your browser — nothing is uploaded anywhere.

Limitations

  • 150 flowers is tiny. With only 30 test flowers, one mistake moves accuracy by about 3%.
  • A different seed gives a different split and can noticeably change the scores.
  • The model only knows these three species. Any other flower will still be labelled as one of them.
  • Measurements far outside the training range give unreliable — often overconfident — predictions.
  • The test accuracy curve is shown during training for learning purposes; settings tuned on it will look slightly better than they really are.
  • All flowers came from a few locations, so they may not represent irises growing elsewhere.