An ML engineer has a day_of_week column with values Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. Which technique should the engineer use to convert this categorical column into binary indicator variables?
Choose an answer
Tap an option to check your answer.
Correct answer: One-hot encoding.
Why this is the answer
One-hot encoding is the correct technique because it converts categorical variables into a binary vector representation where each category becomes a new binary column. For 'dayofweek', this would create seven new columns (e.g., 'isMonday', 'isTuesday'), with a '1' in the column corresponding to the day and '0's elsewhere. This avoids implying any ordinal relationship between the days, which is crucial as there's no inherent order in days of the week for most ML models. Binary encoding converts categories to binary code, which can still imply an ordinal relationship and is more complex than necessary here. Label encoding assigns a unique integer to each category (e.g., Monday=0, Tuesday=1), which incorrectly suggests an ordinal relationship that doesn't exist. Tokenization is typically used for text data to break it into smaller units (tokens).
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed