================================================================================
  Question 54: Multi-Class Iris Flower Classification
================================================================================

FULL QUESTION:
Using the Iris dataset from scikit-learn, build and evaluate machine learning models to classify iris flowers
into three species (Setosa, Versicolour, Virginica) based on sepal and petal dimensions.
Apply feature standardization using StandardScaler, and split the data into 80% train and 20% test sets.
Train Logistic Regression, Decision Tree Classifier, and Random Forest Classifier models.
Evaluate each classifier using Accuracy Score, Confusion Matrix, and Classification Report.

SHORT QUESTION:
Multi-class classification on the Iris dataset evaluating Logistic Regression, Decision Tree, and Random Forest.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Question 54: Iris Flower Classification

## Requirements
- Python 3.x
- Libraries: pandas, scikit-learn, matplotlib

## How to Run
```bash
python question_54_iris.py
```

================================================================================
SOURCE CODE FILES:
================================================================================

1. question_54_iris.py
--------------------------------------------------------------------------------
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report, ConfusionMatrixDisplay

# Load the Iris dataset
iris = load_iris()
X = pd.DataFrame(iris.data, columns=iris.feature_names)
y = pd.Series(iris.target)

# Split the data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)

# Scale the features
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Logistic Regression
log_model = LogisticRegression(max_iter=200, random_state=42)
log_model.fit(X_train_scaled, y_train)
log_pred = log_model.predict(X_test_scaled)
print("--- Logistic Regression ---")
print("Accuracy:", accuracy_score(y_test, log_pred))
print("\nConfusion Matrix:\n", confusion_matrix(y_test, log_pred))
print("\nClassification Report:\n", classification_report(y_test, log_pred))

# Decision Tree Classifier
tree_clf = DecisionTreeClassifier(random_state=42)
tree_clf.fit(X_train, y_train)
tree_pred = tree_clf.predict(X_test)
print("\n--- Decision Tree Classifier ---")
print("Accuracy:", accuracy_score(y_test, tree_pred))
print("\nConfusion Matrix:\n", confusion_matrix(y_test, tree_pred))
print("\nClassification Report:\n", classification_report(y_test, tree_pred))

# Random Forest Classifier
rf_model = RandomForestClassifier(random_state=42)
rf_model.fit(X_train, y_train)
rf_pred = rf_model.predict(X_test)
print("\n--- Random Forest Classifier ---")
print("Accuracy:", accuracy_score(y_test, rf_pred))
print("\nConfusion Matrix:\n", confusion_matrix(y_test, rf_pred))
print("\nClassification Report:\n", classification_report(y_test, rf_pred))

# Visualize Confusion Matrix for Logistic Regression
fig, ax = plt.subplots(figsize=(8, 6))
ConfusionMatrixDisplay.from_predictions(y_test, log_pred, ax=ax, cmap=plt.cm.Blues)
plt.title("Confusion Matrix - Logistic Regression")
plt.show()
--------------------------------------------------------------------------------
