How to Handle Categorical Features in BigQuery ML for Fast Deployment?
Short answer
B Use the ML.ONE_HOT_ENCODER function on the categorical features and select the encoded categorical features and non-categorical features as inputs to create your model.
Question
Key Takeaways
Tests understanding of explicit feature transformation versus auto-preprocessing in BigQuery ML, where candidates often mistakenly rely on automatic handling or misuse the TRANSFORM clause for selective features.
When building models in BigQuery ML with categorical data, explicitly using ML.ONE_HOT_ENCODER before CREATE MODEL is the community-recommended approach for rapid deployment and predictable feature handling. While auto-preprocessing exists, explicit encoding optimizes training speed and inference performance.
Common mistake: Option C is frequently chosen due to the misconception that BigQuery ML’s auto-preprocessing is always the fastest method, overlooking that explicit ONE_HOT_ENCODING reduces preprocessing overhead and accelerates model creation for targeted categorical columns.
Expert Analysis
Why the Answer Is Correct
Explicitly applying ML.ONE_HOT_ENCODER to categorical features and passing the transformed outputs alongside numeric features to CREATE MODEL ensures deterministic feature mapping and eliminates runtime preprocessing latency. This approach aligns with BigQuery ML best practices for optimizing training throughput when dealing with mixed data types. By controlling the encoding step upfront, you bypass auto-preprocessing heuristics, resulting in faster model compilation and deployment.
Why the Other Options Are Wrong
Option A misuses the TRANSFORM clause, which applies transformations globally and ignores any unlisted query columns during training. Option C relies on auto-preprocessing, which can introduce unpredictable encoding behaviors and additional computational overhead during model fitting. Option D suggests ML.MULTI_HOT_ENCODER, which is designed for array or multi-label categorical data rather than single-value categories like product type or payment method.
Community Comment Notes
Comments highlight the critical distinction between TRANSFORM scope and direct SELECT-based encoding, noting that TRANSFORM requires all features to be listed to avoid silent data drops (Comment [1]). Several users initially favored auto-preprocessing but confirmed that explicit one-hot encoding delivers better performance for targeted categorical columns (Comments [2], [6]). The consensus validates Option B as the most reliable pattern for rapid, controlled deployment in BigQuery ML (Comments [4], [8], [9]).
Official Reference
- https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#transform
- https://cloud.google.com/bigquery/docs/auto-preprocessing
These links open the official vendor documentation in a new tab.
Exam Strategy
Focus on explicit feature engineering over auto-preprocessing when exam questions emphasize speed, control, or specific categorical handling. Always verify whether the TRANSFORM clause is being tested for global versus selective application, as omitting columns in TRANSFORM silently excludes them from training.
Community Votes
47% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 9 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 9
Show 4 more comments
-
vini123 👍 1 Answered BML.ONE_HOT_ENCODER transforms the categorical features into one-hot encoded values. You then select these encoded categorical features along with the non-categorical features to create your model. This is the most common approach for handling categorical features in BigQuery ML for fast deployment.
-
0e6b9e2 👍 1 Answered CThe create_model statement automatically one-hot encodes categorical features. https://cloud.google.com/bigquery/docs/auto-preprocessing This may not be the best solution in terms of transparency, but the question asked for the "fastest" solution
-
YushiSato 👍 1 Answered ATRANSFORM is used to transform the input for both learning and inference. ONE_HOT_ENCODER can also be used within TRANSFORM. The other options require conversion on the input in prediction. A is correct.
-
potomeek 👍 1 Answered CUsing the CREATE MODEL statement with the categorical and non-categorical features directly (Option C) is the simplest, fastest, and most effective way to build and deploy your model in BigQuery ML
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →
project.dataset.model_nameOPTIONS(model_type='logistic_reg') AS SELECT *, TRANSFORM( product_category, payment_method USING ML.ONE_HOT_ENCODER(product_category) AS encoded_product_category, ML.ONE_HOT_ENCODER(payment_method) AS encoded_payment_method ) FROMproject.dataset.table_name;