Google Professional Data Engineer Question 216
Select 4Google Cloud PlatformYou are designing a pipeline in Google Cloud to prepare data for training and serving a machine learning model. The dataset contains a mix of numerical, categorical, and text features. Your goal is to preprocess the data such that the training and serving pipelines are consistent and scalable. Which of the following steps should you incorporate into your pipeline?
- A
Normalize numerical features to a consistent scale, such as between 0 and 1.
- B
One-hot encode categorical features and ensure the same encoding is used during both training and serving.
- C
Store raw text features as-is without transformation for use in the model.
- D
Use feature hashing to handle high-cardinality categorical data.
- E
Ensure that feature transformations are implemented using TensorFlow Transform (tf.Transform) or a similar tool for consistency.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
Preparing data for feature engineering involves ensuring that the preprocessing steps are optimized for the type of data and consistent between the training and serving pipelines. Normalizing numerical data, encoding categorical data (with techniques like one-hot encoding or feature hashing), and ensuring consistent transformations using tools like tf.Transform are essential steps. Raw text features should not be used as-is because they lack the structured numerical representation required by most machine learning models.
- A. Correct.
Normalizing numerical features ensures that models, particularly those sensitive to feature scaling, perform optimally. It is a key preprocessing step for numerical data in feature engineering.
- B. Correct.
One-hot encoding categorical features is a standard method for converting categorical data into a numerical format suitable for models. Consistent encoding between training and serving is critical to avoid model mismatches.
- C. Incorrect.
Raw text features are typically not used as-is in machine learning models, as they need to be tokenized, vectorized, or embedded. Using raw text directly is not a good practice.
- D. Correct.
Feature hashing is a common technique to efficiently handle high-cardinality categorical data by mapping them to a fixed-size vector, which makes it scalable and efficient.
- E. Correct.
Using TensorFlow Transform (tf.Transform) or similar tools ensures that feature transformations are applied consistently during both training and serving, preventing discrepancies that may degrade model performance.