← Back to Projects
Machine LearningPlatform: CodeAlpha

Iris Classification

Iris Classification

1. Context & Objective

The Iris flower dataset consists of 50 samples from each of three species of Iris. This project classifies species using classical ML models and compares their accuracy.

2. Methodology

1. Extracted petal and sepal measurements as X, species as Y. 2. Split dataset 80/20 for training and testing. 3. Compared SVC and Logistic Regression classification boundaries. 4. Evaluated using accuracy score and classification report.
In [1]:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score

iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

clf = SVC(kernel='linear')
clf.fit(X_train, y_train)
print(f'Accuracy: {accuracy_score(y_test, clf.predict(X_test))*100:.2f}%')

3. Final Learnings

Model achieved 100% accuracy on the test set, demonstrating the linear separability of the Setosa class. SVC proved highly robust for small-scale multivariate classification.

Dataset details

Language

Python

Size

150 rows, 4 features

Libraries Used

Scikit-LearnNumpyPandas