Databricks Machine Learning Associate Question 528
Single answerYou are building a machine learning model in Databricks to predict customer churn. Your dataset contains a categorical feature called 'Subscription_Type' with three unique values: 'Basic', 'Standard', and 'Premium'. You decide to use one-hot encoding to preprocess this feature. What will be the correct output representation of this feature for a customer with a 'Standard' subscription after one-hot encoding?
- A
[1, 0, 0]
- B
[0, 1, 0]
- C
[0, 0, 1]
- D
[1, 1, 0]
Show answer and explanation
Correct answer: B
Explanation
One-hot encoding transforms categorical features into a numerical format by assigning a binary vector to each unique category. In this case, the feature 'Subscription_Type' has three unique categories: 'Basic', 'Standard', and 'Premium'. After one-hot encoding, 'Basic' maps to [1, 0, 0], 'Standard' maps to [0, 1, 0], and 'Premium' maps to [0, 0, 1]. For a 'Standard' subscription, the correct one-hot encoded representation is [0, 1, 0].
- A. Incorrect.
This represents the 'Basic' subscription after one-hot encoding because 'Basic' is the first unique value in the categorical feature.
- B. Correct.
This correctly represents the 'Standard' subscription after one-hot encoding because 'Standard' is the second unique value in the categorical feature, and one-hot encoding assigns a 1 to the corresponding position.
- C. Incorrect.
This represents the 'Premium' subscription after one-hot encoding because 'Premium' is the third unique value in the categorical feature.
- D. Incorrect.
This is incorrect because one-hot encoding ensures that only one position is set to 1 for a given category, and no two positions can have a value of 1 simultaneously.