This project implements a simple Multi-Layer Perceptron (MLP) from scratch using numpy. The MLP is trained on the Iris dataset to classify iris flowers into three different species.
-
Clone the repository:
git clone https://github.com/Gaurav31U/Multilayer-Perceptron-Classifier-using-Python.git cd Multilayer-Perceptron-Classifier-using-Python
-
Install the required packages:
pip install numpy pandas
-
Download the Iris dataset and place it in the same directory as the script:
wget https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data -O iris.csv
- Run the script to train the MLP:
python mlp_iris.py
-
mlp
Class:__init__(self, m, n, p, eta, epoaches)
: Initializes the MLP with input sizem
, hidden layer sizen
, output sizep
, learning rateeta
, and number of epochsepoaches
.sigmoid(self, y)
: Computes the sigmoid activation function.forward_prop(self, inp)
: Performs forward propagation to compute the output.back_prop(self, d, inp)
: Performs backward propagation to update the weights.train(self, X, Y)
: Trains the MLP on the input dataX
and labelsY
.
-
Data Handling:
- Reads the Iris dataset from a CSV file, converts categorical labels to numeric codes, and shuffles the data.
- Splits the data into input features
X
and labelsY
.