BARATAM NIDHISHRI

Back to Portfolio

Unlocking Nature’s Secrets: How We Taught AI to Identify Iris Flowers!

By Baratam Nidhishri


Imagine a world where Artificial Intelligence helps us solve everyday puzzles, even in nature! Have you ever looked at a beautiful flower and wished you could instantly know its exact species? That’s exactly what I set out to do with this project: build an Artificial Neural Network (ANN) to precisely classify unknown Iris flower types!

This wasn’t just a coding exercise; it was a captivating journey into the heart of classification problems and the incredible power of deep learning.

Iris Flower Classification using ANN

The “Why”: Becoming Digital Botanists

Why tackle Iris flowers? Because beneath their delicate petals lies a fascinating challenge for AI! The three Iris species — Setosa, Versicolor, and Virginica — share similarities, yet each has unique traits. My mission was to train a model to spot those subtle differences, turning raw data into a brilliant botanical detective. It’s about empowering computers to “see” and categorize the world around us, one flower at a time!

Our Dataset: The Blossoming Basics

For this floral adventure, I utilized the legendary Iris dataset. It’s a perfect starter kit for anyone diving into classification. This dataset contains 150 samples, covering all three Iris species, each described by four vital measurements:

  • Sepal Length (cm)
  • Sepal Width (cm)
  • Petal Length (cm)
  • Petal Width (cm)

Preparing Our Garden: Data Transformation & Visualization

Before our ANN could learn, the data needed a little tender loving care.

  • One-Hot Encoding: Species labels were transformed into numerical vectors (e.g., Setosa → [1, 0, 0]) so the neural network could interpret categorical data.
  • Train-Test Split: The dataset was divided into 80% training data and 20% testing data to ensure proper generalization.
  • Feature Scaling: Using StandardScaler, all features were normalized so that no measurement dominated the learning process.

Building Our Botanical Brain: The Keras Blueprint

I used TensorFlow’s Keras API to design the neural network, making development both intuitive and efficient.

  • Input Layer: Accepts four numerical flower measurements.
  • Hidden Layers: Two layers with 8 and 10 neurons using ReLU activation.
  • Output Layer: Three neurons with Softmax activation representing each Iris species.

The model was compiled using the Adam optimizer and categorical crossentropy loss function.

The Learning Curve: Training & Validation

The network was trained for 75 epochs. With each iteration, accuracy increased while loss decreased for both training and validation sets, indicating effective learning without overfitting.

The final model achieved an impressive ~93% accuracy on unseen test data.

The Reveal: Predicting the Next Bloom!

When presented with a completely unknown flower:

  • Sepal Length: 5.0 cm
  • Sepal Width: 2.0 cm
  • Petal Length: 1.3 cm
  • Petal Width: 0.5 cm

The model confidently predicted the species as Versicolor.

Our Blooming Insights: What We Mastered

  • Understanding the power of ANNs in classification tasks
  • The critical role of data preprocessing and scaling
  • Designing, training, and evaluating neural networks effectively

This project beautifully blended nature and technology, highlighting how machine learning can uncover meaningful patterns hidden within data. I hope it inspires you to explore the fascinating world of AI!

Want to explore the code? View the complete implementation on Google Colab and GitHub .