Learning

Classify iris flowers using machine learning

Classify three Iris groups from four flower measurements

This reproducible benchmark standardizes sepal and petal measurements and applies a direct three-class softmax model. The exported classifier labels all 30 held-out records correctly, with a testing cross-entropy of 0.0359. The result demonstrates the workflow on a small historical data set; it does not establish general botanical identification accuracy.

100%held-out accuracy
0.0359testing cross-entropy
30held-out records
15trainable parameters

1. Scientific objective

The objective is to reproduce a classic three-class classification problem using four morphometric measurements: sepal length, sepal width, petal length and petal width. The model is useful for teaching data splitting, multiclass softmax inference and reproducible deployment. It is not a field-identification system and does not capture the traits, geography or taxonomic evidence required for botanical work.

Transparent multiclass baseline

Show how four measured variables map directly to three class scores without a hidden layer.

Reproducible teaching case

Connect the historical table, exact random split, regenerated figures and executable export.

Inspect decision boundaries

Use the browser model to explore how petal and sepal measurements change the three output scores.

Biostatistics educationBotanical data analysisScientific programmingMachine-learning training
Scope. Each row is one historical Iris record with four measurements and one supplied class label. The page is a classification benchmark, not evidence that these four variables are sufficient for identifying arbitrary plants.

2. Data and provenance

The downloadable irisflowers.csv contains 150 complete rows: 50 labelled Iris setosa, 50 Iris versicolor and 50 Iris virginica. The four continuous inputs are recorded in centimetres.

CSV fieldDefinitionUnitObserved range
sepal_lengthLength of the sepalcm4.3–7.9
sepal_widthWidth of the sepalcm2.0–4.4
petal_lengthLength of the petalcm1.0–6.9
petal_widthWidth of the petalcm0.1–2.5
classSupplied group labelcategorythree labels
SubsetRowsSetosaVersicolorVirginicaPurpose
Training90283329Estimate model parameters
Selection3011712Monitor optimization
Testing3011109Report final internal performance
Equal distribution of fifty records for each of the three Iris labels
The complete table is exactly balanced, although the random subsets contain slightly different class counts.
Associations between the four measurements and an encoded Iris class
The target is nominal. These coefficients depend on its numerical encoding and must not be interpreted as causal effects or biological feature importance.
Provenance. The project uses the 150-row UCI Iris data set, associated with Fisher’s 1936 classification paper. UCI documents known differences between its historical iris.data file and corrected variants. This tutorial preserves the exact values used to train the supplied Neural Designer project; the downloadable copy only normalizes the accidental leading space in one column header. UCI lists the data under CC BY 4.0.

3. Model

Each measurement is standardized using its mean and standard deviation. A single dense softmax layer connects the four scaled inputs directly to three outputs ordered as iris_setosa, iris_versicolor and iris_virginica.

The architecture has no hidden layer and contains 15 trainable parameters: twelve weights and three biases. It is a multiclass logistic classifier represented in Neural Designer’s neural-network framework.

Output contract. The largest softmax score defines the predicted label. The scores have not been independently calibrated as probabilities and should not be presented as botanical certainty.
Direct Iris classifier with four standardized measurements and one categorical softmax output representing three classes
Fixed base and final architecture: four standardized inputs connected directly to three softmax scores. No hidden-layer or neuron-selection experiment was performed.

4. Training strategy

The model minimizes multiclass cross-entropy with the quasi-Newton method and no explicit regularization. Optimization stores 44 iterations (epochs 0–43) and stops on the minimum-loss-decrease criterion.

Training cross-entropy decreases from 1.0995 to 0.0456. Selection cross-entropy decreases from 0.4546 to its minimum of approximately 0.0390 at epoch 30 and finishes at 0.0439.

Training and selection cross-entropy histories over 44 stored iterations
The selection curve rises slightly after epoch 30. The downloadable export is the stored final model at epoch 43.

5. Model selection and baseline

No neuron selection, input selection or architecture selection was performed. The direct 4–3 softmax model is both the base and final architecture. The selection subset monitors training but is not used to compare network sizes.

ReferenceTesting accuracyInterpretation
Largest testing class36.7%Always predict the label represented by 11 of 30 testing rows
Uniform three-class chance33.3% expectedReference for three equally likely labels
Fixed softmax model100%All 30 records in this internal testing subset classified correctly

The compact linear decision model is sufficient for this split. Adding neurons would increase complexity without addressing the more important limitations: small sample size, duplicated measurement vectors and lack of external botanical validation.

6. Scientific validation

The held-out subset contains 30 records. The exported final model assigns all 11 setosa, 10 versicolor and 9 virginica rows to their supplied classes. Perfect accuracy on this small, familiar benchmark should be interpreted alongside score margins, provenance and split limitations.

Testing metricValueInterpretation
Accuracy100%30 correct labels from 30 testing records
Macro precision100%Unweighted mean across the three labels
Macro recall100%Every testing record in each label recovered
Macro-F1100%Class-balanced precision/recall summary
Testing cross-entropy0.0359Calculated from the exact Python export

Confusion matrix

Actual / predictedIris setosaIris versicolorIris virginicaTotal
Iris setosa110011
Iris versicolor010010
Iris virginica0099
Total1110930

Lowest-margin correct test case

A held-out Iris versicolor record with measurements 6.3, 2.5, 4.9 and 1.5 cm receives a versicolor score of 61.13% and a virginica score of 38.87%. The correct label alone therefore does not imply that every decision has a wide score margin.

Scientific interpretation. The direct softmax model separates the supplied labels within this historical table. One exact setosa measurement vector occurs in training, selection and testing, so the random split is not completely independent at the feature-vector level. No external specimens, locations, instruments or modern taxonomic review are tested.

7. Inference and reproducibility

A credible morphometric workflow would begin with a traceable specimen, confirm the measurement protocol and units, apply quality checks, calculate the four measurements, validate the input domain, produce the three model scores and route the result to botanical or teaching review.

Traceable specimen
Measurement protocol
Quality and unit checks
Four measurements
Three model scores
Botanical or teaching review

Held-out inference example

The default browser values reproduce record 121 from the published testing subset. Its supplied label is Iris virginica.

InputValue
Sepal length6.9 cm
Sepal width3.2 cm
Petal length5.7 cm
Petal width2.3 cm
Supplied classIris virginica
Highest model scoreIris virginica

Setosa <0.0001%; versicolor 0.0080%; virginica 99.9920%. The predicted label matches the held-out target.

Try the exported Iris classifier

Enter the four flower measurements in centimetres. The default values reproduce a held-out Iris virginica record from the published split.

Research demonstration. The calculation runs locally with the exact exported weights and preprocessing. Values outside the validated domain are rejected. Softmax scores have not been independently calibrated as probabilities, and this component is not a general botanical identification tool.

Reproduce the inference

The Python package contains the exact export, ordered four-field schema, held-out example and expected scores. The project package preserves the random split, trained parameters and regenerated analyses.

from model import NeuralNetwork

measurements_cm = [6.9, 3.2, 5.7, 2.3]
scores = NeuralNetwork().calculate_outputs(measurements_cm)

8. Validity, uncertainty and limitations

  • Small historical sample. The table contains only 150 records and 30 testing cases, so perfect testing accuracy has substantial sampling uncertainty.
  • Duplicate-vector leakage. The measurement vector 4.9, 3.1, 1.5 and 0.1 cm occurs in the training, selection and testing subsets with the same setosa label.
  • Known data-version issues. UCI documents corrections to particular rows. This project preserves the historical values it was trained on rather than silently mixing versions.
  • Restricted measurements. The model uses four morphometric values only; it ignores location, growth conditions, phenology, colour, genetic evidence and other diagnostic traits.
  • Uncalibrated scores. Softmax values rank the three labels but have not been independently calibrated as probabilities.
  • No external validation. Transfer to new populations, observers, instruments, taxa or measurement protocols has not been evaluated.
  • Educational boundary. The model is suitable for teaching and software verification, not authoritative botanical identification.

References