This task implements a custom perceptron classifier for the famous Iris dataset using a one-vs-all approach for multi-class classification.
The iris_perceptroon_task.py script contains:
- A custom
BioPerceptronclass that implements a basic perceptron algorithm - Multi-class classification using three binary perceptrons (one for each Iris species)
- Data preprocessing with StandardScaler
- Visualization of predictions using PCA dimensionality reduction
- Python 3.7+
- numpy
- matplotlib
- scikit-learn
-
Clone or download this project
-
Create a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Linux/Mac # or .venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
Run the perceptron classification:
python iris_perceptroon_task.pyThe script will:
- Train three perceptrons (one for each Iris class: setosa, versicolor, virginica)
- Test the model on 20% of the dataset
- Print the accuracy percentage
- Display a 2D PCA visualization of the predicted classes
The perceptron typically achieves high accuracy (often 100%) on the Iris dataset due to the dataset's linear separability, especially for the setosa class.