Goal: Train a supervised machine learning model to classify iris flowers into three species based on their measurements.
Key Concepts: Supervised learning, train-test split, feature scaling, K-Nearest Neighbors (KNN), confusion matrix, F1 score.
How it works:
- Loads the Iris dataset (150 samples, 4 features, 3 classes)
- Scales features using
StandardScalerso no single measurement dominates - Splits data 80/20 into training and testing sets (shuffled)
- Trains a
KNeighborsClassifierwith K=5 - Evaluates using accuracy score, confusion matrix, and a full classification report
Files: classifier.py
Dependencies:
pip install scikit-learn
How to run:
cd "C:\Users\user\OneDrive\Desktop\Project2"
python classifier.py
Sample output:
Dataset shape: (150, 4)
Classes: ['setosa', 'versicolor', 'virginica']
Accuracy: 1.0
Confusion Matrix:
[[10 0 0]
[ 0 9 0]
[ 0 0 11]]