MLA-C02 Cheat Sheet

SageMaker algorithms & metrics first. Read the cue, then the answer. Unofficial study notes, not affiliated with AWS.

How to pick an algorithm

Match three things, then eliminate by mismatch.

1 · Task
regression · classification · clustering · anomaly detection · forecasting · embeddings · topic modeling
2 · Data type
tabular · text · sequences · images · time series · (entity, IP) pairs
3 · Labels?
Labeled → supervised. "Unlabeled" → K-Means, PCA, RCF, IP Insights, LDA, NTM, Word2vec.

Time series is a data type; forecasting is a task. Time-series data + "anomaly" = Random Cut Forest, not DeepAR. "BEST fit" + "does not need X" = the simplest tool that meets the stated need.

Cue in the questionAnswer

All 18 built-in algorithms

Facts checked against AWS docs.

AlgorithmWhat it doesTypeInputHardware

Exam traps

Format traps
  • Factorization Machines: protobuf only, no CSV for training
  • Image algorithms: MXNet RecordIO, not protobuf
  • Seq2Seq: protobuf with integer tokens
  • IP Insights: CSV, File mode only
  • DeepAR: JSON Lines / Parquet
Hardware traps
  • GPU only: Seq2Seq, Semantic Segmentation
  • CPU only: LightGBM, LDA (single instance)
  • RCF: no GPU benefit. K-Means: single-GPU instances at most
  • XGBoost / LightGBM are memory-bound: prefer M5 over C5/C4
  • DeepAR inference: CPU only
Look-alikes
  • Words → BlazingText; arbitrary objects/pairs → Object2Vec
  • LDA vs NTM: LDA CPU/perplexity; NTM GPU/coherence
  • Factorization Machines vs DeepAR: "many products" ≠ recommender; check the task
  • Linear Learner vs XGBoost: simple baseline vs nonlinear / best accuracy
  • Random forest is not a built-in algorithm

Metrics

Confusion matrix
Predicted +
Predicted −
Actual +
TP
FN
Actual −
FP
TN

Recall and specificity are about actual rows. Precision is about predicted positives.

Which to optimize
  • Recall: missing a positive is dangerous (fraud, disease). Minimize false negatives.
  • Precision: false alarms are costly (spam, $500 investigations). Minimize false positives.
  • F1: need both, especially on imbalanced data.
  • Accuracy: only on balanced data. A 99.9%-accurate "always not fraud" model has 0% recall.
  • ROC-AUC: compare models across all thresholds. 0.5 = random.
MetricFormulaAlso called / note
Regression metrics
  • RMSE: √(mean squared error). Same units as target. Penalizes large errors.
  • MAE: mean absolute error. Linear; less sensitive to outliers.
  • R²: share of variance the model explains.
  • Precision / recall / F1 are classification metrics, not regression.
Memory trick
  • Sensitivity catches the positives. Specificity clears the negatives.
  • Recall denominator = TP + FN. Precision denominator = TP + FP.
  • Specificity = 1 − false positive rate.
  • F1 is the harmonic mean: pulled toward the lower of P and R.

Over/underfitting & ensembles

Standard ML knowledge (not separately checked against AWS docs).

Overfitting (high variance)
Train error low, validation error high.
  • L2, dropout, early stopping, more data, simpler model
  • L1 if you also want feature selection
Underfitting (high bias)
Both errors high.
  • More capacity, more features, train longer
  • Reduce regularization
L1 vs L2
  • L1 (Lasso): abs weights; can hit exactly 0 → sparse model
  • L2 (Ridge / weight decay): squared weights; shrinks, never drops
Bagging vs boosting
  • Bagging: parallel, bootstrap samples, average → cuts variance (random forest)
  • Boosting: sequential, each fixes the last → cuts bias (XGBoost, LightGBM, AdaBoost)

Neural network training

Core rules of thumb.

Batch size
  • Small: noisy, avoids local minima, more updates/epoch
  • Large: smooth, can converge on a wrong solution
  • Steps per epoch = dataset ÷ batch size
Learning rate
  • Large: overshoots; loss oscillates or diverges → lower it
  • Small: slow but stable → raise it if progress is crawling
Vanishing gradient
Early layers stop learning; loss stalls.
  • Fixes: multi-level hierarchy, LSTM, ResNet, ReLU
Exploding gradient
Loss spikes or NaN.
  • Gradient clipping, lower learning rate, weight init, batch norm
SageMaker Debugger detects both.

Data preparation

SituationUse

Services & infrastructure

NeedService