Review sheet
Data Preparation for ML and AI
The main points of this domain on a few screens, to reread before the exam.
1.1Storage and formats
- S3 stages: raw (never edited), curated, features, models.
- Hive-style partitions (year=2026/month=11/) let jobs skip folders.
- S3 request rates: at least 3,500 writes and 11,000 reads per second per partitioned prefix.
- Reproduce a dataset: S3 versioning with recorded version IDs, or a dated copy.
- Lifecycle: objects under 128 KB do not transition by default.
- FSx for Lustre linked to S3: fast repeated reads. It needs a VPC in training.
- EFS: shared datasets and notebooks. EBS: the volume of one instance.
- DataSync copies files in on a schedule. Storage Gateway is a local door to S3.
- Parquet and ORC: few columns of many rows. Avro: streams and schema change.
1.1Storage and formats
- Built-in algorithms: CSV with no header and the target first, or RecordIO-protobuf. FastFile and Pipe stream from S3.
1.1Sources and streaming
- RDS and Aurora: snapshot export to S3 as Parquet, no load on production.
- DynamoDB export to S3 needs point-in-time recovery and uses no read capacity.
- Kinesis shard: 1 MB/s or 1,000 records/s in, 2 MB/s out. Retention 24 hours to 365 days.
- On-demand streams start at 4 MB/s write. You can switch modes twice in 24 hours.
- Enhanced fan-out: 2 MB/s per consumer per shard. Up to 20 consumers per stream, or 50 on On-demand Advantage.
- Rising iterator age: consumers are behind. Add shards or consumers, or use fan-out.
- Firehose S3 buffer: 1 to 128 MiB (64 or more with conversion) and 0 to 900 seconds. Conversion needs JSON and a Glue table.
1.1Sources and streaming
- Flink: state, windows, joins. One KPU is 1 vCPU and 4 GB. Default 64 KPUs.
- MSK: Kafka API and partitions. Serverless, provisioned or Express brokers. MSK Connect for connectors.
- S3 503 Slow Down: more prefixes, backoff, ramp up. Raise soft quotas in Service Quotas.
Custom consumers, replay, ordering per key
Deliver to S3 or OpenSearch with no code, convert to Parquet
Windows, joins and state on live data
Existing Kafka code and tools
Small stateless per-record code
- Lambda
| Streaming need | Pick |
|---|---|
| Custom consumers, replay, ordering per key | |
| Deliver to S3 or OpenSearch with no code, convert to Parquet | |
| Windows, joins and state on live data | |
| Existing Kafka code and tools | |
| Small stateless per-record code | Lambda |
1 / 2
Custom consumers, replay, ordering per key
Deliver to S3 or OpenSearch with no code, convert to Parquet
Windows, joins and state on live data
| Streaming need | Pick |
|---|---|
| Custom consumers, replay, ordering per key | |
| Deliver to S3 or OpenSearch with no code, convert to Parquet | |
| Windows, joins and state on live data |
1.1Catalog, merge, vectors and features
- Crawlers fill the Data Catalog. Athena, EMR and Spectrum share it.
- Lake Formation grants table, column, row and tag access. Direct S3 permission bypasses it.
- Align key types and case before a join. Union by column name, not position.
- Spark broadcast join for a small table (default under 10 MB). Shuffle join for two large ones.
- Glue job bookmarks read only new data on each run.
- The index dimension must equal the embedding model output size.
- OpenSearch k-NN: HNSW (fast, memory heavy) or IVF (clusters, training step). Serverless or domain.
- pgvector: HNSW or IVFFlat, operators <->, <=>, <#>. Indexes cover up to 2,000 dimensions.
1.1Catalog, merge, vectors and features
- Feature Store ingestion needs a record identifier and an event time. PutRecord fills online at once, offline in batches.
OpenSearch
- Hybrid keyword plus vector search at scale
Aurora, RDS pgvector
- Vectors with SQL rows in one query
S3 Vectors
- Huge, less active data at the lowest cost
Neptune Analytics
- Graph links plus vectors
DocumentDB
- Documents are already stored there
| Vector store | Pick it when |
|---|---|
| OpenSearch | Hybrid keyword plus vector search at scale |
| Aurora, RDS pgvector | Vectors with SQL rows in one query |
| S3 Vectors | Huge, less active data at the lowest cost |
| Neptune Analytics | Graph links plus vectors |
| DocumentDB | Documents are already stored there |
1.2Transform tools
- Glue job types: Spark, Spark streaming and Python shell. Ray closed to new customers on 2026-04-30.
- Do not pick Ray for new work. One DPU is 4 vCPUs and 16 GB.
- DynamicFrame: self-describing records, with choice types for mixed columns.
- Glue Flex execution class: lower price for non-urgent jobs.
- DataBrew: no-code, 250+ transforms, profile jobs, PII mask, hash and encrypt.
- EMR: Spot on task nodes, On-Demand on primary and core nodes. Serverless and EKS options.
- Data Wrangler lives in SageMaker Canvas. It exports to S3, Pipelines, Feature Store or code.
- Processing jobs: S3 in, script on managed instances, S3 out. A ProcessingStep joins a pipeline.
1.2Transform tools
- Athena CTAS writes partitioned Parquet. One statement writes at most 100 partitions.
- Partition projection skips crawlers. Iceberg adds UPDATE, DELETE, MERGE and time travel.
- Code, large scale, serverless Spark, streaming ETL
- No-code cleaning, profiling, PII transforms
- Custom libraries, tuning, Spot, Hadoop stack
- Visual prep in Canvas, export to Pipelines
- Run any script on managed instances
- SQL transform with CTAS, Parquet output
| Tool | Pick it when |
|---|---|
| Code, large scale, serverless Spark, streaming ETL | |
| No-code cleaning, profiling, PII transforms | |
| Custom libraries, tuning, Spot, Hadoop stack | |
| Visual prep in Canvas, export to Pipelines | |
| Run any script on managed instances | |
| SQL transform with CTAS, Parquet output |
1 / 2
- Code, large scale, serverless Spark, streaming ETL
- No-code cleaning, profiling, PII transforms
- Custom libraries, tuning, Spot, Hadoop stack
- Visual prep in Canvas, export to Pipelines
| Tool | Pick it when |
|---|---|
| Code, large scale, serverless Spark, streaming ETL | |
| No-code cleaning, profiling, PII transforms | |
| Custom libraries, tuning, Spot, Hadoop stack | |
| Visual prep in Canvas, export to Pipelines |
2 / 2
- Run any script on managed instances
- SQL transform with CTAS, Parquet output
| Tool | Pick it when |
|---|---|
| Run any script on managed instances | |
| SQL transform with CTAS, Parquet output |
1.2Features, streams and text
- Feature Store: online keeps the latest record, offline keeps all in S3. Up to 2,500 features per group.
- Point-in-time join: feature values as of each example, so no future data leaks in.
- Lambda on streams: batching window up to 5 minutes, parallelization factor 1 to 10, bisect on error.
- Stateful windows on streams: Flink, or Spark Structured Streaming in micro-batches.
- Z-score: mean 0. Min-max: fixed range. Log: tames skew. Fit scalers on training data only.
- Scale matters for k-NN, k-means, SVM, linear models, neural nets and PCA. Trees do not care.
1.2Features, streams and text
- One-hot for few categories. Ordinal for ordered. Target encoding for many, with leakage care.
- Titan Text Embeddings V2: up to 8,192 tokens, 1,024 dimensions by default. Same model for index and query.
- Stemming is a fast crude root. Lemmatization is a true base form. Subword tokens avoid unknown words.
1.2RAG, privacy and foundation model data
- Knowledge Base chunking: fixed-size, hierarchical, semantic, none or a custom Lambda.
- Parse tables and figures with a foundation model parser or Data Automation.
- Metadata goes in a .metadata.json file beside each document and is used as a query filter.
- Comprehend detects and redacts PII. Macie finds it in S3 but does not change data.
- Hash keeps joins. Tokenization is reversible. Generalization lowers precision.
- Fine-tuning data: JSONL prompt and completion, or messages for chat models.
- Continued pre-training: unlabeled domain text. Distillation: prompts or invocation logs.
- Hold out a validation set. The Bedrock service role needs S3 access.
Fixed-size
- A simple start, tune size and overlap
Hierarchical
- Match small child, return big parent
Semantic
- Cuts where meaning shifts, extra cost
Custom (Lambda)
- Your own splitting rules
| Chunking strategy | Pick it when |
|---|---|
| Fixed-size | A simple start, tune size and overlap |
| Hierarchical | Match small child, return big parent |
| Semantic | Cuts where meaning shifts, extra cost |
| Custom (Lambda) | Your own splitting rules |
1.3Quality and labels
- Glue Data Quality uses DQDL: IsComplete, Completeness, IsUnique, ColumnValues, RowCount.
- Rule recommendations are a starting point. Review them.
- Run rules on catalog tables or in an ETL job that can fail or route bad rows.
- Scores go to CloudWatch. Run events go to EventBridge. Anomaly detection needs history.
- DataBrew rules are for visual work. Glue Data Quality is for pipelines.
- Ground Truth (2026-07-30): closed to new customers. Ground Truth Plus support ended 2026-06-30.
- Workforces: public Mechanical Turk, private staff, vendor. Default 3 workers for classification.
- Automated labeling: at least 1,250 objects, 5,000 advised.
1.3Quality and labels
- Outliers: IQR for skew, z-score near 3 for normal data, Random Cut Forest for many features.
- Impute: mean, median, mode, previous value or a model. Add a missing indicator.
1.3Bias, imbalance and integrity
- Selection, sampling, measurement and label bias have different causes.
- Shuffle before splitting, but not time series. Use stratified splits for rare classes.
- Leakage: target leakage and train-test contamination. Test score high, production low.
- Clarify (2026-07-30): closed to new customers. Set label, positive value, facet and facet value.
- CI compares group sizes. DPL compares positive label shares. KL and JS compare distributions.
- Rare class: use F1 or PR AUC, not accuracy. Resample the training set only.
- SMOTE for numeric rows. Back-translation for text. Flip, crop and rotate for images.
1.3Bias, imbalance and integrity
- Prompt-response checks: schema, empties, length, duplicates.
- ApplyGuardrail screens text with no model call. Rekognition moderates images.
- Poisoning: approved sources, write control, versioning. Provenance: source, license, date, checksum.
Rare class, accuracy looks high
- F1 or PR AUC, resample, SMOTE, class weights
Test score high, production low
- Look for leakage: split first, fit on train only
Skewed numbers with gaps
- Median plus a missing indicator
Extreme values, many features
- Random Cut Forest, or IQR for one skewed column
Unreliable labels
- Several workers and consolidation
Bad rows must not reach the lake
- Glue Data Quality rule in the ETL job
| Problem | Fix |
|---|---|
| Rare class, accuracy looks high | F1 or PR AUC, resample, SMOTE, class weights |
| Test score high, production low | Look for leakage: split first, fit on train only |
| Skewed numbers with gaps | Median plus a missing indicator |
| Extreme values, many features | Random Cut Forest, or IQR for one skewed column |
| Unreliable labels | Several workers and consolidation |
| Bad rows must not reach the lake | Glue Data Quality rule in the ETL job |
1 / 2
Rare class, accuracy looks high
- F1 or PR AUC, resample, SMOTE, class weights
Test score high, production low
- Look for leakage: split first, fit on train only
Skewed numbers with gaps
- Median plus a missing indicator
Extreme values, many features
- Random Cut Forest, or IQR for one skewed column
| Problem | Fix |
|---|---|
| Rare class, accuracy looks high | F1 or PR AUC, resample, SMOTE, class weights |
| Test score high, production low | Look for leakage: split first, fit on train only |
| Skewed numbers with gaps | Median plus a missing indicator |
| Extreme values, many features | Random Cut Forest, or IQR for one skewed column |
2 / 2
Unreliable labels
- Several workers and consolidation
Bad rows must not reach the lake
- Glue Data Quality rule in the ETL job
| Problem | Fix |
|---|---|
| Unreliable labels | Several workers and consolidation |
| Bad rows must not reach the lake | Glue Data Quality rule in the ETL job |
Exam traps
- “Copy a DynamoDB table to S3 without using read capacity” → export to S3 from point-in-time recovery, not a Scan
- “Several consumers read one stream without slowing each other” → Kinesis enhanced fan-out, not more shards alone
- “Load streams into S3 as Parquet with no servers” → Firehose with a Glue table, not Kinesis Data Streams
- “Windows and joins on a live stream” → Managed Service for Apache Flink, not Lambda or Firehose
- “Vectors must join with SQL rows” → pgvector in Aurora, not a separate store
- “Queries fail after changing the embedding model” → dimension mismatch, re-embed and rebuild the index
Exam traps
- “Hide one column from analysts” → Lake Formation column permission, not a bucket policy
- “No-code cleaning by analysts” → DataBrew, not Glue ETL
- “Rolling counts over five minutes on a stream” → Flink or Spark windows, not plain Lambda
- “Test accuracy far above production” → data leakage, not underfitting
- “99 percent accuracy but no fraud found” → class imbalance: F1 or PR AUC, not accuracy
- “Keep joins working but hide an email” → hashing, not redaction