A minimal MNIST classification pipeline for demonstrating roar provenance tracking.
The pipeline has three steps:
extract.py— Reads an MNIST parquet file (from Hugging Face), extracts 28x28 pixel images as flattened 784-dimensional feature vectors, and saves them as a.npzfile.train.py— Trains a logistic regression classifier (scikit-learn, SAGA solver) on the extracted features. Logs training loss per epoch to Weights & Biases. Saves the model as a.pklfile.evaluate.py— Loads a trained model and test features, computes accuracy/precision/recall, prints a classification report, and writes metrics to a.jsonfile.
Training and test data are MNIST parquet files hosted on Hugging Face:
- Python 3.10+
- numpy, scikit-learn, pyarrow, Pillow, wandb
pip install numpy scikit-learn pyarrow Pillow wandb# Download data
wget "https://huggingface.co/datasets/ylecun/mnist/resolve/main/mnist/train-00000-of-00001.parquet?download=true" -O train-00000-of-00001.parquet
wget "https://huggingface.co/datasets/ylecun/mnist/resolve/main/mnist/test-00000-of-00001.parquet?download=true" -O test-00000-of-00001.parquet
# Extract features
python extract.py --input train-00000-of-00001.parquet --output train_feats.npz
python extract.py --input test-00000-of-00001.parquet --output test_feats.npz
# Train
python train.py --input train_feats.npz --output model.pkl
# Evaluate
python evaluate.py --model model.pkl --input test_feats.npz --output metrics.json