AWS Certified AI PractitionerAI/ML and Generative AI FundamentalsEasy

A data scientist is preparing a dataset for an AI/ML model that will predict house prices. The dataset contains various features, including 'number_of_bedrooms', 'square_footage', and 'zip_code'. Which of these features would most likely require one-hot encoding before being fed into a typical machine learning algorithm?

  1. Asquare_footage
  2. BAll of the above
  3. Cnumber_of_bedrooms
  4. Dzip_code
Show answer & explanation

Correct answer: D. zip_code

One-hot encoding is used for nominal categorical features where the numerical value itself doesn't imply order or magnitude. Zip codes are nominal categories, and treating them as numerical values would incorrectly imply a mathematical relationship. Number of bedrooms and square footage are inherently numerical.

Why the other options are wrong

  • A. This is a continuous numerical feature.
  • B. Only zip_code is a suitable candidate for one-hot encoding among the given options.
  • C. This is typically a numerical feature, representing a count.

One-Hot Encoding

A process of converting categorical variables into a numerical format that machine learning algorithms can understand, by creating new binary features for each category.

  • Used for nominal categorical data.
  • Creates a new binary column for each unique category.
  • Avoids implying ordinal relationships between categories.

Memory trick: Categorical data needs a 'hot' transformation for the machine's 'code' to understand.

More AI/ML and Generative AI Fundamentals questions