Google Professional Machine Learning Engineer Question 24
Single answerGoogle Cloud PlatformYou are tasked with building a predictive model using BigQuery ML. Your dataset contains a mix of categorical and numerical features. During feature engineering, you observe that one of your categorical features has over 100 unique values. To ensure your model performs efficiently and handles this feature appropriately, what should you do?
- A
Apply one-hot encoding to the categorical feature
- B
Use BigQuery ML's feature transformation functions such as ML.FEATURE_CROSS
- C
Leverage embedding-based feature representation by enabling model-specific feature transformation
- D
Remove the feature with high cardinality from the dataset to avoid performance issues
Show answer and explanation
Correct answer: C
Explanation
Handling high-cardinality categorical features is crucial in machine learning workflows. BigQuery ML provides embedding-based feature representation for certain models, which is an efficient way to represent high-cardinality features as dense vectors. This avoids the inefficiencies of one-hot encoding while preserving the feature's predictive power, making it the best choice in this scenario.
- A. Incorrect.
One-hot encoding for a feature with over 100 unique values would create a very large number of additional columns, which can cause inefficiency and high computational cost.
- B. Incorrect.
ML.FEATURE_CROSS is useful for creating interactions between features but does not directly address the issue of high cardinality in categorical features.
- C. Correct.
Embedding-based feature representation is a model-specific transformation provided by BigQuery ML (e.g., for models like DNNs). It efficiently handles high-cardinality categorical features by learning dense vector representations during training.
- D. Incorrect.
Removing a feature with high cardinality is not ideal unless it is irrelevant to the model. This approach may lead to loss of important information if the feature is predictive.