File size: 2,788 Bytes
44b3ab8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
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

```python
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:

```bash
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