metadata
license: mit
tags:
- iris
- classification
- supervised-learning
- lda
- scikit-learn
library_name: sklearn
pipeline_tag: tabular-classification
language:
- en
Iris Flower Classifier
A supervised classification model trained on the classic Iris dataset using Linear Discriminant Analysis (LDA). Achieves 100% accuracy on the test set.
Model Details
| Property | Value |
|---|---|
| Algorithm | Linear Discriminant Analysis (LDA) |
| Type | Supervised Classification |
| Input | 4 flower measurements (cm) |
| Output | Species prediction + class probabilities |
| Training Accuracy | 97.5% (10-fold CV) |
| Test Accuracy | 100% |
| Classes | Iris-setosa, Iris-versicolor, Iris-virginica |
Features
| Feature | Description | Range |
|---|---|---|
sepal_length |
Length of sepal (cm) | 4.3 – 7.9 |
sepal_width |
Width of sepal (cm) | 2.0 – 4.4 |
petal_length |
Length of petal (cm) | 1.0 – 6.9 |
petal_width |
Width of petal (cm) | 0.1 – 2.5 |
Quick Start
import joblib
import numpy as np
model = joblib.load("models/iris_model.pkl")
scaler = joblib.load("models/scaler.pkl")
label_encoder = joblib.load("models/label_encoder.pkl")
# Predict a flower: [sepal_length, sepal_width, petal_length, petal_width]
sample = np.array([[5.1, 3.5, 1.4, 0.2]])
scaled = scaler.transform(sample)
prediction = model.predict(scaled)[0]
species = label_encoder.inverse_transform([prediction])[0]
print(f"Predicted: {species}") # Iris-setosa
Model Comparison
8 algorithms were compared using 10-fold stratified cross-validation:
| Algorithm | CV Accuracy |
|---|---|
| LDA | 97.5% |
| SVM | 96.7% |
| Logistic Regression | 95.8% |
| KNN | 95.8% |
| Naive Bayes | 95.8% |
| Decision Tree | 95.0% |
| Random Forest | 95.0% |
| Gradient Boosting | 95.0% |
Files
models/
iris_model.pkl # Trained LDA classifier
scaler.pkl # StandardScaler for feature normalization
label_encoder.pkl # LabelEncoder for species names
metadata.pkl # Model metadata (name, accuracy, features, classes)
app.py # Flask web app for interactive predictions
templates/
index.html # Web UI with sliders
Web App
A Flask web app is included for interactive predictions:
pip install flask joblib scikit-learn numpy
python app.py
# Open http://localhost:5000
Training Data
The classic Iris dataset (150 samples, 3 classes, 50 samples each). No missing values.
Citation
@misc{rajuamburu-iris-classifier,
author = {rajuamburu},
title = {Iris Flower Classifier},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/rajuamburu/iris-classifier}
}
License
MIT