How to Handle Categorical Features in BigQuery ML for Fast Deployment?
You are working with a dataset that contains customer transactions. You need to build an ML model to predict customer purchase behavior. You plan to develop the model in BigQuery ML, and export it to Cloud Storage for online prediction. You notice that the input data contains a few categorical features, including product category and payment method. You want to deploy the model as quickly as possible. What should you do?
Community Votes
47% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
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.
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.
Community Discussion (9 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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
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.
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;