Study guide
3.2 Interactive Data Preparation with SageMaker Data Wrangler
AWS Certified Machine Learning Engineer — Associate MLA-C01
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Introduction & Exam Strategy
1.1 AWS MLA-C01 Blueprint, Format & Strategy 1.2 The Machine Learning Engineering Lifecycle on AWS
2 Domain 1: Data Ingestion & Storage Architecture for ML
2.1 Ingesting Batch and Streaming Data for ML 2.2 High-Performance Storage for Training and Inference 2.3 Data Cataloging, Governance, and Querying
3 Domain 1: Feature Engineering & Data Transformation
3.1 Distributed Feature Engineering with AWS Glue & DataBrew 3.2 Interactive Data Preparation with SageMaker Data Wrangler 3.3 Feature Management with SageMaker Feature Store
4 Domain 1: Data Quality, Integrity & Ground Truth Labeling
4.1 Data Validation, Schema Drift, and Quality Rules 4.2 Handling Missing Values, Outliers & Class Imbalance 4.3 Data Labeling with SageMaker Ground Truth & Ground Truth Plus
5 Domain 2: Model Selection & Framework Architecture
5.1 SageMaker Built-in Algorithms & Selection Criteria 5.2 Custom Models with Script Mode and BYOC 5.3 Foundation Models, JumpStart, and Amazon Bedrock
6 Domain 2: SageMaker Model Training & Hyperparameter Optimization
6.1 SageMaker Training Jobs & Cost Optimization 6.2 Distributed Training Strategies & Architectures 6.3 Hyperparameter Optimization with Automatic Model Tuning (AMT)
7 Domain 2: Model Evaluation, Tracking & Model Registry
7.1 ML Evaluation Metrics & Validation Strategies 7.2 Experiment Tracking with SageMaker Experiments 7.3 Model Governance with SageMaker Model Registry
8 Domain 3: SageMaker Inference Options & Endpoint Architecture
8.1 Real-Time, Serverless, and Asynchronous Inference 8.2 High-Throughput Offline Inference with Batch Transform 8.3 Multi-Model Endpoints (MME) & Multi-Container Endpoints (MCE)
9 Domain 3: Deployment Strategies & Infrastructure Scaling
9.1 Production Deployment Patterns & Traffic Shifting 9.2 Endpoint Auto-Scaling & Hardware Acceleration
10 Domain 3: MLOps Pipelines & Workflow Orchestration
10.1 SageMaker Pipelines Core Architecture 10.2 Advanced Pipeline Patterns & Integration 10.3 End-to-End MLOps CI/CD & Automated Retraining
11 Domain 4: Production Model Monitoring with SageMaker Model Monitor
11.1 Data Quality & Model Quality Monitoring 11.2 Model Bias & Model Explainability Drift 11.3 Operational Observability with Amazon CloudWatch
12 Domain 4: Responsible AI, Bias Detection & Governance
12.1 Pre-Training and Post-Training Bias with SageMaker Clarify 12.2 Model Documentation & Auditing with Model Cards & Dashboard 12.3 Safety, Guardrails & Generative AI Governance
13 Domain 4: ML Security, Network Isolation & Cost Optimization
13.1 IAM Roles and Least Privilege for ML 13.2 Network Isolation, VPC Endpoints & Data Encryption 13.3 ML Cost Optimization & Resource Governance
3.2 Interactive Data Preparation with SageMaker Data Wrangler
Key Takeaways Explain This Topic AI
Amazon SageMaker Data Wrangler provides an end-to-end visual workflow for data ingestion, profiling, feature transformation, and pipeline operationalization encapsulated in a .flow file.
Data Wrangler seamlessly connects to multiple disparate sources including Amazon S3, Amazon Athena, Amazon Redshift, AWS Lake Formation, Snowflake, and Databricks.
The Data Quality and Insights Report automatically evaluates dataset health, identifies missing values and outliers, detects target leakage, checks for multicollinearity, and trains a baseline Quick Model.
Over 300 built-in transformations are available (One-Hot, Target Encoding, Robust Scaler, text vectorization), supplemented by custom PySpark, Pandas, and SparkSQL transformation nodes.
Data Wrangler flows can be exported directly into SageMaker Pipelines (ProcessingStep), standalone Python scripts, SageMaker Feature Store feature groups, or AWS Glue ETL jobs.
Last updated: August 2026
Interactive Data Preparation with SageMaker Data Wrangler
Amazon SageMaker Data Wrangler is an integrated visual data preparation tool inside Amazon SageMaker Studio designed to streamline and accelerate the feature engineering lifecycle. Data Wrangler simplifies data exploration, diagnostic quality analysis, transformation authoring, and operationalization into automated MLOps pipelines. +-----------------------------------------------------------------------------------------+
- | SAGEMAKER DATA WRANGLER ARCHITECTURE |
- | |
- | [Data Sources] [Visual Flow (.flow)] [Export Targets] |
- | - Amazon S3 +----------------------+ - SageMaker Pipelines |
- | - Amazon Athena ------> | Import & Sampling | -----> - Python Script / SDK |
- | - Amazon Redshift | Quality & Insights | - SageMaker Feature Store|
- | - Snowflake / Databricks | 300+ Transforms / SQL| - AWS Glue ETL Job |
- | - Lake Formation +----------------------+ - Direct S3 Export |
- +-----------------------------------------------------------------------------------------+
- 1. Core Architecture & Data Ingestion
Data Wrangler organizes all data ingestion steps, transformation sequences, analysis nodes, and export destinations into a Directed Acyclic Graph (DAG) stored as a .flow file (a JSON document detailing the pipeline steps).
Data Ingestion Connectors
Amazon S3: Ingests CSV, Parquet, JSON, and ORC files with automatic schema inference.
Amazon Athena: Query structured data lakes using standard SQL syntax directly from the Data Wrangler console.
Amazon Redshift: Connect to data warehouses with IAM authentication or Secrets Manager credentials.
AWS Lake Formation: Enforces column-level and row-level governance and access control policies during data import.
Third-Party Warehouses: Native connectors for Snowflake and Databricks.
Sampling Strategies During Interactive Exploration
To maintain high UI responsiveness when working with multi-terabyte datasets, Data Wrangler applies intelligent sampling during interactive authoring:
Top K: Reads the first N N N rows (fastest, ideal for initial schema validation).
Random Sampling: Generates a statistically representative sample across the entire dataset.
Stratified Sampling: Samples proportionally across discrete classes of a specified categorical target column (crucial for imbalanced datasets).
Note
Interactive Sample vs. Full Job Execution: Interactive transformations in the SageMaker Studio UI execute against the configured sample dataset. However, when you export the flow to a SageMaker Processing Job or Pipeline, the transformation DAG executes across the entire, complete source dataset in distributed fashion.
2. Data Quality and Insights Report
Before applying transformations, ML engineers must evaluate data integrity and detect potential modeling pitfalls. The Data Quality and Insights Report automatically analyzes tabular datasets and produces a comprehensive diagnostic dashboard. +-----------------------------------------------------------------------------------------+
- | DATA QUALITY AND INSIGHTS REPORT SECTIONS |
- | |
- | 1. Dataset Summary: Row/column counts, missing cell %, duplicate rows |
- | 2. Target Column Stats: Class balance, distribution, entropy, target drift |
- | 3. Quick Model: Fast baseline model (XGBoost) accuracy & F1 score |
- | 4. Feature Summary: Min, max, mean, standard deviation, skewness, kurtosis |
- | 5. Target Leakage: Features that unnaturally predict the target |
- | 6. Multicollinearity: High cross-feature correlation (Pearson / Spearman) |
- | 7. Anomalous Values: Statistical outliers detected via isolation forests / IQR |
- +-----------------------------------------------------------------------------------------+
- Critical Diagnostic Checks for MLA-C01
- 1. Target Leakage Detection
Target leakage occurs when a feature contains information that will not be available at real-world inference time, causing artificially inflated training metrics that collapse in production (e.g., a refund_date column used to predict customer churn). Data Wrangler calculates mutual information and predictive correlation between each feature and the target, flagging features that exhibit suspiciously high predictive power.
2. Multicollinearity Analysis
When two or more independent features are highly correlated (e.g., square_feet and number_of_rooms ), they introduce redundancy, destabilize linear model coefficients, and inflate variance. Data Wrangler computes a cross-feature correlation matrix and recommends removing or combining redundant features.
3. Quick Model Baseline
Data Wrangler automatically trains an internal baseline model (using gradient boosted decision trees) on the raw features. It provides an immediate benchmark metric (e.g., ROC-AUC, F1-score, or MSE) and surfaces feature importance rankings to guide your feature engineering decisions.
3. Built-In & Custom Transformations
Data Wrangler includes over 300 pre-built transformations categorized by data type and operation:
Common Transformation Categories
Transformation Category Built-In Operations Best Practice / ML Impact
Missing Value Handling Drop missing, Fill with mean/median/mode, Constant replacement, Indicator column Add a binary indicator column ( col_is_na ) when missingness itself conveys predictive signal (e.g., missing credit score).
Categorical Encoding One-Hot Encoding, Ordinal/Label Encoding, Target/Likelihood Encoding, Frequency Encoding Use Target Encoding for high-cardinality features (e.g., ZIP codes) with cross-validation smoothing to prevent overfitting.
Numeric Scaling Standard Scaler ( Z = X − μ σ Z = \frac{X-\mu}{\sigma} Z = σ X − μ ), Min-Max Scaler ( [ 0 , 1 ] [0,1] [ 0 , 1 ] ), Robust Scaler ( I Q R IQR I QR ) Use Robust Scaler when the feature contains significant outliers, as it scales using median and interquartile range.
Text Feature Extraction Tokenization, Stopword Removal, Vectorization (TF-IDF, Bag of Words, Word Embeddings) Efficiently converts raw text strings into dense or sparse numerical feature representations.
Datetime Featurization Extract day of week, hour, cyclical encoding (sine/cosine transforms of cyclical time) Cyclical sine/cosine transformations preserve the continuous temporal distance between 23:00 and 00:00.
Custom Transformations (Code Nodes)
When built-in transformations are insufficient, Data Wrangler allows adding custom code blocks directly in the DAG:
Custom PySpark: Runs distributed Spark transformations across partitions.
Custom Python (Pandas): Runs standard Pandas transformations on the DataFrame.
Custom SparkSQL: Runs declarative SQL queries ( SELECT *, SQRT(colA) AS colA_sqrt FROM df ). # Example Custom PySpark snippet inside a Data Wrangler node
- from pyspark.sql.functions import col, sin, cos
- import math
- # Cyclical encoding for hour of day (0-23)
- df = df.withColumn("hour_sin", sin(col("transaction_hour") * (2.0 * math.pi / 24.0)))
- df = df.withColumn("hour_cos", cos(col("transaction_hour") * (2.0 * math.pi / 24.0)))
- 4. Production Export Destinations
Once the transformation flow is finalized in Data Wrangler, it can be exported into various production formats: +-----------------------------------------------------------------------------------------+
- | DATA WRANGLER EXPORT DESTINATIONS |
- | |
- | [Data Wrangler Flow (.flow)] |
- | | |
- | +-------------------------+-------------------------+ |
- | | | | |
- | v v v |
- | [SageMaker Pipeline] [SageMaker Feature Store] [AWS Glue ETL Job] |
- | - Generates - Ingests features - Converts .flow |
- | ProcessingStep into Online/Offline to PySpark Glue |
- | - Automated retraining Feature Groups ETL script |
- +-----------------------------------------------------------------------------------------+
- Export Options Breakdown
SageMaker Pipelines: Generates a Python script defining a ProcessingStep using the pre-configured SageMaker Data Wrangler container image ( sagemaker-data-wrangler-container ). The step takes the .flow file and source S3 datasets as inputs and outputs the transformed dataset to S3 for downstream TrainingStep consumption.
SageMaker Feature Store: Automatically creates Feature Group definitions matching the output schema and provisions an ingestion script to populate both the Online and Offline Feature Stores.
Python Code (SageMaker Python SDK): Generates a standalone Jupyter Notebook/script that launches a Processor job to run the flow programmatically.
AWS Glue ETL: Translates the visual DAG steps into an equivalent PySpark script for execution inside an AWS Glue managed ETL job. # Instantiating a Data Wrangler Processing Step in SageMaker Pipelines
- from sagemaker.processing import ProcessingInput, ProcessingOutput
- from sagemaker.workflow.steps import ProcessingStep
- from sagemaker.processing import Processor
- wrangler_processor = Processor(
- role=sagemaker_execution_role,
- image_uri=data_wrangler_image_uri,
- instance_count=2,
- instance_type="ml.m5.4xlarge"
- )
- step_data_wrangler = ProcessingStep(
- name="CustomerDataWranglerProcessing",
- processor=wrangler_processor,
- inputs=[
- ProcessingInput(
- source="s3://ml-bucket/raw-data/customers.csv",
- destination="/opt/ml/processing/input/customers.csv"
- ),
- ProcessingInput(
- source="s3://ml-bucket/flows/customer_prep.flow",
- destination="/opt/ml/processing/flow"
- )
- ],
- outputs=[
- ProcessingOutput(
- output_name="transformed_features",
- source="/opt/ml/processing/output",
- destination="s3://ml-bucket/features/customer_features/"
- )
- ]
- )
- 5. Cost Optimization & Best Practices
Shut Down Studio Kernel Apps: The interactive Data Wrangler interface runs on dedicated compute instances (e.g., ml.m5.4xlarge ). When data preparation authoring is complete, ensure the Data Wrangler application instance is shut down in SageMaker Studio to prevent ongoing hourly compute charges.
Use Sampling for Rapid Iteration: Set appropriate sample sizes (e.g., 50,000 rows) during interactive exploration rather than attempting to render millions of rows in real-time.
Select Appropriate Processing Instance Counts: For export processing jobs, scale instance_count horizontally to parallelize transformations across large S3 multi-part datasets.