Everything to recall on one screen
Each line maps an exam phrase to the answer it usually points to.
If the question says… pick
| “Visual, low‑code data prep inside SageMaker” | Data Wrangler (now inside SageMaker Canvas) |
| “Quick report on quality, leakage and imbalance before training” | Data Wrangler Data Quality and Insights report |
| “Rules that fail an ETL job when data is bad” | Glue Data Quality (DQDL rules) |
| “Analysts profile and clean data without code” | Glue DataBrew |
| “Reuse features across teams; same values in training and inference” | SageMaker Feature Store |
| “Millisecond feature lookup at inference” | Online store, GetRecord |
| “Full feature history for training” | Offline store in S3, query with Athena |
| “Features must update seconds after each event” | Lambda or Flink computing, then PutRecord |
| “Bias in the training data, before any model exists” | Clarify pre‑training bias (CI, DPL…) |
| “Bias in the model’s predictions” | Clarify post‑training bias |
| “Which features drive a prediction” | Clarify SHAP explanations |
| “Live endpoint inputs drift from training data” | Model Monitor data quality monitor |
| “Heavily right‑skewed number” | Log transform; cap at a high percentile |
| “Outliers distort scaling” | Robust scaling (median and IQR) or percentile capping |
| “Hour of day, day of week, month” | Sine and cosine (cyclical) encoding |
| “Few categories, no order” | One‑hot encoding |
| “Thousands of categories” | Target (out‑of‑fold), frequency or hash encoding |
| “Great validation score, poor in production” | Target leakage or train‑serve skew |
| “Positive class under 1%” | Judge by PR‑AUC, recall, F1; fix with class weights or resampling |
| “Data ordered in time” | Time‑based split, never a random shuffle |
| “Find which buckets hold PII” | Amazon Macie |
| “Detect and redact PII in text” | Amazon Comprehend PII detection |
| “Mask PII inside an ETL job” | Glue sensitive data detection or DataBrew masking |
| “Humans must label images or text” | SageMaker Ground Truth |
| “RAG answers lack surrounding context” | Hierarchical chunking in Bedrock Knowledge Bases |
| “Smaller model should mimic a larger one” | Bedrock Model Distillation |
| “Cheapest compute for a pandas preprocessing job” | Processing job on a CPU instance; Managed Spot is for training only |
Numbers and formulas
- Fraud share in this dataset: well under 1%
- Outlier fences: Q1 − 1.5·IQR and Q3 + 1.5·IQR
- Redundant pair: correlation above 0.9
- Z‑score: (x − mean) / std; min‑max: (x − min) / (max − min)
- Cyclical hour: sin(2π·h/24), cos(2π·h/24)
- Class imbalance CI: (na − nd) / (na + nd)
- DPL: qa − qd (positive‑label rates of the two groups)
- Bedrock KB default chunk: about 300 tokens
- Bedrock distillation: up to 15,000 prompts, 100+ recommended
Leakage in one breath
- Split first, then fit scalers, imputers and encoders on train only
- Rolling features use only the past; exclude the current row’s label
- Never turn the label into a feature (a customer’s fraud rate that includes today)
- Split by time when the future must be predicted
Feature Store in one breath
- Every record needs a record identifier and an event time
- Create the group, wait for Created, then ingest
- Online store is off unless you enable it
- Online writes copy to the offline store automatically
- Writer role needs
sagemaker:PutRecordon that group
MLA‑C02 tasks this module covers
All inside Domain 1, Data Preparation for ML and AI (28%).
The module on one page
Data leaves the Module 1 lake, gets explored and cleaned, becomes features, lands in Feature Store, and is checked for quality and bias before any model trains on it.
The dataset and its rare class
Each row is one card transaction with a 0/1 fraud label. Fraud is well under 1% of rows. Here are 1,000 transactions at a 0.5% rate: five are fraud.
A model that always answers “legitimate” is right 995 times out of 1,000 and catches nothing. Try it below.
Why accuracy lies
Out of 100,000 transactions with 500 frauds. Set how many frauds the model catches and how many legitimate ones it wrongly flags.
Every chart should change a decision
Exploratory data analysis (EDA) means looking at distributions, rates and relationships before building anything. The rule: each finding should lead to a specific feature choice.
Cleaning: missing values, outliers, time
Drop or impute?
Cap, don’t delete
In fraud data the extreme values are often the signal. Capping (also called winsorizing) pulls extreme values back to a limit and keeps the row. Remove a row only when the value is impossible: a negative amount, a date in the future, an age of 250.
Timestamps
Convert every timestamp to one time zone (UTC) before anything else, then extract hour, weekday and weekend flags. Time features only work if all rows speak the same clock.
Four feature families
| Family | Example | Fraud pattern it catches |
|---|---|---|
| Velocity | transactions and amount per card in the last 1 h, 24 h, 7 days | A stolen card used many times quickly |
| Amount scaling | z‑score against the card’s own recent mean | A purchase far outside this customer’s normal size |
| Merchant encoding | one‑hot category; category fraud rate from training data | Risky merchant types such as online retail |
| Time | hour_sin, hour_cos, is_night, weekday | Activity at hours this card never uses |
Before keeping a feature, ask five things: can you define it in one sentence, is it mostly populated, how many distinct values does it take, does it stay stable week to week, and does it move with the label at all?
Choosing a scaler
| Method | Formula | Use when | Watch out |
|---|---|---|---|
| Z‑score (standardize) | (x − mean) / std | Roughly bell‑shaped data; linear models, neural nets | Outliers inflate the std |
| Min‑max | (x − min) / (max − min) | You need 0 to 1, e.g. neural net inputs | One huge value squashes everything else |
| Robust | (x − median) / IQR | Outliers you want to keep | Less familiar to readers |
| Log | log(1 + x) | Long right tail: amounts, counts, income | Only for values ≥ 0 |
| Per‑entity z | (x − own mean) / own std | “Unusual for this customer” | Needs history; cold‑start fallback |
Choosing an encoding
Why hours need sine and cosine
Leakage: features that know the answer
Target leakage means a feature carries information the model would not have at prediction time, usually the label itself or data from the future. Validation scores look superb; production collapses.
Three common leaks
| Code | The leak | Fix |
|---|---|---|
groupby('merchant_category')['is_fraud'].mean() on all rows | Test rows’ labels shape their own encoding | Fit on training rows only, out‑of‑fold (scikit‑learn TargetEncoder) |
customer_fraud_rate = customer’s mean is_fraud over all history | Includes the current row’s label and the future | Use only labels confirmed before this transaction, or drop it |
StandardScaler().fit_transform and per‑customer mean/std on the full table | Test and future rows set the scale | Fit on train; per‑customer stats from a past‑only rolling window |
Split by time
SageMaker Data Wrangler
A visual tool for building data‑prep steps without code. It now lives inside SageMaker Canvas. The flow is saved as a JSON file you can version, and it can run at full scale as a job.
| Need | Data Wrangler | Glue DataBrew | Glue / EMR Spark |
|---|---|---|---|
| Who uses it | Data scientists in SageMaker | Analysts, no code | Engineers writing code |
| Best at | ML prep, leakage and bias insight, Feature Store export | Profiling, cleaning, data quality rules, PII masking | Large or custom ETL, joins, streaming |
| Scale | Job on processing instances | Serverless jobs | Any size |
SageMaker Feature Store
A shared library of features. Define a feature once, then training reads its history and the live model reads its latest value, so the two can’t drift apart (train‑serve skew).
Order of operations
- Prepare the DataFrame: a record identifier column, an event‑time column (Unix seconds or ISO‑8601 text), and string columns cast to pandas’ string type.
- Define features:
load_feature_definitions(df)infers Integral, Fractional and String types. - Create the group with an S3 location for the offline store, the identifier and event‑time names, a role, and
enable_online_store=Trueif you need live reads (off by default). - Wait until status is
Created; ingesting earlier fails. - Ingest: batch with
ingest(), or one record at a time withPutRecordfrom a stream. - Read:
GetRecordon the online store at inference; Athena on the offline store for training sets.
Data quality and bias
Which check, when
Clarify’s pre‑training bias metrics
A facet is the attribute you’re checking, such as region or age group. Clarify compares group a (often the larger or favoured group) with group d (the group that might be disadvantaged).
| Metric | Question it answers |
|---|---|
| CI Class imbalance | Is one group much smaller in the data? |
| DPL Difference in proportions of labels | Does one group get the positive label more often? |
| KL, JS divergence | How different are the groups’ label distributions? |
| LP, TVD, KS | Other distances between the groups’ label distributions |
| CDD Conditional demographic disparity | Does a gap persist within subgroups (set with group_name)? |
CI and DPL calculator
Security and cost
Least privilege for the pipeline role
Cost levers
- Right‑size: pandas work runs on general‑purpose CPU instances such as ml.m5; GPUs add cost and no speed.
- Billed per second while the job runs, so batch daily rather than running many tiny jobs.
- Managed Spot discounts apply to SageMaker training jobs, not Processing jobs.
- Alarms and budgets on processing spend, plus Feature Store metrics such as
Operation4XXErrorsto catch failing writes.
Hands‑on project: decide like an engineer
Three situations you will meet when a feature pipeline runs for real. Pick an answer, then open the reasoning.
1. The score that’s too good
Offline validation shows a PR‑AUC of 0.97. In a shadow test on live traffic, the same model scores 0.41.
- Collect more data
- Audit the features for leakage: rebuild them with a time‑based split and past‑only windows
- Switch to a larger model
Suggested answer
2. A merchant category nobody has seen
A new merchant type starts appearing in live traffic. It didn’t exist when you trained.
- Let the endpoint fail on unknown values
- Map unseen values to an “unknown” bucket fitted at training time, and monitor its share
- Retrain every time a new category appears
Suggested answer
OneHotEncoder(handle_unknown="ignore") or a reserved category) so inference never breaks. Track how many rows land there; when the share grows, retrain with real examples.3. Velocity that arrives a day late
A nightly job writes txn_count_1h to the online store. A card used five times in ten minutes still shows yesterday’s count.
- Run the batch job hourly
- Compute velocity on the event stream (Flink or Lambda) and write each update with PutRecord
- Have the endpoint query the offline store with Athena
Suggested answer
The build, step by step
- Load the processed Parquet from Module 1 and check schema, row count and fraud share.
- Split by time first: training months, a validation month, a test month.
- Clean: drop rows missing essentials, impute the rest with values learned from training data, convert timestamps to UTC, cap extreme amounts.
- Engineer: velocity over 1 hour, 24 hours and 7 days from earlier transactions only; a per‑card amount z‑score; sine and cosine of the hour; merchant encoding fitted on training data.
- Rebuild visually in Data Wrangler and export the flow and the Python code.
- Register a feature group keyed by card with an event‑time column: create, wait for Created, ingest.
- Check bias with a Clarify pre‑training report on a facet such as age band or region.
- See a leak for yourself: compute one feature the wrong way, a merchant fraud rate over all rows, and compare validation scores with the correct version. The jump you see is what leakage looks like.
The rest of the exam guide for this module
Every skill MLA‑C02 lists for Tasks 1.2 and 1.3, where it’s covered, then a short lesson for each one the sections above don’t fully reach.
| Skill in the exam guide | Where |
|---|---|
| 1.1.9 Ingest data into Feature Store | Section 8 |
| 1.2.1 Transform with Glue, DataBrew, Spark on EMR, Data Wrangler | Section 7, deep dive 1 |
| 1.2.2 Create and manage features in Feature Store | Section 8 |
| 1.2.3 Transform streaming data (Lambda, Spark) | Deep dive 2 |
| 1.2.4 Scaling, standardizing, splitting, binning, log, normalizing | Section 5, deep dive 1 |
| 1.2.5 Embedding models for text and images | Deep dive 6 |
| 1.2.6 Tokenization, domain‑specific augmentation | Deep dive 6 |
| 1.2.7 RAG document prep: chunking, metadata | Deep dive 6 |
| 1.2.8 Mask, redact, anonymize | Deep dive 5 |
| 1.2.9 Data for fine‑tuning, continued pre‑training, distillation | Deep dive 6 |
| 1.3.1 Validate quality (DataBrew, Glue Data Quality) | Section 9, deep dive 3 |
| 1.3.2 Label and annotate data | Deep dive 3 |
| 1.3.3 Find and mitigate bias (split, shuffle, augment) | Section 9, deep dive 4 |
| 1.3.4 Bias metrics across numeric, text, image | Section 9, deep dive 4 |
| 1.3.5 Resolve class imbalance | Section 2, deep dive 4 |
| 1.3.6 Validate AI training data (prompt‑response pairs, safety) | Deep dive 6 |
| 1.3.7 Clean: outliers, imputation, dedup | Section 4 |
Deep dive 1: the rest of the feature engineering toolbox
| Technique | What it does | Example |
|---|---|---|
| Binning | Turns a number into ranges | age → 18–25, 26–40, 41–65, 65+; quantile bins give equal counts per bin |
| Feature splitting | Breaks one field into useful parts | timestamp → hour, weekday; “Toronto, ON” → city, province; email → domain |
| Log transform | Compresses a long right tail | np.log1p(amount) |
| Feature crossing | Combines two features into one | merchant category × is_night |
| Dimensionality reduction | Fewer columns that keep most information | PCA on many correlated numeric features |
Glue jobs and Spark on EMR do the same transformations in code at large scale; DataBrew does many of them without code.
Deep dive 2: transforming streaming data
Velocity features are only useful at inference if they are fresh. Batch jobs that run nightly can’t tell you a card was used three times in the last minute.
Deep dive 3: data quality rules and labeling
Glue Data Quality uses a small rule language, DQDL. A failed rule can stop the job before bad data reaches training:
Rules = [
IsComplete "trans_num",
IsUnique "trans_num",
Completeness "category" > 0.95,
ColumnValues "amt" > 0
]
DataBrew offers the same idea without code: profile a dataset, then attach data quality rules to a job. A completeness rule is exactly what catches a column that suddenly goes blank.
| Labeling need | Service |
|---|---|
| Your own or vendor workforce labels images, text, video; optional automated labeling to cut cost | SageMaker Ground Truth |
| AWS runs the whole labeling project for you | Ground Truth Plus |
| Humans review low‑confidence predictions in production | Amazon Augmented AI (A2I) |
Deep dive 4: fixing imbalance and bias
Bias in text and images works the same way as in tables: check how each group is represented (counts per group, label rates per group) and rebalance with more data, augmentation or reweighting. Shuffling before splitting removes order effects when data isn’t time‑dependent.
Deep dive 5: masking and redacting sensitive data
Deep dive 6: preparing data for generative AI
| Skill | What to know |
|---|---|
| Embeddings (1.2.5) | An embedding model (Bedrock Titan Text Embeddings, Nova multimodal embeddings, Cohere Embed) turns text or images into number lists. The vector index dimension must match the model’s output; use the same model for documents and queries. |
| Tokenization (1.2.6) | Models count tokens, not words or characters. Context windows, chunk sizes and prices are all in tokens. |
| Augmentation (1.2.6) | Add domain examples: paraphrases, back‑translation, synthetic examples from an FM, then review them. |
| Chunking (1.2.7) | Bedrock Knowledge Bases offers default (about 300 tokens, whole sentences), fixed‑size with overlap, hierarchical (match small child chunks, return the larger parent), semantic (split where meaning changes; uses an FM, costs more), or no chunking. |
| Metadata (1.2.7) | Attach source, date, department and so on to each chunk so retrieval can filter (“policies from 2026 only”). |
| Fine‑tuning data (1.2.9) | Labeled prompt and desired‑response pairs in JSONL; the exact schema depends on the model. |
| Continued pre‑training (1.2.9) | Large amounts of unlabeled domain text; teaches vocabulary and style, not tasks. |
| Distillation (1.2.9) | You supply prompts (up to 15,000; 100+ recommended); a large teacher model writes answers that train a smaller student. Can also draw from invocation logs. |
| Data integrity (1.3.6) | Validate the JSONL format, remove duplicate and contradictory pairs, strip PII, and screen for unsafe or toxic content before training. |
Self‑check questions
Answer each one aloud first, then open it to check.
Exploring data vs engineering features: what’s the difference, and why do you need both?
EDA is looking: distributions, missing values, class balance, correlations, rates by category. Feature engineering is building: new columns that turn what you found into signals a model can use. EDA without feature engineering leaves insights unused; feature engineering without EDA encodes guesses, and you may build features you don’t understand or that leak the label.
Why does a rare positive class change how you explore and evaluate?
Fraud is well under 1% of rows. A model that never predicts fraud scores over 99% accuracy and is useless, and training updates are dominated by the majority class. During EDA you measure the imbalance so you choose honest metrics (recall, precision, F1, PR‑AUC), split so test sets contain fraud (stratified or by time), and plan class weights or resampling.
When do you drop missing data, and when do you fill it in?
Drop when the value is essential or impossible to guess: a row without a timestamp or amount, or a column that is mostly empty. Impute when the column is useful and only a little is missing: a missing merchant category becomes “unknown” or the mode; a missing amount in a skewed column gets the median. If missingness is meaningful, impute and add a flag column. Fit imputers on training data only.
Compare three ways to scale transaction amounts
- Global z‑score: simple, but outliers stretch the scale and it ignores who the customer is.
- Min‑max to 0–1: bounded, but one extreme value squashes everyone else.
- Per‑customer z‑score: captures “unusual for this person”, the strongest fraud signal, but needs history and a fallback for new customers.
Also useful: a log transform for the long tail, and robust scaling when outliers must stay.
What is a velocity feature, and why does it catch fraud?
Velocity is how often and how much a card is used in a recent window: count and total amount in the last hour, day or week. Stolen cards are typically used many times in quick succession, often small test charges first. Velocity catches that burst even when each single transaction looks normal. Compute it only from earlier transactions, and keep it fresh with streaming updates if it feeds a live model.
How does target encoding work, and what can go wrong?
Target encoding replaces each category with the average label for that category, for example the fraud rate of “shopping_net”. It handles thousands of categories in one column. The risk is target leakage: if the averages include test rows or the current row, the feature contains the answer. Compute it on training data only, use out‑of‑fold encoding inside training, and smooth rare categories toward the overall rate.
Why encode hour of day with sine and cosine?
As a plain number, 23:00 and 00:00 look 23 apart even though they are one hour apart. Mapping the hour onto a circle with sine and cosine puts them next to each other, so the model sees the real distance. The same applies to weekday and month.
Online store vs offline store: what does each do?
The online store keeps the latest value per record for millisecond reads by a live endpoint (GetRecord). It is off by default. The offline store keeps every version in S3, cataloged for Athena, for building training sets and audits. Online writes are copied to the offline store automatically, so training and inference share one definition of each feature.
What is demographic parity, and why does it matter for fraud models?
Demographic parity means each group receives the positive outcome (here, a fraud flag or decline) at a similar rate. In fraud detection, a model that flags one region or age group far more often wrongly declines honest customers in that group, which hurts customers and can break regulations. Before training, Clarify’s CI and DPL show whether the data is already skewed; after training, post‑training metrics show whether the model is.
How would you secure a pipeline that handles customer data?
- Least‑privilege roles: read raw, write features, PutRecord on one feature group, one KMS key; no wildcards, no delete
- KMS encryption for S3 and both feature stores; TLS in transit
- Jobs inside a VPC with VPC endpoints; no public internet access
- Mask, hash or drop PII before it becomes a feature; Macie to find stray PII
- Lake Formation or IAM to limit who can read the offline store
- CloudTrail for auditing, and alarms on failed writes
Exam drill
Scenario questions in the exam’s style. Tap an answer to see why.
0 / 0Common traps and outdated advice
Mistakes that show up often in tutorials and sample code, with the fix.
- Public fraud datasets name columns differently. The Kaggle credit card transactions set uses
trans_date_trans_time,cc_num,merchant,category,amtandis_fraud. Map names before reusing anyone’s code. - Quick pandas code leaks labels easily:
groupby('category')['is_fraud'].mean()on all rows, a customer’s all‑time fraud rate, orStandardScaler().fit_transformon the whole table. Fit on training rows only (section 6). - Per‑customer statistics computed over full history include the future. Use a rolling window over earlier transactions.
- Clipping at Q3 + 1.5·IQR on heavily skewed amounts flattens much of the tail. Check amounts by label first (
df.groupby('is_fraud')['amt'].describe()) and choose a percentile cap. - Assigning a
groupby().rolling()result back withreset_index(drop=True)only lines up if the DataFrame’s index was reset after sorting. - Most scikit‑learn estimators raise an error on missing values rather than silently passing them through; a few tree models handle them natively.
- Model Monitor checks data sent to a deployed endpoint or batch transform. For data before training, use Glue Data Quality, DataBrew or the Data Wrangler report.
- In Clarify,
group_namefeeds the conditional demographic disparity (CDD) metric. Each run also needs a facet name and the facet values to compare. - Demographic parity, equalized odds and predictive parity need predictions, so they are post‑training checks.
- Feature Store’s
load_feature_definitionsrejects plain object and datetime columns: cast text to pandas’ string type and convert timestamps first. Keying transaction rows by customer keeps only each customer’s latest row in the online store. - Claims that one feature family lifts AUC by a fixed amount are anecdotes. Measure the lift on your own validation split.
- pandas 3.0 (January 2026) removed the uppercase
'H'alias: write'1h', not'1H'. Feature Store has supported SageMaker Python SDK v3 (3.8.0+) since May 2026; older examples use v2 import paths.