Skip to content

Skill 1.2.4: Perform feature engineering (for example, scaling, standardization, feature splitting, binning, log transformation, normalization)


Question 1 - Feature Scaling for Gradient-Based Models

A financial services company is building a fraud detection model using Amazon SageMaker with the XGBoost algorithm. The dataset contains transaction amounts ranging from $0.01 to $250,000, customer account ages ranging from 0 to 40 years, and transaction counts per day ranging from 0 to 300.

The data science team must preprocess these features before training. The team wants to minimize computational overhead while ensuring all numerical features contribute proportionally to the model's learning process.

Which preprocessing technique should the team apply to the transaction amount feature, given its heavily right-skewed distribution spanning several orders of magnitude? (Select ONE)

  • A) Min-Max normalization to scale all values between 0 and 1
  • B) Log transformation to compress the wide range of values
  • C) One-hot encoding to convert amounts into categorical bins
  • D) Z-score standardization to center the distribution around zero
  • E) Feature splitting to separate dollars and cents into distinct columns
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: Log transformation is the standard technique for heavily right-skewed continuous variables spanning multiple orders of magnitude. It compresses the range while preserving the relative ordering, allowing tree-based and linear models to learn effectively from features that would otherwise be dominated by extreme values.

Distractor Analysis

  • A is Incorrect: Min-Max normalization to [0,1] would map extreme outliers like $250,000 to 1 while compressing all "normal" transactions near 0, losing discriminative information. It does not address skewness.
  • C is Incorrect: One-hot encoding converts categorical variables into binary indicator columns—it is not designed for continuous numeric features. Converting continuous values to bins would discard ordinal information.
  • D is Incorrect: Z-score standardization requires normally-distributed data to be effective. For highly skewed data, the mean and standard deviation are distorted by outliers, making the standardized values unreliable.
  • E is Incorrect: Feature splitting is used to decompose compound fields (e.g., "2024-03-15" into year/month/day), not to separate dollars and cents from a numeric column, which would create arbitrary, statistically meaningless features.

Key Takeaway: Choose log transformation for heavily skewed continuous variables spanning multiple orders of magnitude; reserve standardization for approximately normal distributions and min-max scaling for bounded, non-skewed ranges.


Question 2 - Training-Serving Consistency in SageMaker Pipelines

An e-commerce company's ML team uses Amazon SageMaker Pipelines to orchestrate training and batch inference for a product recommendation system. The pipeline includes a SKLearnProcessor step that fits a StandardScaler on numerical features (price, review count, seller rating) during model training.

A new ML engineer proposes modifying the inference pipeline to re-fit the scaler on each incoming batch of inference data before applying the model, arguing this keeps the preprocessing "fresh" for new data distributions.

What is the correct approach to maintain consistency between training and inference? (Select ONE)

  • A) Re-fit the scaler on inference batches to adapt to data drift automatically
  • B) Persist the fitted scaler parameters as a model artifact (e.g., joblib/pickle) and load them at inference to apply the same transformation
  • C) Apply Min-Max normalization instead of StandardScaler at inference to avoid parameter drift
  • D) Skip scaling at inference since the model already learned the patterns from scaled data
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: The fitted scaler is part of the model's learned artifact. Saving the scaler parameters (mean and standard deviation calculated during training) and loading them at inference ensures identical transformation of input features, eliminating training-serving skew.

Distractor Analysis

  • A is Incorrect: Re-fitting on each inference batch recalculates μ and σ from new data distributions, causing the same raw input value to map to a different scaled value than what the model was trained on. This introduces training-serving skew that degrades model performance silently.
  • C is Incorrect: Switching transformation methods at inference (StandardScaler → Min-Max) entirely changes the feature space. The model was trained on standardized (z-scored) features, and Min-Max values would fall outside the learned input distribution.
  • D is Incorrect: The model does not "know" the original unscaled values—it learned weights on standardized features. Passing unscaled data would produce incorrect predictions because the model interprets the input relative to the transformed feature space.

Key Takeaway: Persist and reuse the exact fitted scaler parameters across training and inference—preprocessing is an inseparable component of the model artifact, not a separate pipeline step to re-fit.


Question 3 - Binning Strategy for Credit Risk Model

A credit scoring startup is building a logistic regression model in Amazon SageMaker Data Wrangler to predict loan default risk. The team includes a feature annual_income that ranges from $15,000 to $500,000.

The compliance team requires that the model's decision process be explainable to customers. The ML engineers decide that grouping income into meaningful categories (e.g., "Low: <$40K", "Medium: \(40K-\)100K", "High: \(100K-\)250K", "Very High: >$250K") will make the model logic easier to articulate during regulatory audits.

Which feature engineering technique does this describe? (Select ONE)

  • A) Feature splitting
  • B) Binning
  • C) Standardization
  • D) Log transformation
  • E) Embedding
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: Binning (also called discretization) groups continuous values into discrete intervals or categories. This transforms a continuous numeric feature into an ordinal categorical feature with boundaries that are interpretable to humans—exactly what regulatory explainability demands.

Distractor Analysis

  • A is Incorrect: Feature splitting decomposes a single compound field into its constituent parts (e.g., extracting day, month, and year from a timestamp). It does not group continuous ranges into categorical bins.
  • C is Incorrect: Standardization rescales a continuous feature to zero-mean and unit-variance without changing its data type—values remain continuous and do not gain interpretability for human explanation.
  • D is Incorrect: Log transformation compresses skew but preserves the continuous nature of the data. The income values would still require explanation as continuous numbers, failing the compliance requirement.
  • E is Incorrect: Embeddings map high-dimensional categorical or text data into dense vector spaces to capture semantic relationships. Binning a single continuous column does not require embedding.

Key Takeaway: Use binning when explainability or non-linear categorization matters more than preserving the exact continuous value; logistic regression models benefit from monotonic binned features that capture non-linear effects.


Question 4 - Feature Splitting for DateTime in Glue DataBrew

A logistics company is building a delivery-time prediction model using AWS Glue DataBrew. The raw dataset contains a delivery_timestamp column formatted as 2024-03-15 08:30:00 UTC.

The ML team hypothesizes that the hour of day, day of week, and month of delivery significantly influence delivery times. They need to create separate numeric feature columns for each of these components before training an XGBoost model in SageMaker.

Which DataBrew transformation should the team apply to achieve this? (Select ONE)

  • A) Scale the timestamp values using min-max normalization
  • B) Convert the timestamp to a categorical one-hot encoding
  • C) Split the timestamp column into separate columns for year, month, day, hour, and minute
  • D) Apply a log transformation to the timestamp epoch values
  • E) Create bins from timestamp values using custom boundaries
Click to reveal Answer & Explanation

Correct Answer: C

Correct Option Analysis

  • C is Correct: Feature splitting decomposes a composite field (like a datetime string) into its constituent components. Extracting hour, day of week, and month from a timestamp is the canonical application of feature splitting, enabling models to learn cyclical patterns (e.g., rush hour effects) or seasonal impacts.

Distractor Analysis

  • A is Incorrect: Scaling a timestamp makes no statistical sense—the numeric epoch representation of datetime has arbitrary zero points, and min-max normalization would not expose cyclical patterns like hour-of-day or day-of-week effects.
  • B is Incorrect: One-hot encoding a full timestamp (with potentially thousands of unique values) would explode feature dimensionality and capture no generalizable temporal pattern—each exact timestamp becomes its own category.
  • D is Incorrect: Log transforming epoch values would compress already meaningless numeric representations of time, producing values with no interpretable relationship to the underlying hour/day/month effects the team needs to capture.
  • E is Incorrect: Binning timestamps into ranges (e.g., "Q1 2024", "Q2 2024") loses granularity and does not extract the specific temporal components (hour, day of week) the ML hypothesis requires.

Key Takeaway: Split datetime fields into their cyclical components (hour, day of week, month) rather than passing raw timestamps—tree models and linear models can only extract signal from explicitly decomposed temporal features.


Question 5 - Streaming Feature Engineering with Sliding Windows

An IoT company processes sensor data from manufacturing equipment using a streaming pipeline. Sensors emit temperature and vibration readings every 10 seconds.

The ML team needs to engineer a feature representing the moving average of vibration readings over the last 5 minutes to feed into a real-time anomaly detection model deployed on Amazon SageMaker. The feature must update continuously as new readings arrive, with each new prediction considering the most recent 30 readings.

Which AWS service or framework should the team use to implement this feature engineering requirement? (Select ONE)

  • A) AWS Glue batch job scheduled every 5 minutes
  • B) AWS Lambda function triggered by each sensor record
  • C) Spark on Amazon EMR with Kafka structured streaming
  • D) AWS Glue DataBrew recipe scheduled on-demand
  • E) Amazon Comprehend document processing pipeline
Click to reveal Answer & Explanation

Correct Answer: C

Correct Option Analysis

  • C is Correct: A continuously sliding window over streaming data requires stateful stream processing. Spark Structured Streaming on Amazon EMR with Kafka integration supports windowed aggregation (moving averages, rolling sums), maintaining state across the sliding window and updating outputs as each event arrives.

Distractor Analysis

  • A is Incorrect: Batch Glue jobs run on fixed schedules (e.g., every 5 minutes). A moving average requirement demands sub-second latency and continuous window rollover—a batch job introduces unacceptable delay between data arrival and feature computation.
  • B is Incorrect: AWS Lambda is stateless by nature. While Lambda can process records individually, it cannot maintain the rolling 30-reading state across invocations without external state stores, and even then, the fundamental design does not support efficient sliding window aggregation.
  • D is Incorrect: DataBrew is a visual batch data preparation tool for scheduled or on-demand jobs, not a streaming engine. It cannot process continuously arriving sensor data.
  • E is Incorrect: Amazon Comprehend provides NLP capabilities like entity recognition, sentiment analysis, and PII detection—it has no streaming window aggregation capabilities for numerical sensor features.

Key Takeaway: For streaming features requiring sliding windows or ordered aggregation, choose a stateful stream processor (Spark Structured Streaming on EMR or Amazon Managed Service for Apache Flink); Lambda is only suitable for stateless, per-record transformations.


Question 6 - Feature Store for Training-Serving Consistency

A large retail company operates hundreds of ML models across multiple teams. Data scientists frequently retrain models on new datasets, but live inference endpoints often use slightly different feature engineering logic because each team implemented its own preprocessing code. This has caused multiple production incidents where model predictions degraded after redeployment.

The ML platform team wants a centralized solution where engineered features are defined once, stored with versioning, and accessed consistently by both training jobs and real-time inference endpoints. The solution must integrate with Amazon SageMaker.

Which AWS service should the platform team implement? (Select ONE)

  • A) AWS Glue Data Catalog to store feature transformation metadata
  • B) Amazon SageMaker Feature Store
  • C) Amazon DynamoDB with DAX caching
  • D) AWS Glue DataBrew shared recipes
  • E) Amazon ElastiCache for Redis to cache engineered features
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: Amazon SageMaker Feature Store is purpose-built to solve training-serving skew caused by inconsistent feature engineering. It provides a centralized repository for storing, versioning, and retrieving features at low latency for both online inference and offline training. Feature definitions are written once and reused identically across the ML lifecycle.

Distractor Analysis

  • A is Incorrect: The Glue Data Catalog holds schema and table metadata for data discovery and ETL. It does not provide real-time feature serving, versioning, or an API for inline inference feature retrieval.
  • C is Incorrect: DynamoDB could store features as key-value pairs but requires each team to build custom abstraction layers for consistency, versioning, and training batch retrieval. It does not natively enforce feature definition consistency, which is the core problem described.
  • D is Incorrect: DataBrew recipes apply batch transformations to datasets, but sharing a recipe across teams does not guarantee inference-time consistency, nor does it provide real-time feature serving capabilities.
  • E is Incorrect: ElastiCache serves as a low-latency key-value cache but lacks feature versioning, lineage tracking, and batch training export APIs. It does not address the governance problem of teams implementing divergent feature definitions.

Key Takeaway: When teams need "define once, serve everywhere" feature consistency with versioning and governance, SageMaker Feature Store is the native AWS solution—caches and catalogs solve performance and discovery, not consistency.


Question 7 - Embedding Model Selection in Bedrock

A healthcare startup is building a clinical notes search application using Amazon Bedrock. The system must convert unstructured clinical text documents (e.g., physician notes, discharge summaries) into numerical vector representations. These vectors will be indexed in Amazon OpenSearch Serverless for semantic similarity search, enabling doctors to find prior cases discussing similar symptoms and treatments.

The CTO requires that the embedding model understand domain-specific medical terminology and capture semantic meaning (e.g., "myocardial infarction" and "heart attack" should produce similar vectors).

Which Bedrock capability should the team use? (Select ONE)

  • A) Categorical encoding using SageMaker Data Wrangler
  • B) Embedding models (e.g., Amazon Titan Embeddings or Cohere Embed)
  • C) Fine-tuning a generation model on medical texts
  • D) AWS Glue DataBrew text splitting recipe
  • E) Amazon Comprehend entity recognition for vocabulary matching
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: Embedding models convert text into dense vector representations where semantically similar phrases map to nearby vectors in high-dimensional space. Amazon Bedrock offers embedding models (Titan Embeddings, Cohere Embed) specifically designed for semantic search and RAG use cases, capturing relationships like synonymy and paraphrasing.

Distractor Analysis

  • A is Incorrect: Categorical encoding converts discrete labels (e.g., "male"/"female", "red"/"blue") into numeric identifiers. It does not process natural language text and does not capture semantic meaning—"myocardial infarction" and "heart attack" would receive completely unrelated numeric codes.
  • C is Incorrect: Fine-tuning a generation model updates weights to improve instruction-following or domain-specific text generation—it does not produce vector representations for similarity search. Embedding models are distinct from generation models.
  • D is Incorrect: DataBrew's text splitting creates text segments for embedding input but does not itself generate vector embeddings. The splitting recipe is a preparatory step, not the numerical transformation itself.
  • E is Incorrect: Comprehend entity recognition extracts named entities (e.g., medications, conditions), providing structured metadata but not semantic vector representations. Similarity between "myocardial infarction" and "heart attack" requires embeddings, not entity labels.

Key Takeaway: For semantic search and RAG, use dedicated embedding models via Amazon Bedrock—they learn contextual relationships that categorical encoding and rule-based entity extraction cannot capture.


Question 8 - Categorical Encoding for High-Cardinality Features

An advertising technology company is building a click-through rate prediction model using SageMaker with a gradient boosting algorithm. The dataset includes a campaign_id feature with 50,000+ unique values, and the team suspects this feature has predictive power (some campaigns systematically outperform others).

The team needs to encode this feature for tree-based algorithms that inherently handle categorical splits. Which encoding strategy is most appropriate? (Select ONE)

  • A) One-hot encoding all 50,000+ campaign IDs into binary columns
  • B) Label encoding using the campaign's average historical click-through rate (target encoding)
  • C) Min-Max normalization of campaign IDs
  • D) Log transformation of campaign IDs
  • E) Embedding the campaign IDs using an embedding model from Amazon Bedrock
Click to reveal Answer & Explanation

Correct Answer: B

Correct Option Analysis

  • B is Correct: Target encoding (also called mean encoding) replaces each categorical value with the average target value (or a smoothed variant) for that category. For high-cardinality features like 50,000+ campaign IDs, this captures predictive signal in a single numeric column, avoiding dimensionality explosion and directly applicable to gradient boosting models.

Distractor Analysis

  • A is Incorrect: One-hot encoding 50,000+ unique campaign IDs would create 50,000+ sparse binary columns, dramatically increasing memory requirements and training time while providing little benefit for tree-based models (which handle splits natively). This approach is computationally prohibitive.
  • C is Incorrect: Min-Max normalization of arbitrarily assigned campaign ID integers would create meaningless numeric relationships—campaign ID "100" is not inherently smaller or larger than "200" in a way that carries predictive signal.
  • D is Incorrect: Log transformation of arbitrary categorical ID values is statistically meaningless—IDs are nominal labels, not continuous measurements with a natural scale or skewed distribution.
  • E is Incorrect: While entity embeddings exist for categorical variables, they require training a neural network (or similar) to learn the embeddings. For gradient boosting (a tree-based algorithm), this overhead is unnecessary; additionally, Bedrock embedding models are designed for text, not arbitrary categorical IDs.

Key Takeaway: For high-cardinality categorical features in tree-based models, target encoding or hash encoding is preferred over one-hot encoding, which explodes dimensionality and becomes computationally prohibitive.


Question 9 - Log Transformation for Outlier-Insensitive Scaling

A real estate company is training a property price prediction model using Amazon SageMaker with a linear regression algorithm. The features include square_footage (ranging from 500 to 50,000 sq ft) and distance_to_city_center (ranging from 0.5 km to 200 km).

Both features are highly right-skewed, with a small number of luxury mansions and remote properties creating extreme outliers. The team wants to reduce the influence of outliers without removing data points.

Which transformation should the team apply to BOTH features before training? (Select ONE)

  • A) Z-score standardization
  • B) Min-Max normalization to [0,1]
  • C) Log transformation (e.g., log1p)
  • D) Binning into quantile-based categories
  • E) One-hot encoding of property characteristics
Click to reveal Answer & Explanation

Correct Answer: C

Correct Option Analysis

  • C is Correct: Log transformation (specifically log1p for zero-safe transformation) is ideal for highly right-skewed features with heavy-tailed distributions. It compresses large values proportionally, reducing the influence of extreme outliers while preserving the relative ordering of values. Linear regression models assume normally distributed features, and log transformation helps meet this assumption.

Distractor Analysis

  • A is Incorrect: Z-score standardization uses mean and standard deviation, both of which are distorted by extreme outliers. For heavily right-skewed data, the mean is pulled toward outliers, and the standard deviation is inflated, producing transformed values that do not follow a normal distribution.
  • B is Incorrect: Min-Max normalization is extremely sensitive to outliers—a single max value of 50,000 sq ft would compress all "typical" properties (500-3000 sq ft) into a tiny fraction of the [0,1] range, destroying discriminative information.
  • D is Incorrect: Binning into quantiles would convert continuous features into categorical ordinal values, losing precise continuous numeric information. While this reduces outlier influence, it also discards information about relative magnitudes within each bin, degrading linear regression performance.
  • E is Incorrect: One-hot encoding is for categorical variables (like property type), not continuous numeric features like square footage or distance measurements.

Key Takeaway: For right-skewed continuous features with outliers, log transformation preserves information while reducing outlier influence—unlike min-max scaling (outlier-sensitive) or z-score standardization (distorted by skewed distributions).


Question 10 - Masking PII Before Model Training

A telecommunications company is building a customer churn prediction model using Amazon SageMaker and has discovered that the training dataset accidentally includes customer email addresses, phone numbers, and social security numbers in a free-text "customer_notes" field.

The legal team mandates that no personally identifiable information (PII) can be used in model training. The data engineering team needs to remove or obscure this information while preserving the utility of non-PII text (e.g., "customer complained about network quality in downtown area").

Which TWO approaches should the team implement? (Select TWO)

  • A) Use Amazon Comprehend to detect PII entities and replace them with masking tokens (e.g., [EMAIL], [PHONE])
  • B) Drop the customer_notes column entirely, losing all information from that field
  • C) Use Amazon Macie to discover and report sensitive data locations in S3 before transformation
  • D) Train the model with PII intact but deploy with Amazon SageMaker Model Monitor to detect leakage
  • E) Use AWS Glue DataBrew to apply a standard scaler to the text field
Click to reveal Answer & Explanation

Correct Answers: A and C

Correct Options Analysis

  • A is Correct: Amazon Comprehend's PII detection API identifies entities like emails, phone numbers, and SSNs in free-text. Replacing them with masking tokens preserves the surrounding non-PII information while ensuring compliance with the no-PII requirement.
  • C is Correct: Amazon Macie automatically discovers, inventories, and reports on sensitive data stored in S3 buckets across the AWS estate. Running Macie over the data lake identifies all locations containing PII, ensuring comprehensive discovery before any masking transformation is applied.

Distractor Analysis

  • B is Incorrect: Dropping the column entirely is a valid but unnecessarily destructive approach—the requirement is to mask PII while preserving the utility of non-PII text. The column contains valuable predictive signal (customer complaints, network issues) that would be lost. This introduces unnecessary information loss when a compliant alternative exists.
  • D is Incorrect: Model Monitor detects data drift and prediction degradation post-deployment—it does not prevent or remediate PII leakage during model training. Training with PII intact directly violates the legal mandate.
  • E is Incorrect: DataBrew's scaling transforms are designed for numeric features; applying a "standard scaler" to free-text data is technically invalid and would destroy all information in the field. Scaling does not mask or remove PII.

Key Takeaway: Use Comprehend for entity-level PII masking and Macie for automated S3 sensitive data discovery—together they provide a compliant, information-preserving PII handling pipeline without dropping columns.