Prepare a city categorical feature for a BigQuery ML linear regression model with minimal coding while preserving predictive information. What should you do?
Choose an answer
Tap an option to check your answer.
Correct answer: Use BigQuery SQL to one-hot encode city into binary columns..
Why this is the answer
One-hot encoding is the appropriate method here because BigQuery ML linear regression models require numerical inputs. Categorical features like 'city' need to be converted into a numerical format that the model can interpret. One-hot encoding creates a new binary column for each unique city, with a '1' indicating the presence of that city and '0' otherwise. This preserves all predictive information without implying any ordinal relationship between cities. Omitting the city column would discard valuable predictive information. Using TensorFlow to create a categorical variable is more complex than necessary for this task, as BigQuery ML can handle the one-hot encoding internally or via SQL. Mapping cities to numeric region labels (1-5) would introduce an artificial ordinal relationship that doesn't exist and could negatively impact model performance.
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