An ML engineer is training a logistic regression model to predict subscription churn. The dataset includes two categorical string features: location (3 distinct categories) and job_seniority_level (more than 10 distinct categories). How should these features be preprocessed for the model?
Choose an answer
Tap an option to check your answer.
Correct answer: Use one-hot encoding for location. Use ordinal encoding for job_seniority_level..
Why this is the answer
One-hot encoding is suitable for the 'location' feature because it has a small number of distinct categories (3). This method creates new binary features for each category, preventing the model from inferring an arbitrary ordinal relationship. Ordinal encoding is appropriate for 'jobsenioritylevel' as it has more than 10 distinct categories, and there's likely an inherent order (e.g., 'junior' < 'mid' < 'senior'). Assigning integer values based on this order preserves the relationship without creating an excessive number of features. Tokenizing 'location' is incorrect as it's typically used for text data, not categorical features with a few distinct values. Binning 'location' is unnecessary as it already has few categories. Standard scaling is for numerical features, not categorical ones like 'jobsenioritylevel'.
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