================================================================================
  Simple Question SQ5: Minimal ML Models (Decision Tree, Random Forest, Linear Regression)
================================================================================

FULL QUESTION:
SQ5. Minimal Machine Learning Test: Train and evaluate the three core models used across the practical exam (DecisionTreeClassifier, RandomForestClassifier, and LinearRegression) using scikit-learn.
Use this simpler program to verify your scikit-learn installation, syntax, and prediction functions before training on large CSV datasets.

SHORT QUESTION:
Minimal Scikit-Learn Model Verification Script.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# SQ5: Minimal ML Models Test

## Purpose
Run this quick script to verify that Decision Tree, Random Forest, and Linear Regression train and infer without errors.

## Requirements
```bash
pip install scikit-learn numpy pandas
```

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

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

1. test_models.py
--------------------------------------------------------------------------------
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LinearRegression
from sklearn.metrics import accuracy_score, r2_score

def test_decision_tree():
    print("-" * 50)
    print("1. Testing Decision Tree Classifier...")
    X = np.array([[20.0, 30.0, 20.0], [21.0, 32.0, 25.0], [24.0, 45.0, 500.0], [25.0, 50.0, 600.0]])
    y = np.array([0, 0, 1, 1])
    dt = DecisionTreeClassifier(max_depth=3, random_state=42)
    dt.fit(X, y)
    test_sample = np.array([[23.5, 42.0, 550.0]])
    pred = dt.predict(test_sample)[0]
    print(f"   Sample: {test_sample.tolist()} -> Predicted Class: {pred}")
    print("   [OK] Decision Tree working properly.")

def test_random_forest():
    print("\n" + "-" * 50)
    print("2. Testing Random Forest Classifier...")
    X = np.array([[15, 25], [25, 40], [80, 120], [180, 260]])
    y = np.array(["Good", "Satisfactory", "Moderate", "Poor"])
    rf = RandomForestClassifier(n_estimators=10, random_state=42)
    rf.fit(X, y)
    test_sample = np.array([[90, 140]])
    pred = rf.predict(test_sample)[0]
    print(f"   Sample: {test_sample.tolist()} -> Predicted AQI Bucket: {pred}")
    print("   [OK] Random Forest working properly.")

def test_linear_regression():
    print("\n" + "-" * 50)
    print("3. Testing Multiple Linear Regression...")
    X = np.array([[1010.0, 15.0, 2.0], [1015.0, 12.0, 3.5], [1005.0, 22.0, 1.2], [1020.0, 8.0, 4.0]])
    y = np.array([24.5, 21.0, 31.0, 18.5])
    lr = LinearRegression()
    lr.fit(X, y)
    y_pred = lr.predict(X)
    r2 = r2_score(y, y_pred)
    test_sample = np.array([[1008.0, 18.0, 2.5]])
    pred = lr.predict(test_sample)[0]
    print(f"   Sample: {test_sample.tolist()} -> Predicted Temp: {pred:.2f} °C (R2: {r2:.3f})")
    print("   [OK] Linear Regression working properly.")

if __name__ == "__main__":
    print("=" * 60)
    print("  SQ5: Machine Learning Verification Suite")
    print("=" * 60)
    test_decision_tree()
    test_random_forest()
    test_linear_regression()
    print("\n" + "=" * 60)
    print("  [ALL ML MODELS VERIFIED SUCCESSFULLY]")
    print("=" * 60)
--------------------------------------------------------------------------------
