Author: Chance Rebish
Date: May 5, 2025
Project: A6 - Artificial Neural Network
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.
- 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
- 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
- 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
- Sigmoid: Used in hidden layer for non-linear classification of separable classes
- Softmax: Used in output layer to convert raw outputs into probability distributions
- 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
- Python 3.x
- NumPy library
-
Ensure you're in the directory containing
main.pyandIris-data.txt -
Run the program:
python main.py
-
The program will:
- Load and preprocess the iris dataset
- Train the neural network
- Display validation and test accuracy
- Prompt for manual input
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
- 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
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
ANN/
├── main.py # Main neural network implementation
├── Iris-data.txt # Iris dataset (150 samples)
└── README.md # This documentation
- NumPy: Used for mathematical operations and array manipulations