This project is a Machine Learning classification system that predicts the species of an Iris flower based on its physical measurements.
The model is trained using the K-Nearest Neighbors (KNN) algorithm and follows a complete machine learning pipeline including:
- Data Exploration
- Data Visualization
- Data Preprocessing
- Train-Test Split
- Feature Scaling
- Model Training
- Prediction
- Model Evaluation
- Hyperparameter Tuning
- Cross Validation
- Model Saving
This project was developed as part of an AI/ML Internship to demonstrate the complete workflow of building a supervised Machine Learning model.
Dataset Used:
Iris Flower Dataset
The dataset contains 150 flower samples from three different Iris species.
- Sepal Length
- Sepal Width
- Petal Length
- Petal Width
- ๐ธ Setosa
- ๐ธ Versicolor
- ๐ธ Virginica
Load Dataset
โ
โผ
Exploratory Data Analysis
โ
โผ
Data Visualization
โ
โผ
Train-Test Split
โ
โผ
Feature Scaling
โ
โผ
Train KNN Model
โ
โผ
Predictions
โ
โผ
Model Evaluation
โ
โผ
Hyperparameter Tuning
โ
โผ
5-Fold Cross Validation
โ
โผ
Save Trained Model
โ Exploratory Data Analysis
โ Statistical Summary
โ Data Visualization
โ Pair Plot
โ Species Count Plot
โ Train-Test Split
โ Feature Scaling using StandardScaler
โ K-Nearest Neighbors Classifier
โ Model Prediction
โ Accuracy Score
โ Confusion Matrix
โ Classification Report
โ Confusion Matrix Heatmap
โ Custom Flower Prediction
โ Save Trained Model (.pkl)
โ Hyperparameter Tuning
โ Accuracy vs K Graph
โ 5-Fold Cross Validation
| Technology | Purpose |
|---|---|
| Python | Programming Language |
| Pandas | Data Handling |
| NumPy | Numerical Computing |
| Matplotlib | Data Visualization |
| Seaborn | Statistical Visualization |
| Scikit-Learn | Machine Learning |
| Joblib | Model Saving |
93%
5-Fold Cross Validation
The model was evaluated using 5-Fold Cross Validation to obtain a more reliable estimate of its performance.
K = 5
The pair plot visualizes the relationship between all four features of the Iris dataset. It clearly shows that Setosa is linearly separable, while Versicolor and Virginica have slight overlap.
The dataset contains an equal number of samples (50 each) for all three flower species, making it a perfectly balanced dataset.
The confusion matrix shows that the trained KNN model correctly classifies almost every sample, with only a few misclassifications between Versicolor and Virginica.
Cross-validation was used to evaluate different values of K. The best performing model was selected based on the highest average validation accuracy.
Project_2_Iris-Flower-Classification/
โ
โโโ models/
โ โโโ knn_iris_model.pkl
โ โโโ scaler.pkl
โ
โโโ screenshots/
โ โโโ countplot.png
โ โโโ pairplot.png
โ โโโ confusion_matrix_heatmap.png
โ โโโ accuracy_vs_k.png
โ
โโโ main.py
โโโ requirements.txt
โโโ README.md
git clone https://github.com/iabhishek765/Iris-Flower-Classification_Project_2.gitcd Iris-Flower-Classification_Project_2pip install -r requirements.txtpython main.pyThe project performs:
- Dataset Exploration
- Statistical Analysis
- Visualization
- Data Preprocessing
- Model Training
- Model Prediction
- Performance Evaluation
- Hyperparameter Tuning
- Cross Validation
- Saves the trained model for future use
- Deploy using Streamlit
- Build a Flask API
- Add user input interface
- Compare multiple ML algorithms
- Perform GridSearchCV
- Deploy on Hugging Face Spaces
Abhishek Singh
AI & ML Enthusiast
GitHub:
https://github.com/iabhishek765



