Cheatsheet
Every formula, comparison table, and quick fact from all 9 modules, on one page — built for a last scroll-through the morning of the viva.
1. ML Fundamentals
full module →Accuracy
(TP + TN) / Total
Misleading on imbalanced data.
Precision
TP / (TP + FP)
Of flagged positives, how many were right.
Recall
TP / (TP + FN)
Of actual positives, how many were caught.
F1 score
2·(P·R) / (P + R)
Harmonic mean of precision & recall.
Total error
Bias² + Variance + Noise
The bias-variance decomposition.
Confusion matrix
| Predicted + | Predicted − | |
|---|---|---|
| Actual + | TP | FN |
| Actual − | FP | TN |
L1 vs L2 regularization
| L1 (Lasso) | L2 (Ridge) | |
|---|---|---|
| Penalty | Σ|w| | Σw² |
| Effect | Some weights → exactly 0 | All weights shrink smoothly |
| Good for | Feature selection | Multicollinearity |
Bagging vs boosting
| Bagging | Boosting | |
|---|---|---|
| Training | Parallel, independent | Sequential, each fixes last |
| Reduces | Variance | Bias |
| Example | Random Forest | Gradient Boosting |
- ▸Underfit = high = poor on train AND val.
- ▸Overfit = high = great on train, poor on val.
- ▸ CV: average the score across k train/val splits.
- ▸Fit preprocessing (scalers etc.) on train fold only — never on the full dataset.
2. Neural Networks & Deep Learning
full module →Sigmoid
σ(x) = 1 / (1 + e⁻ˣ)
Squashes to (0, 1).
Sigmoid derivative
σ'(x) = σ(x)·(1 − σ(x))
Reuses the forward-pass output.
ReLU
max(0, x)
Cheap, no saturation for x > 0.
Neuron output
a = f(Σ wᵢxᵢ + b)
Weighted sum + bias, then activation f.
Activation cheat table
| Function | Range | Typical use |
|---|---|---|
| Sigmoid | (0, 1) | Binary output layer |
| Softmax | (0,1), sums to 1 | Multi-class output layer |
| ReLU | [0, ∞) | Hidden layers (default) |
| tanh | (−1, 1) | Hidden layers (older nets, RNN gates) |
Vanishing/exploding gradient fixes
| Problem | Fix |
|---|---|
| Vanishing gradient | ReLU family, batch norm, residual connections, He/Xavier init |
| Exploding gradient | Gradient clipping, careful init, lower learning rate |
- ▸ = compute prediction. = compute how each caused the error.
- ▸No anywhere = whole network collapses to one linear function.
- ▸ normalizes per , speeds up + stabilizes training.
- ▸ → spatial locality (images). / → sequences. → parallelizable long-range context.
3. NLP Essentials
full module →TF-IDF
TF(t,d) × log(N / DF(t))
Term frequency × inverse document frequency.
Attention weight
softmax(Q·Kᵀ / √d)·V
Query-Key similarity → weighted sum of Values.
Text representation evolution
| Method | Understands context? | Notes |
|---|---|---|
| TF-IDF | No | Sparse, frequency counts only |
| Word2Vec / GloVe | No (fixed per word) | Dense, similar words are close |
| Transformer embeddings | Yes | Same word, different vector by sentence |
BERT vs GPT
| BERT | GPT | |
|---|---|---|
| Pretraining | Masked language modeling | Next-token prediction |
| Context | Bidirectional | Left-to-right (causal) |
| Best at | Understanding (classification, NER) | Generation (chat, completion) |
- ▸ () means the never truly hits an "unknown word."
- ▸ is crude/fast; is grammar-aware/correct.
- ▸: no training needed, use a pretrained with a prompt.
4. Math for AI
full module →Bayes' theorem
P(A|B) = P(B|A)·P(A) / P(B)
Update belief given new evidence.
Eigen equation
A·v = λ·v
v = eigenvector, λ = eigenvalue.
Expectation
E[X] = Σ x·P(x)
Probability-weighted average.
Variance
Var(X) = E[(X − E[X])²]
Spread around the mean.
Chain rule
dy/dx = f'(g(x))·g'(x)
The math behind backprop.
Distributions at a glance
| Distribution | Models… | Example |
|---|---|---|
| Normal | Continuous, symmetric measurements | Transaction amounts (log scale) |
| Bernoulli | Single binary trial | Is this one transaction fraud? |
| Binomial | n Bernoulli trials | Fraud count in n transactions |
| Poisson | Rare events per fixed interval | Fraud alerts per hour |
- ▸ = number of independent directions of information in a matrix.
- ▸ = eigenvectors of the covariance matrix, ranked by ( captured).
- ▸: sample means trend normal regardless of the original distribution.
- ▸A rare condition + an imperfect test ⇒ most positives are false positives (base-rate fallacy).
5. DSA Refresher
full module →Big-O growth (best to worst)
| Notation | Name | Example |
|---|---|---|
| O(1) | Constant | Array index access, hash lookup |
| O(log n) | Logarithmic | Binary search |
| O(n) | Linear | Single loop / scan |
| O(n log n) | Linearithmic | Good sorting (merge/quick sort) |
| O(n²) | Quadratic | Nested loop / naive pair check |
Which structure for which job
| Need | Use |
|---|---|
| Instant lookup / dedup / counting | Hash map |
| Sorted-input search | Binary search |
| Best contiguous subarray/substring | Sliding window |
| Pair/triplet in sorted array | Two pointer |
| Shortest path, unweighted | BFS |
| Explore all paths / backtracking | DFS |
- ▸Always state time AND space complexity after solving.
- ▸Reverse a linked list: three pointers — prev, curr, next.
- ▸Cycle detection: Floyd's fast-slow pointer.
- ▸Merge two sorted arrays: two pointers, always copy the smaller — the heart of merge sort.
6. Python / SQL / Data Manipulation
full module →SQL clause order
| Clause | Purpose |
|---|---|
| SELECT | Pick columns |
| WHERE | Filter rows before grouping |
| GROUP BY | Bucket rows sharing a value |
| HAVING | Filter after grouping (on aggregates) |
| ORDER BY | Sort results |
JOIN types
| Type | Returns |
|---|---|
| INNER JOIN | Only rows matching in both tables |
| LEFT JOIN | All left rows, NULLs where no match on the right |
pandas quick reference
| Task | Code |
|---|---|
| Filter rows | df[df.col > x] |
| Group + aggregate | df.groupby('col').agg(...) |
| Join two tables | df.merge(other, on='key') |
| Fill missing | df.fillna(value) |
- ▸ core: distances → np.argsort → majority vote of nearest K labels.
- ▸Always shuffle before a train/test split unless order is meaningful (time series).
7. Scenario & System Design for ML
full module →The 6-step framework
| # | Ask |
|---|---|
| 1 | Goal — what does success mean, in business terms? |
| 2 | Data — what exists, what's missing, how skewed? |
| 3 | Approach — simplest baseline first, justify complexity |
| 4 | Evaluation — the right metric, not just accuracy |
| 5 | Constraints — latency, cost, interpretability, fairness |
| 6 | Failure modes — what breaks, how would you notice? |
Loss curve diagnosis
| Pattern | Diagnosis |
|---|---|
| Both high & flat | Underfitting |
| Train low, val high & diverging | Overfitting |
| Both dropping, val noisy/spiking | Learning rate too high |
| Both dropping, painfully slow | Learning rate too low |
- ▸Say the framework out loud before naming any technique.
- ▸"Count objects in video" is a tracking problem ( + track IDs), not just detection.
- ▸No labels yet? / zero-shot → bootstrap labels → distill to a small fast .
- ▸Lending models must be explainable — a regulator can demand the reason for every rejection.
- ▸Never hard-swap a that only won offline: shadow → canary → ramp, with rollback ready.
8. Research Paper Reading
full module →The 4-part paper summary
| Part | Question |
|---|---|
| Problem | What gap/limitation motivated this? |
| Method | Core idea in 1-2 sentences |
| Findings | What did they show, vs which baseline? |
| Implication | Why should anyone care? |
Efficient reading order
| Order | Section |
|---|---|
| 1 | Abstract |
| 2 | Conclusion |
| 3 | Figures / tables |
| 4 | Introduction |
| 5 | Skim: Method |
| 6 | Skip on first pass: most of Related Work |
- ▸Budget under 2 minutes to summarize any paper out loud using the 4-part structure.
- ▸Naming one honest limitation of your own work reads as more mature than claiming none.
9. Viva Soft Skills
full module →60-second self-intro shape
| ~20s | ~20s | ~20s |
|---|---|---|
| Background | One concrete project/thesis hook | Why this role, specifically |
- ▸Everything on your CV is fair game — only list what you can defend in depth.
- ▸Prepare 2 genuine questions for the panel; skip salary/benefits in a technical round.
- ▸Rehearse out loud, timed — recognizing an answer while reading is not the same as saying it fluently.