0% found this document useful (0 votes)
5 views9 pages

Iris Flower Classification with Deep Learning

The project focuses on classifying Iris flower species using a deep learning model built with TensorFlow/Keras, utilizing an Iris dataset with four features. It involves data loading, preprocessing, exploratory data analysis, and model training, ultimately achieving high accuracy in classification. The results indicate effective learning patterns, with recommendations for further performance enhancement through hyperparameter tuning and cross-validation.

Uploaded by

mahdi.aoune25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Iris Flower Classification with Deep Learning

The project focuses on classifying Iris flower species using a deep learning model built with TensorFlow/Keras, utilizing an Iris dataset with four features. It involves data loading, preprocessing, exploratory data analysis, and model training, ultimately achieving high accuracy in classification. The results indicate effective learning patterns, with recommendations for further performance enhancement through hyperparameter tuning and cross-validation.

Uploaded by

mahdi.aoune25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

République Algérienne Démocratique et Populaire

Ministère de l’enseignement supérieur et de la Recherche Scientifique


Université M’hamed Bougara- Boumerdès

Faculty of Science
Computer science Department
L3
Speciality: software engineering

RÉALISÉ PAR :
• Hamouche Nabil Imad
• Aoune El Babda Mehdi

GROUPE :0 1
I. Introduction:
This project aims to classify Iris flower species using a deep learning model. The Iris dataset
contains measurements of Sepal length, Sepal width, Petal length, and Petal width, and the
task is to classify each sample into one of three species: Iris setosa, Iris versicolor, and Iris
virginica. This classification problem is addressed using a neural network built with
TensorFlow/Keras.

II. Libraries Import:


The first part of the code is dedicated to importing the necessary libraries. Here's an overview
of the libraries used:

 NumPy (import numpy as np): A core library for numerical computing in Python. It is
used for handling arrays and mathematical operations.

 Pandas (import pandas as pd): A powerful data manipulation and analysis library. It is
used to load, process, and analyze datasets in DataFrame format.

 Matplotlib (import [Link] as plt): A plotting library used to create static,


animated, and interactive visualizations. It is used to generate plots for data
visualization, such as scatter plots and loss/accuracy graphs.

 Scikit-learn:

o train_test_split: From the sklearn.model_selection module, this function


splits the dataset into training and test sets, helping evaluate the model's
performance on unseen data.

o StandardScaler: From the [Link] module, this is used for


feature scaling. It standardizes the features to have zero mean and unit
variance, which is critical for improving model performance, especially when
using neural networks.

o LabelEncoder: From the [Link] module, this tool is used to


encode categorical labels into numerical values. It’s essential because machine
learning models work with numeric data.

o
 TensorFlow/Keras:

o TensorFlow (import tensorflow as tf): An open-source machine learning


library widely used for developing deep learning models.

o Keras (from [Link] import Sequential): A high-level API


within TensorFlow used to build and train neural network models.

o Layers (from [Link] import Dense, Dropout, Input): These


are the components used to build the architecture of the neural network. Dense
represents fully connected layers, Dropout is used to prevent overfitting, and
Input defines the input layer of the model.

o to_categorical: Converts the labels into a one-hot encoded format required for
multi-class classification.

o CategoricalCrossentropy: A loss function used for multi-class classification


problems.

III. Data Loading and Preprocessing:


The data is loaded from an Excel file (iris_label.xlsx) using pandas and analyzed. The dataset
consists of 150 samples of Iris flowers, each containing four features (Sepal length, Sepal
width, Petal length, Petal width) and a target label (species).

The features (x_train) are extracted by dropping the target column (species), and the target
variable (y_train) contains the species labels.
IV. Data Summary with describe:
The line of code print([Link]()) generates a summary of the dataset, which provides
essential statistical insights into the features of the Iris dataset.

Importance in the Workflow

 Summary Statistics: The output of describe() helps in understanding the distribution


of the features. For example, it gives insight into whether the features (like Sepal
length, Sepal width, etc.) are on the same scale or if any features are skewed.

 Data Preprocessing: It can help identify potential issues like missing values or
outliers in the data. If the features are on different scales (e.g., one feature ranges from
1-5 and another from 100-200), this might indicate a need for feature scaling (which
is done later with StandardScaler).

 Decision-Making: Based on the statistical summary, you can decide whether to apply
transformations, handle missing values, or check for outliers before feeding the data
into the machine learning model.
V. Exploratory Data Analysis (EDA):
A scatter plot is created to visualize the relationship between the first two features, Sepal
length and Sepal width, with color-coding for different species. The color-bar legend shows
the mapping of integer labels to species names, which are encoded as 0, 1, and 2.

VI. Label Encoding:


Since the neural network requires numerical labels for classification, the species labels are
encoded using LabelEncoder from scikit-learn. The labels are then converted into one-hot
encoding format using to_categorical, which is necessary when using
CategoricalCrossentropy as the loss function.
VII. Data Splitting:
The data is split into training and testing sets using train_test_split from scikit-learn, with
20% of the data used for testing and 80% for training. This ensures the model is evaluated on
unseen data.

VIII. Model Architecture:


A neural network model is created using Keras. The architecture consists of:

 An Input layer matching the number of features.

 Two Dense layers with 10 neurons each, activated using ReLU (Rectified Linear
Unit) for non-linearity.

 A Dropout layer with a rate of 0.2 to prevent overfitting.

 A Softmax output layer with 3 neurons (corresponding to the three Iris species) to
predict the class probabilities.

The model is compiled using the Adam optimizer and CategoricalCrossentropy loss
function, which is suitable for multi-class classification problems.
IX. Model Training:
The model is trained using the training set for 200 epochs with a batch size of 5. During
training, both the training and validation loss and accuracy are monitored to observe the
model's performance and generalization ability.

X. Evaluation:
After training, the model is evaluated on the test data and train set. The final loss and
accuracy on the test and train set are printed, providing an assessment of how well the model
generalizes to unseen data.

XI. Results :
 Training and Validation Loss: The training and validation loss over epochs are
visualized to understand how the model's performance improved over time. These
plots help to diagnose overfitting or underfitting during training.
 Training and Validation Accuracy: The training and validation accuracy curves are
also plotted to monitor the model's ability to correctly classify samples during both
training and validation phases. This helps to confirm the model's convergence and
assess if it is overfitting
XII. Prediction on New Data:
The model is used to classify a new sample, with the input values corresponding to a flower’s
measurements. The prediction is made using the trained model, and the predicted species is
printed.

XIII. Conclusion:
The deep learning model demonstrates the ability to classify Iris flower species with high
accuracy. The combination of ReLU activations and Softmax output allows the network to
learn complex patterns in the data. The training and validation accuracy curves suggest good
model performance, while the loss curves show convergence during training. Further steps
can include hyperparameter tuning and cross-validation for improved performance.

You might also like