AIF-C01 Fundamentals of AI and ML Practice Question
A data scientist needs to preprocess categorical data with high cardinality (e.g., zip code with 50,000 unique values). Which technique is most appropriate?
⚠ Common exam trap
AWS often tests the trap that candidates assume one-hot encoding is always the safest choice for categorical data, ignoring the practical infeasibility of high cardinality, and fail to recognize target encoding as the standard solution for such cases.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Target encoding
Target encoding is the most appropriate technique for high-cardinality categorical features like zip codes because it replaces each category with the mean of the target variable for that category, effectively compressing 50,000 unique values into a single numeric feature while retaining predictive signal. This avoids the dimensionality explosion of one-hot encoding and the arbitrary ordering of label or ordinal encoding, which can mislead models.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Target encoding
Why this is correct
Target encoding replaces each category with a statistic of the target, producing a single numeric column regardless of cardinality. This suits zip codes with 50,000 unique values, where one-hot encoding would create 50,000 sparse columns and degrade model performance and memory use.
- ✗
Label encoding
Why it's wrong here
Label encoding assigns each of the 50,000 zip codes an arbitrary integer, implying a false ordinal relationship and producing a sparse, meaningless numeric feature. It is intended for low-cardinality or genuinely ordered categories, not high-cardinality nominal identifiers where target or frequency encoding is used.
- ✗
Ordinal encoding
Why it's wrong here
Ordinal encoding imposes a rank order on zip codes that does not exist, so the model treats 90210 as greater than 10001, distorting distance calculations. It is correct for genuinely ordered categories such as education level or severity ratings, not for nominal high-cardinality identifiers.
- ✗
One-hot encoding
Why it's wrong here
One-hot encoding creates 50,000 binary columns, causing extreme dimensionality, memory blow-up and sparse features that degrade training. It works well for low-cardinality nominal variables, but for high-cardinality identifiers target encoding, hashing or embeddings are used instead.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AIF-C01 question from scratch — 862 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AIF-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AIF-C01 exam.