# Scikit-Learn Classification: Train, Test & Explain

TechBuilt Open School — Free, self-guided technical project kit

- **Track:** AI & Machine Learning
- **Level:** Intermediate
- **Access:** No account, signup, payment or enrollment required
- **Format:** Guided plan and runnable starter example, not a complete solution or a live class
- **Online guide:** https://techbuiltos.online/projects/scikit-learn-classifier

## Project goal

Practice an ML baseline, data split, evaluation metric and responsible interpretation.

Train a learning-only classifier on the built-in Iris dataset, evaluate it on held-out examples and document limitations.

## Before you begin

- Python with scikit-learn installed
- Basic Python arrays and train/test split concepts

## Local setup

1. Create a virtual environment and install scikit-learn.
2. Save and run classifier.py; it uses the bundled Iris dataset.
3. Do not present this toy demonstration as an operational decision tool.

## Starter example — classifier.py

The sample below is a starting point. It may require the prerequisites above. Complete the subsequent milestones to finish your own project.

```python
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, confusion_matrix
from sklearn.model_selection import train_test_split

iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
    iris.data, iris.target, test_size=0.25, random_state=42,
    stratify=iris.target,
)
model = LogisticRegression(max_iter=500)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
print("Held-out accuracy:", round(accuracy_score(y_test, predictions), 3))
print("Confusion matrix:\n", confusion_matrix(y_test, predictions))
```

## Build milestones

1. Explain target labels and input features before modeling.
2. Split data into train and test sets without peeking at test labels.
3. Fit a LogisticRegression baseline and measure held-out accuracy.
4. Report a confusion matrix and per-class precision/recall.
5. Write a short model card with intended learning-only use and limitations.

## Completion checklist

- [ ] Training and test samples remain separate.
- [ ] Same random_state yields reproducible split and baseline results.
- [ ] Report names the evaluation dataset and a suitable metric.
- [ ] Documentation states that sample performance does not prove real-world safety.

## Optional extensions

- Compare a second baseline and explain the selection of evaluation metrics.
- Write a one-page model card and identify data drift signals.

## Related learning

- Individual course roadmap: https://techbuiltos.online/courses/scikit-learn
- Individual course roadmap: https://techbuiltos.online/courses/ai-ml-foundations

- Specialization: https://techbuiltos.online/specializations/ai-machine-learning
- Specialization: https://techbuiltos.online/specializations/data-science

---

This original self-study project is independent of paid cohorts. Review any external library documentation before use. Do not commit real credentials, private client files or personal data to public repositories.
