Based on the MLS-C01 exam guideReport an error
The most common failure happens not in modeling but in problem definition. "We want to reduce churn" is a business goal, not an ML problem. To translate it, you must fix three things.
If you get the problem type wrong, everything after it goes off the rails. The Specialty exam keeps testing this mapping through scenarios.
| Business question | ML problem type | Typical output | Representative algorithms |
|---|---|---|---|
| Is this transaction fraudulent? | Binary classification | Probability from 0 to 1 | XGBoost, Linear Learner |
| Which segment does this customer belong to? | Multiclass classification | Class label | XGBoost, k-NN |
| What will next month's revenue be? | Regression | Continuous value | XGBoost, Linear Learner, DeepAR (time series) |
| Which users form similar groups? | Clustering | Cluster ID | K-Means |
| What product will this user buy next? | Recommendation | Ranked list | Factorization Machines, Neural Topic family |
| Is this sensor value abnormal? | Anomaly detection | Anomaly score | Random Cut Forest |
| What is demand for the next 7 days? | Time series forecasting | Per-interval forecasts | DeepAR |
Supervised learning learns an input→output mapping from labeled data, and unsupervised learning finds structure without labels. Fraud detection is usually supervised binary classification, but if past fraud cases (positive labels) are extremely scarce, it shifts to unsupervised anomaly detection (Random Cut Forest). The same business problem changes problem type depending on label availability.
⚠️ Pitfall: If you memorize "fraud detection = always classification," you will pick the wrong answer in a scenario for a new service that has no labels. When you find clues in the passage like "there are almost no past cases" or "there is no labeling budget," unsupervised anomaly detection rises to a candidate answer.
An ML system is not built once and done. When data changes during operation (drift), the cycle starts over.
1. Data : Collect → Clean → Label → Store (data lake)
2. Features : Feature engineering → Transform → Feature Store
3. Model : Algorithm selection → Training → HPO tuning → Evaluation
4. Deploy : Real-time endpoint / Batch transform / Serverless
5. Monitor : Data & model quality drift → Retraining trigger
└──────────(loop back to stage 1)──────────┘
# The lifecycle as seen through the SageMaker SDK — separating concerns by stage
import sagemaker
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker.sklearn.processing import SKLearnProcessor
session = sagemaker.Session()
role = sagemaker.get_execution_role()
# Stages 1-2: cleaning + feature engineering as a Processing Job
processor = SKLearnProcessor(
framework_version="1.2-1",
role=role,
instance_type="ml.m5.xlarge",
instance_count=1,
)
processor.run(
code="preprocess.py",
inputs=[ProcessingInput(source="s3://my-lake/raw/", destination="/opt/ml/processing/input")],
outputs=[ProcessingOutput(source="/opt/ml/processing/train", destination="s3://my-lake/features/train")],
)Training-serving skew is the performance degradation that happens when the feature transformation logic at training time differs from the logic at inference time. Fixing preprocessing in code (preprocess.py) and reusing it identically for training and inference, or managing features centrally with SageMaker Feature Store, reduces skew. Features improvised ad hoc in a notebook almost always create skew.
Even the same model gets a different deployment form depending on the nature of the traffic. The Specialty exam tests this choice through scenarios too.
| Deployment form | Behavior | Suitable situation |
|---|---|---|
| Real-time endpoint | Always-on instances, immediate response per request | Online inference that needs millisecond responses |
| Serverless inference | Starts automatically on request, scales to 0 when idle | Intermittent, unpredictable traffic; cold starts acceptable |
| Asynchronous inference | Queues the request and writes the result to S3 | Inference with large payloads or long processing times |
| Batch transform | Launches a job to score large volumes of data at once | Nightly bulk scoring; no need to keep an endpoint up |
⚠️ Pitfall: If you see only "reduce cost" and pick serverless unconditionally, you are wrong. If there is a clue that response latency (SLA) is strict, serverless with its cold starts is the wrong answer, and a real-time endpoint is the answer.
This is where the Specialty exam digs deepest. A single metric like accuracy deceives people. If fraud is 0.1% of all transactions, predicting only "all legitimate" yields 99.9% accuracy. That is why you must look at class imbalance and error costs together.
# Core classification metrics (based on the confusion matrix)
from sklearn.metrics import precision_score, recall_score, f1_score, roc_auc_score
# precision = TP / (TP + FP) → "of those flagged as fraud, the fraction that is real" (cost of false positives)
# recall = TP / (TP + FN) → "of actual fraud, the fraction caught" (cost of false negatives)
precision = precision_score(y_true, y_pred)
recall = recall_score(y_true, y_pred)
f1 = f1_score(y_true, y_pred) # harmonic mean of precision and recall
auc = roc_auc_score(y_true, y_score) # threshold-independent, ranking quality| Metric | Computation | What a high value means | When to prioritize | Pitfall |
|---|---|---|---|---|
| Accuracy | (TP+TN)/total | Often right overall | Only when classes are balanced | With imbalance, even "all negative" gives 99%+ |
| Precision | TP/(TP+FP) | Few false positives | False positives are costly (spam blocking, marketing sends) | Easy to raise by predicting only a few |
| Recall | TP/(TP+FN) | Few false negatives | False negatives are costly (fraud, cancer diagnosis) | Predicting everything positive gives 1.0 |
| F1 | Harmonic mean of precision and recall | Good balance between the two | When the two costs are similar | Hides which side is the problem |
| ROC-AUC | Area under the TPR-FPR curve | Threshold-independent discrimination | Threshold undecided, comparing models | Overly optimistic under extreme imbalance |
| PR-AUC | Area under the precision-recall curve | Discrimination for the minority class | Extreme imbalance (positives < 1%) | The value changes if the class ratio changes |
| RMSE | Square root of the mean squared error | Few large errors | Regression, when you want to penalize large errors heavily | Sensitive to outliers |
| MAE | Mean absolute error | Small average error | Regression, when you need robustness to outliers | Treats large errors leniently |
Business context decides which metric to optimize.
ROC-AUC (the area under the TPR-FPR curve) is relatively insensitive to class imbalance. But when positives are extreme, around 0.1%, ROC-AUC looks overly optimistic, so PR-AUC (the area under the precision-recall curve) gives a more honest signal. When the Specialty exam asks "which metric for imbalanced data?", the answer is usually PR-AUC, or whichever of recall/precision has the higher cost.
In a metric-selection question, "training loss" is a wrong answer. Loss is only an optimization target and does not reflect the business cost structure.
Good offline metrics do not guarantee that actual user behavior (revenue, dwell time) improves. That is why deployment is not a one-time event but a process of splitting traffic to validate. SageMaker puts multiple variants on one endpoint and distributes traffic by weight.
from sagemaker.session import production_variant
variant_a = production_variant(model_name="model-v1", instance_type="ml.m5.large",
initial_instance_count=1, variant_name="A", initial_weight=90)
variant_b = production_variant(model_name="model-v2", instance_type="ml.m5.large",
initial_instance_count=1, variant_name="B", initial_weight=10)
session.endpoint_from_production_variants(
name="fraud-endpoint", production_variants=[variant_a, variant_b]
)
# Send only 10% to the new model (B), compare business metrics in CloudWatch, then adjust weights[Offline gate] [Online verdict]
Train/validation set metrics ──pass──▶ Small-traffic A/B ──improvement confirmed──▶ Increase weight
(PR-AUC etc.) │ │
fail worse
▼ ▼
Do not deploy Roll back (weight 0)
Specialty passages stack multiple constraints. Reading in the order below solves most of them.
In a passage where constraints conflict, the answer is not the flashiest technology but the choice that satisfies all the constraints at once. If it violates even one constraint (for example, sensitive data sent to a public workforce), it is wrong regardless of its other advantages.
Tomorrow we cover where and in what format to keep this data (S3, EFS, FSx for Lustre; RecordIO, Parquet).
Click a choice to reveal the answer and explanation.
Question 1
A fintech company is building a fraud detection model on data where only 0.2% of transactions are fraudulent. The cost of a false negative (missing actual fraud) is far greater than that of a false positive. What is the most appropriate combination of evaluation metrics?
Question 2
When translating the request "we want to reduce customer churn" into an ML problem, what must be fixed first?
Question 3
A new payment service wants to start fraud detection but has almost no historical fraud labels. What is the most realistic approach?
Question 4
A recommendation model showed a large AUC improvement in offline evaluation and was deployed to all traffic immediately — and revenue dropped. What is the most appropriate way to prevent this in advance?
Question 5
What is the most essential reason to view the ML lifecycle as a "cyclical loop" rather than a "linear pipeline"?