Files
ML-portfolio/classification-project/README.md

2.1 KiB
Raw Blame History

MNIST Classification — Binary, Multiclass, Multilabel & Multioutput

A complete tour of classification approaches on the MNIST handwritten digit dataset (70,000 images, 28×28 pixels).

Overview

Covers four distinct classification problem types on the same dataset, comparing models honestly with cross-validation rather than relying on raw accuracy (which is misleading on imbalanced classes).

Approach

  1. Binary classification ("is it an 8?") — SGD Classifier baseline, evaluated against a DummyClassifier to prove the model actually learned something beyond guessing the majority class.
  2. Threshold analysis — precision-recall and ROC curves to show the tradeoff between precision and recall as the decision threshold moves, instead of reporting one fixed operating point.
  3. Model comparison — SGD (linear) vs Random Forest (ensemble) on the same binary task.
  4. Multiclass classification — all 10 digits at once, with a 10×10 confusion matrix (normalized by row) to see which digits actually get confused with which.
  5. Multilabel classification — predicting multiple independent yes/no labels per sample simultaneously, including ClassifierChain to model dependence between labels.
  6. Multioutput classification — predicting all 784 pixel values at once (image denoising as a classification problem).

Results

Model / Task Metric Score
SGD (binary: "is it an 8?") F1 0.58
SGD (binary) ROC AUC 0.915
Random Forest (binary) F1 0.90
Random Forest (binary) ROC AUC 0.997
Multilabel (KNN) Macro F1 0.978

The SGD → Random Forest jump illustrates why a linear decision boundary struggles on raw pixel data compared to a tree ensemble that can carve non-linear regions.

Tech stack

Python, scikit-learn, matplotlib

Notebooks