# 🏁 Capstone: NumPy Implementations vs Library Baselines

By Better Wise

> This lesson is premium content. Sign in and purchase the course to view the full content.

You already have the harness from the previous lesson: fixed folds, fixed seeds, a timing wrapper, and a results schema. In this lesson you run every model through it, from the normal-equation linear regressor to the one-hidden-layer MLP, and publish one table that a skeptical reviewer can rerun. Nothing new gets implemented here. The work is integration, fairness, and reporting.

> **Important:** 
> The deliverable is a report, not a scoreboard. If your NumPy model loses on runtime and wins on nothing, that is still a successful capstone, provided the number is correctly measured and honestly explained.

## The brief: one table, six rows, no asterisks

Your from-scratch code has been written in isolation, each model validated against its own unit test. The capstone asks the question those unit tests cannot answer: when every model is fed the same folds, the same preprocessing, and the same tuning budget, does the NumPy version behave like the scikit-learn counterpart on accuracy and loss, and how much wall-clock time does that cost?

Two outcomes are both legitimate. Parity in accuracy with a 10x runtime penalty is the expected result, and it is worth stating plainly: the value of the from-scratch version is transparency, not throughput. A mismatch is the more interesting outcome, because it means either your implementation or your protocol is wrong. Both are worth finding before you write the report.

Run this exercise first. Before writing any integration code, list for each of your six models the single parameter that most affects its runtime, for example the number of k-means iterations, the EM convergence tolerance, or the MLP epoch count. Write the pair (yours, baseline equivalent) next to each.

## The specification

Build `run_capstone.py` that produces `results.csv` with one row per (model, dataset, fold) and these columns: `model`, `impl` (`numpy` or `sklearn`), `dataset`, `fold`, `seed`, `accuracy`, `loss`, `fit_seconds`, `predict_seconds`.

## In this lesson

- Order of work
- Acceptance criteria
- Pitfalls that produce impressive, wrong tables
- Closing the loop


---

## Contents

Part of [🧮 Mathematics for Machine Learning 4: Build Core ML Algorithms from Scratch](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch.md)

- **📈 Linear and Cross-Entropy Models from Scratch**
  - [📉 Linear Regression with Normal Equations and Gradient Descent](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/linear-regression-normal-equations-and-gradient-descent.md)
  - [🔍 Gradient Checking with a Finite-Difference Harness](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/gradient-checking-finite-difference-harness.md) (sign-in required)
  - [🎚️ Logistic Regression to Softmax: Cross-Entropy Done Right](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/logistic-regression-to-softmax-cross-entropy.md)
  - [✅ Checkpoint: Linear and Cross-Entropy Models](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/checkpoint-linear-and-cross-entropy-models.md)
- **🔵 Unsupervised Learning from Scratch**
  - [🧭 PCA via SVD: Explained Variance and Component Selection](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/pca-via-svd-explained-variance.md)
  - [🌀 k-means: Lloyd's Algorithm and k-means++ Initialization](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/k-means-lloyd-and-k-means-plus-plus.md)
  - [🔔 Gaussian Mixture Models with Expectation Maximization](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/gaussian-mixture-models-expectation-maximization.md)
  - [✅ Checkpoint: PCA, k-means and GMM](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/checkpoint-pca-kmeans-and-gmm.md)
- **🧠 Backpropagation and Benchmark Capstone**
  - [🔗 Backpropagation for a One-Hidden-Layer MLP](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/backpropagation-for-one-hidden-layer-mlp.md)
  - [📊 Cross-Validation and a Fair Baseline Comparison Protocol](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/cross-validation-and-baseline-comparison-protocol.md)
  - [🏁 Capstone: NumPy Implementations vs Library Baselines](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/capstone-numpy-vs-library-baselines.md) (premium content) — this lesson
  - [✅ Checkpoint: Backpropagation and Model Comparison](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/checkpoint-backpropagation-and-model-comparison.md) (premium content)
- [Course cheatsheet](https://everwise.study/courses/mathematics-for-machine-learning-4-build-core-ml-algorithms-from-scratch/cheatsheet.md) (premium content)
