Day 14 · Capstone + Recap
Suggested pace: 1–1.5 hrs learn · 2–3 hrs code · rest to debug and document What you should know first ☐ Day 8: the full project workflow ☐ Day 12: training and evaluating a neural network ☐ Day 6: metrics and baselines
Suggested pace: 1–1.5 hrs learn · 2–3 hrs code · rest to debug and document
What you should know first ☐ Day 8: the full project workflow ☐ Day 12: training and evaluating a neural network ☐ Day 6: metrics and baselines If one of these feels shaky, spend 15 minutes revisiting it before starting. That is normal and saves time later.
Goal of today Prove you really learned it. You will (1) review everything as one connected story, (2) rebuild one model without tutorials, (3) explain it clearly, (4) publish it.
Big picture — read this first The capstone is a proof of understanding, not just a final code dump. Explain the problem, input/output shapes, architecture, loss, training procedure, evaluation, and errors. The conceptual bridge to GenAI: After this course, continue with embeddings, vector databases, RAG, tool calling, agents, MCP, evaluation, security, FastAPI, Docker, and LLMOps.
(1) Attention → (2) Transformer → (3) Decoder-only Transformer → (4) Next-token prediction → (5) LLM
PART A — THE BIG PICTURE (one connected story)
Everything in these 15 days is the same story told at increasing levels:
DATA → MODEL → LOSS → OPTIMIZE (gradient descent) → EVALUATE → (fix overfitting) → repeat
| Da y | What you learned | One-line memory |
|---|---|---|
| 1 | NumPy/Pandas | Data lives in arrays/tables; think in shapes , avoid loops |
| 2 | Regression + GD | Model ŷ = wx + b ; loss = MSE; learn by w -= lr · gradient |
| 3 | Overfitting, Ridge/Lasso, CV | Goal is generalization; penalize big weights; rotate validation folds |
| 4 | Metrics, trees, boosting | Precision/recall over accuracy on imbalance; forest = vote, boosting = fix errors |
| 5 | k-NN, k-Means, PCA, embeddings | Similar = close; embeddings = meaning as vectors |
| 6 | NN from scratch | A = f(XW+b) ; backprop = chain rule backward |
| 7 | PyTorch | Autograd + zero_grad → forward → loss → backward → step |
| 8 | MLP/CNN, dropout, early stop | Conv filters exploit image structure; regularize with dropout/early stop |
| 9 | Attention/Transformers | softmax(QKᵀ/√d)V ; block = attention + FFN + residual + norm |
Concept map
Linear regression ──► Logistic regression ──► Neuron ──► Neural network (MLP)
│ │
Gradient descent ◄────────── backprop / autograd ─────────┤
├─► CNN (images)
Overfitting fixes: Ridge/Lasso · dropout · early stop · CV ├─► Transformer (text)
─► LLMsPART B — REVISION CHECKLIST (tick honestly)
Data & basics
□ I can explain shape, axis, broadcasting, and @ with an example □ I can clean a dataset: missing values, duplicates, types, encoding □ I know when to use label vs one-hot encoding
Core ML
□ I can write ŷ = wx + b, MSE, and the gradient-descent update from memory □ I know what happens if the learning rate is too high/low □ I can diagnose under/overfitting from train-vs-val error □ I can explain Ridge vs Lasso, and k-fold CV □ I can compute precision, recall, F1 from a confusion matrix □ I can explain bagging (forest) vs boosting □ I know 3 ways to handle class imbalance
Deep learning
□ I can draw a neuron and a 2-layer network with shapes □ I can explain forward pass, loss, backprop, update □ I can write a PyTorch training loop from memory and explain each line □ I can explain convolution, filters, feature maps, pooling □ I can explain dropout and early stopping
Transformers
□ I can write the attention formula and explain Q, K, V with an analogy □ I can draw the Transformer block from memory □ I know why we scale by √d_k, why positional encoding, why multi-head
If unsure → revisit that day’s notes, then redo the related mini exercise.
PART C — 60-SECOND FLASHCARDS (cover the answer, test
yourself)
| Question | Answer |
|---|---|
| What’s a broadcast-compatible pair? | Dimensions equal or one is 1 (from the right) |
| axis=0 in sum means | Collapse rows → one result per column |
| What does the gradient tell us? | How loss changes if a parameter increases |
| Why square errors? | Positive + punishes big errors |
| Question | Answer |
|---|---|
| High train acc, low val acc? | Overfitting |
| Precision vs recall? | Right when I say yes / found all the yeses |
| Why class_weight="balanced" ? | Make rare-class mistakes cost more |
| ReLU? | max(0, z) |
| Why activations? | Non-linearity; otherwise layers collapse into one linear map |
| Backprop in one sentence | Chain rule from loss back to every weight |
| zero_grad() why? | PyTorch accumulates gradients |
| Dropout at eval? | Off |
| MaxPool 2×2 effect | Halves height & width |
| Attention formula | softmax(QKᵀ/√d_k)V |
| Why positional encoding? | Attention has no notion of order |
| Decoder-only uses which mask? | Causal (lower-triangular) |
PART D — THE CAPSTONE
D1. Choose ONE model to rebuild (no tutorials, no copy-paste)
| Option | Difficulty | Best if you want to show |
|---|---|---|
| A. Linear/logistic regression from scratch (NumPy) | Easy | Strong fundamentals |
| B. 2-layer NN from scratch (NumPy) | Medium | You understand backprop |
| C. MNIST CNN in PyTorch | Medium | Practical deep learning * |
| D. Self-attention + a tiny text | Hard | GenAI readiness ** |
classifier / mini Transformer block
Recommended for a GenAI path: C or D. If short on time: C.
D2. “No tutorial” rules
- Close all notes and videos.
- Start from a blank file. Write the skeleton first (imports → data → model → loss → optimizer → loop → evaluate).
- When stuck for >10 min, look up only the one function/API (docs), not the whole solution.
- Note what you had to look up — those are your weak spots (list them in the README).
- Time yourself. Target: model trained within ~2 hours.
# 1. imports, seed, device
# 2. data: Dataset/DataLoader (train / val / test)
# 3. model: class Net(nn.Module): __init__, forward
# 4. loss + optimizer
# 5. train loop (zero_grad, forward, loss, backward, step) + validation loop
# 6. evaluate on test: accuracy / confusion matrix
# 7. plots: loss curves, sample predictions
# 8. save modelD3. Blank-page skeleton to fill in (PyTorch version)
D4. Explanation script — the 6 required parts Write each as 3–6 plain sentences (as if teaching a friend).
1. The problem
- What are we solving? Classification/regression? Why does it matter?
- Example: “Recognize handwritten digits from 28×28 grayscale images, as in postal code reading.”
2. Input and output
- Shapes and meaning. Example: Input
(B,1,28,28)normalized pixels; output(B,10)logits, one per digit; predicted digit = argmax.
3. How the model works
- Draw the architecture; walk through data flow layer by layer with shapes.
- Example: two conv+pool blocks extract edges then shapes; flatten; two linear layers classify; dropout regularizes.
4. The loss function
- Which and why. Example: Cross-entropy: penalizes low probability on the correct class; contains softmax; lower = better.
5. Training
- Optimizer, learning rate, batch size, epochs, regularization, early stopping; the 5-line loop and why each call matters.
6. Evaluation
- Metrics, curves, confusion matrix, error analysis. What worked, what failed, what you’d try next.
D5. Feynman test Explain the model to someone with no ML background in 5 minutes (record voice on your phone). Where you hesitate = where to study again.
PART E — CLEAN THE CODE
Checklist
□ Organize into files: data.py, model.py, train.py, evaluate.py (or a clean notebook) □ Functions instead of copy-pasted blocks □ Meaningful names ( train_loader, not dl1) □ Short docstrings on functions/classes □ Set seeds ( torch.manual_seed(42), np.random.seed(42)) □ No hard-coded local paths; use relative paths / Path □ Remove unused imports and debug prints □ Notebook runs Restart & Run All without errors □ requirements.txt (pip freeze | grep -E "torch|numpy|pandas|scikit|matplotlib" or
Key idea write manually)
□ .gitignore for data/, *.pt, __pycache__/, .ipynb_checkpoints/
Suggested folder
Day-10-Capstone/
├── README.md
├── requirements.txt
├── model.py
├── train.py
├── evaluate.py
├── notebooks/capstone.ipynb
├── results/
│ ├── loss_curves.png
│ ├── confusion_matrix.png
│ └── sample_predictions.png
└── .gitignorePART F — README TEMPLATE (recruiters read this first)
# <Project title> — e.g. MNIST Digit Classifier (CNN, PyTorch)
One-sentence summary + tech badges (Python · PyTorch · NumPy).
## Problem
## Dataset (source, size, splits)
## Model / Approach
(architecture diagram or table of layers with shapes)
## Training setup
| Optimizer | LR | Batch | Epochs | Regularization |
## Results
| Model | Val acc | Test acc |


## Error analysis / Insights
## What I learned / challenges
## ▶ How to run
pip install -r requirements.txt
python train.py
## Future improvements (data augmentation, batch norm, deeper model, etc.)Root README of the repo ml-dl-fundamentals/ : short intro + a table linking each day’s folder with a one-line summary and key result:
| Day | Topic | What I built | Key result |
|---|---|---|---|
| 1 | NumPy/Pandas | Vectorized cosine similarity, Titanic cleaning | 0 loops,
clean CSV |
| 2 | Regression | Linear regression from scratch vs sklearn | w,b match within
0.01 |
...PART G — WRITE THE POST (LinkedIn / blog)
Short LinkedIn structure (150–250 words)
- Hook (line 1 decides if people click):
- “I trained a CNN in PyTorch in 15 days. 3 things surprised me.”
- What I built (1–2 lines + repo link)
- 3 specific learnings (technical, concrete — e.g. “Forgetting
zero_grad()silently ruined train-ing”, “Accuracy hid my fraud model’s 0% recall”, “Attention is just a weighted average”) - A number or image (accuracy, loss curve screenshot)
- What’s next — “Next: embeddings → RAG → agents”
- Hashtags:
#MachineLearning #DeepLearning #PyTorch #GenAI#LearningInPublic
Draft (edit to your voice)
Key idea 15 days ago I could use ML libraries. Today I can explain what happens inside them. I built: linear regression with gradient descent, a neural net in pure NumPy, a PyTorch CNN (99% on MNIST), and self-attention — all in one repo. 3 lessons: 1. Accuracy lies on imbalanced data — precision/recall told the real story. 2. Backprop is just the chain rule applied backward — writing it by hand made PyTorch feel like magic-free. 3. Attention = softmax(QKᵀ/√d)V: a weighted average that lets each word look at every other word. Next up: embeddings, RAG and agents.
Blog outline (800–1200 words) Problem → Intuition (analogy) → Math (minimal) → Code (key snippets) → Results (plots) → Mistakes I made → Next steps.
PART H — COMMON MISTAKES
| Mistake | Better |
|---|---|
| Copying a tutorial and calling it a capstone | Rebuild blank-page; list what you looked up |
| README with no results | Always add metrics + plots |
| Only reporting accuracy | Add confusion matrix / other metrics |
| No explanation of why | Add insights + error analysis |
| Messy notebook | Restart & Run All before pushing |
| Committing datasets/large weights | .gitignore ; provide download instructions |
PART I — SELF-ASSESSMENT QUIZ (answer in writing)
- Why can a model with 100% training accuracy still be useless?
- Draw the loss curve shapes for lr too low, right, too high.
- Fraud model: 99.8% accuracy, 0% recall. Explain.
- Write the 5 lines of a PyTorch training step and explain each.
- Output size: input 28, kernel 3, padding 1, stride 2. → floor((28 + 2×1 − 3)/2) + 1 = 14 6. Explain Q, K, V using a library analogy.
- What’s the difference between BERT and GPT?
- Why does attention cost O(T²)?
Worked Problem · Compare Against A Dumb Baseline
Problem. Labels are [0,0,0,1,0,1,0,0]. A baseline always predicts 0. Your model predicts [0,0,0,1,0,1,0,1]. Compute accuracy for both and your model's precision and recall.
- Baseline accuracy: it is right on the six 0s, so 6 ÷ 8 = 0.75.
- Model accuracy: it differs only at the last position, so 7 ÷ 8 = 0.875.
- Model positives: it predicts 1 three times (positions 3, 5, 7). Two of them are real 1s, so precision = 2 ÷ 3 ≈ 0.667.
- There are two real 1s and the model found both, so recall = 2 ÷ 2 = 1.0.
- Always report the baseline: a model is only worth something if it beats it.
import numpy as np
y = np.array([0,0,0,1,0,1,0,0]); p = np.array([0,0,0,1,0,1,0,1])
print((y == 0).mean(), (y == p).mean())
tp = ((p == 1) & (y == 1)).sum()
print(round(tp / (p == 1).sum(), 3), tp / (y == 1).sum())0.75 0.875
0.667 1.0Answer. Baseline 0.75, model 0.875, precision 0.667, recall 1.0.
Your Turn · Report The Improvement Honestly
Problem. Baseline accuracy is 0.75 and the model's is 0.875. State the improvement in points and as a reduction in errors.
Try it on paper or in a notebook first. Then check the solution.
Solution — Step By Step
- Absolute improvement = 0.875 − 0.75 = 0.125, which is 12.5 percentage points.
- Baseline error = 0.25 and model error = 0.125.
- The error was cut in half: (0.25 − 0.125) ÷ 0.25 = 50%.
print(0.875 - 0.75, (0.25 - 0.125) / 0.25)0.125 0.5Answer. +12.5 points, which is a 50% reduction in errors. On only 8 samples this is too few to be conclusive, so say so in your README.
Move on when you can… ☐ state the minimum version of your project ☐ train a baseline and compare your model with it ☐ report the results honestly in a README ☐ list the limits of your project ☐ choose one optional challenge If you cannot tick most of these, repeat the worked problems for this day. Taking an extra day is fine; it is not falling behind.