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?

  1. Use the TRANSFORM clause with the ML.ONE_HOT_ENCODER function on the categorical features at model creation and select the categorical and non-categorical features.
  2. 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. Source Reference Answer
  3. Use the CREATE MODEL statement and select the categorical and non-categorical features.
  4. Use the ML.MULTI_HOT_ENCODER function on the categorical features, and select the encoded categorical features and non-categorical features as inputs to create your model.

Community Votes

B
47%
C
33%
A
20%

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)

vini123 👍 1 Selected: B
ML.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.
potomeek 👍 1 Selected: C
Using 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
0e6b9e2 👍 1 Selected: C
The 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
phani49 👍 3 Selected: C
BigQuery ML automatically handles categorical features. When you use the CREATE MODEL statement, it recognizes categorical columns and applies appropriate encoding (e.g., one-hot encoding or embeddings) under the hood.
YushiSato 👍 1 Selected: A
TRANSFORM 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.
bobjr 👍 2 Selected: A
CREATE OR REPLACE MODEL project.dataset.model_name OPTIONS(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 ) FROM project.dataset.table_name;
BlehMaks 👍 4 Selected: B
When the TRANSFORM clause is present, only output columns from the TRANSFORM clause are used in training. Any results from query_statement that don't appear in the TRANSFORM clause are ignored. https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#transform so if you want TRANSFORM then use TRANSFORM for both categorical and non-categorical features
pikachu007 👍 1 Selected: B
Given the goal of quickly deploying the model for predicting customer purchase behavior while handling categorical features, option 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" seems to be the most appropriate. This approach directly handles the encoding of categorical features using one-hot encoding and selects the necessary features for model creation, ensuring efficient utilization of categorical data in the BigQuery ML model.
b1a8fae 👍 1 Selected: B
Only B and D make sense. Between the two, after reading the use case of multi-hot encoding (https://cloud.google.com/bigquery/docs/auto-preprocessing#feature-transform), I would tend towards B, since one-hot encoding is preferred over in case of using non-numerical, non-array features (product category and payment methods are often respresented as such); multi-hot encoding is preferred in case of non-numerical, array features, which is not the case here.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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 →

← Back to PMLE Study Guide