Data Preparation for ML and AI
Learning goals
- Ingest data from sources such as S3, EFS, FSx, RDS and DynamoDB, and from streaming with Kinesis, Flink and Kafka, in a format suited to the purpose (Parquet, ORC, CSV, JSON)
- Transform data and create features with Glue, DataBrew, Spark on EMR, Data Wrangler and Feature Store, choosing appropriately among scaling, binning, log transforms and encoding
- Prepare RAG documents with embeddings, chunking and metadata extraction, and choose vector stores such as OpenSearch, pgvector and S3 Vectors
- Validate quality with Glue Data Quality and DataBrew, label with Ground Truth, and address class imbalance with Clarify bias metrics and resampling
Key points
- Formats: when analytics reads only some columns, use columnar Parquet or ORC (good compression, less data read). For row-wise appends and logs, use JSON or CSV. Some SageMaker AI built-in algorithms read fast in Pipe mode with RecordIO-protobuf.
- Storage: S3 is the default home for training data. For training that reads many small files at high speed, use FSx for Lustre (integrated with S3); for sharing across multiple instances, use EFS. For large uploads from distant locations, use S3 Transfer Acceleration.
- Streaming: ingest with Kinesis Data Streams, transform with Managed Service for Apache Flink or Lambda, and deliver to S3 and elsewhere with Data Firehose. For existing Kafka assets, use MSK.
- Transformation tools: for code-free visualization and transformation, Data Wrangler or DataBrew; for large-scale ETL, Glue (Spark) or EMR. Use Feature Store (online and offline) so created features share the same definitions in both training and inference.
- Feature engineering: standardization (mean 0, variance 1) and normalization (0–1), log transforms for skewed distributions, binning numeric ranges, one-hot encoding for categories (unordered) and label encoding (ordered). Impute missing values, handle outliers and remove duplicates.
- Generative AI data: convert text and images to vectors with embedding models. RAG retrieval accuracy changes with chunking (fixed-size, hierarchical, semantic) and metadata. Also prepare training data for fine-tuning, continued pre-training and distillation with consistent formats and quality.
- Personal information: mask, redact or anonymize before using data for training or RAG. Find sensitive data in S3 with Macie, and meet PII, PHI and data residency requirements.
- Quality and bias: validate missing values, ranges and uniqueness with Glue Data Quality or DataBrew rules. Label with Ground Truth (combining people and automated labeling). Measure bias with Clarify pre-training metrics (class imbalance CI, difference in proportions of labels DPL and others), and address it with oversampling, undersampling, synthetic data (such as SMOTE) and stratified splits.
Workplace uses
- SalesJoin CRM opportunity data with web access logs in Glue and register features such as “visits in the last 30 days” in Feature Store. Use the same features for training the win-prediction model and for real-time inference on the sales screen.
- General AffairsChunk internal policy PDFs by heading, attach department and revision date as metadata, and store them in a vector store, so old versions of policies do not show up in search.
- AccountingIn expense fraud detection, fraud examples make up only 0.5% of the total. Confirm class imbalance with Clarify, oversample only the training data, and evaluate on test data with the original ratio.
Exam objectives (from the exam guide)
- 1.1 データを収集して保存する。
- 1.2 データ変換、特徴量エンジニアリング、前処理を実行する。
- 1.3 データ品質を検証し、バイアスを管理する。
Learning resources
- SageMaker Data Wrangler (official) ↗
- SageMaker Feature Store (official) ↗
- AWS Glue Data Quality (official) ↗
- What is AWS Glue DataBrew (official) ↗
- What is Amazon FSx for Lustre (official) ↗
- Knowledge base chunking (official) ↗
- Clarify: pre-training bias metrics (official) ↗
- SageMaker Ground Truth (official) ↗
- MLA-C02 exam guide / study guide ↗