ML· Feb 2026
Iris Flower Classification
A complete, reproducible ML pipeline that predicts an iris species from four measurements.
- test accuracy
- 93.3%
- Built with
- Pythonscikit-learnpandasNumPy

Problem
Predict an iris flower's species — setosa, versicolor or virginica — from sepal and petal length and width, using a pipeline that is honest about its results and gives the same answer every run.
Approach
- Stratified 60/40 train/test split so every species is equally represented in both sets.
StandardScalerfitted on the training data only, then applied to the test set — no data leakage.- Logistic regression classifier from scikit-learn.
- Full evaluation: accuracy, confusion matrix, and per-class precision / recall / F1.
- Fixed random seed for reproducibility.
Results
| Metric | Test set (60 flowers) |
|---|---|
| Accuracy | 93.3% |
| Setosa | 100% precision and recall |
| Versicolor | F1 = 0.90 |
| Virginica | F1 = 0.89 |
Setosa is perfectly separable. All 4 errors are between versicolor and virginica, whose measurements overlap.
What I learned
- The standard ML workflow end to end: load, split, scale, train, predict, evaluate.
- Avoiding data leakage by fitting preprocessing on the training set only.
- Why stratification matters on small datasets.
- Accuracy isn't the whole story — the confusion matrix shows which classes get confused.
Dataset
Iris dataset — R. A. Fisher (1936), via the UCI Machine Learning Repository.