Skip to content

iabhishek765/Decodelabs_Task_2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒธ Project_2_Iris-Flower-Classification

Python Scikit-Learn Pandas Matplotlib Seaborn License


๐Ÿ“– Project Overview

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

Dataset Used:

Iris Flower Dataset

The dataset contains 150 flower samples from three different Iris species.

Features

  • Sepal Length
  • Sepal Width
  • Petal Length
  • Petal Width

Target Classes

  • ๐ŸŒธ Setosa
  • ๐ŸŒธ Versicolor
  • ๐ŸŒธ Virginica

๐Ÿง  Machine Learning Workflow

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

โœจ Features

โœ… 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


๐Ÿ›  Technologies Used

Technology Purpose
Python Programming Language
Pandas Data Handling
NumPy Numerical Computing
Matplotlib Data Visualization
Seaborn Statistical Visualization
Scikit-Learn Machine Learning
Joblib Model Saving

๐Ÿ“Š Model Performance

Test Accuracy

93%

Cross Validation

5-Fold Cross Validation

The model was evaluated using 5-Fold Cross Validation to obtain a more reliable estimate of its performance.

Best K Value

K = 5


๐Ÿ“ธ Project Screenshots

๐ŸŒธ Pair Plot

Pair Plot

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.


๐Ÿ“Š Class Distribution

Count Plot

The dataset contains an equal number of samples (50 each) for all three flower species, making it a perfectly balanced dataset.


๐Ÿ”ฅ Confusion Matrix

Confusion Matrix

The confusion matrix shows that the trained KNN model correctly classifies almost every sample, with only a few misclassifications between Versicolor and Virginica.


๐Ÿ“ˆ Accuracy vs K

Accuracy vs K

Cross-validation was used to evaluate different values of K. The best performing model was selected based on the highest average validation accuracy.

๐Ÿ“ Project Structure

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

๐Ÿš€ Installation

Clone Repository

git clone https://github.com/iabhishek765/Iris-Flower-Classification_Project_2.git

Go to Project Folder

cd Iris-Flower-Classification_Project_2

Install Dependencies

pip install -r requirements.txt

Run Project

python main.py

๐Ÿ“ˆ Output

The 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

๐Ÿ”ฎ Future Improvements

  • Deploy using Streamlit
  • Build a Flask API
  • Add user input interface
  • Compare multiple ML algorithms
  • Perform GridSearchCV
  • Deploy on Hugging Face Spaces

๐Ÿ‘จโ€๐Ÿ’ป Author

Abhishek Singh

AI & ML Enthusiast

GitHub:

https://github.com/iabhishek765


โญ If you found this project useful, consider giving it a star!

About

Iris Flower Classification using Machine Learning (KNN) with Hyperparameter Tuning and Cross Validation.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages