Skip to content

crebish/iris-neural-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iris Species Classification using Artificial Neural Networks

Author: Chance Rebish
Date: May 5, 2025
Project: A6 - Artificial Neural Network

Overview

This project implements an artificial neural network to classify iris flowers into three species based on their physical measurements. The system uses sepal length, sepal width, petal length, and petal width measurements to predict whether an iris belongs to one of three species: Iris-setosa, Iris-versicolor, or Iris-virginica.

Features

  • Interactive Classification: Enter measurements manually to get real-time species predictions
  • Comprehensive Training: Uses 60% of data for training, 20% for validation, and 20% for testing
  • Performance Metrics: Displays validation and test accuracy percentages
  • Data Normalization: Automatically normalizes input features for better performance

Neural Network Architecture

Data Preparation

  • Dataset Split: 60% training, 20% validation, 20% testing (optimized for small dataset)
  • Output Representation: One-hot encoding for the 3 iris species
  • Feature Normalization: Z-score normalization applied to all measurements

Network Structure

  • Input Layer: 4 neurons (sepal length, sepal width, petal length, petal width)
  • Hidden Layer: 4 neurons with sigmoid activation
  • Output Layer: 3 neurons with softmax activation (one-hot species classification)
  • Topology: Feedforward neural network with full inter-layer connectivity

Activation Functions

  • Sigmoid: Used in hidden layer for non-linear classification of separable classes
  • Softmax: Used in output layer to convert raw outputs into probability distributions

Learning Algorithm

  • Method: Back-propagation with delta learning rule
  • Learning Rate: 0.1
  • Weight Initialization: Random values from standard normal distribution (scaled to 0.1)
  • Training Iterations: 100 epochs per training session

Usage

Prerequisites

  • Python 3.x
  • NumPy library

Running the Program

  1. Ensure you're in the directory containing main.py and Iris-data.txt

  2. Run the program:

    python main.py
  3. The program will:

    • Load and preprocess the iris dataset
    • Train the neural network
    • Display validation and test accuracy
    • Prompt for manual input

Manual Classification

When prompted, enter four comma-separated measurements:

Enter sepal length, sepal width, petal length, petal width (or 'q' to quit):
5.1,3.5,1.4,0.2

The program will output the predicted species:

Prediction: Iris-setosa

Technical Details

Performance Considerations

  • Accuracy Variability: Results may vary due to random weight initialization and data splitting
  • Seed Setting: Uses np.random.seed(41) for consistent results (can be removed for full variability)
  • Data Distribution: Some species may be underrepresented in training sets due to random splitting

Expected Performance

The neural network typically achieves high accuracy on iris classification due to the relatively separable nature of the three species. Performance may vary based on:

  • Random weight initialization
  • Data splitting distribution
  • Training data representation across species

File Structure

ANN/
├── main.py           # Main neural network implementation
├── Iris-data.txt     # Iris dataset (150 samples)
└── README.md         # This documentation

Dependencies

  • NumPy: Used for mathematical operations and array manipulations

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages