Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Machine Learning Engineer practice bank has an additional 974 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You trained a BigQuery ML boosted tree binary classifier named retail.churn_model with input_label_cols=['churn_status'] (a STRING column) using the following preprocessing clause:
TRANSFORM(ML.STANDARD_SCALER(total_spend) OVER() AS scaled_spend, days_active, churn_status)
The source table retail.customer_features has 200 columns and 100 million rows. You need to run a batch prediction query that:
customer_id, predicted_churn_status, and predicted_churn_status_probs for all customers0.75Which query should you execute?
SELECT
customer_id,
predicted_churn_status,
predicted_churn_status_probs
FROM
ML.PREDICT(
MODEL `retail.churn_model`,
(
SELECT
customer_id,
total_spend,
days_active
FROM
`retail.customer_features`
),
STRUCT(0.75 AS threshold)
)
ML.PREDICT query doesThis query uses ML.PREDICT with a column-pruned GoogleSQL subquery (QUERY_STATEMENT) and a custom decision threshold inside the configuration STRUCT to score all 100 million customer rows efficiently.
TRANSFORM preprocessing correctly: When a BigQuery ML model is created with a TRANSFORM clause, the transformation logic (ML.STANDARD_SCALER(total_spend) OVER()) and its training-time parameters are saved inside the model artifact. At inference time, QUERY_STATEMENT only needs to supply the raw input feature columns referenced in TRANSFORM (total_spend and days_active); the training label (churn_status) is not required.customer_id while minimizing bytes scanned: Selecting only customer_id, total_spend, and days_active prunes 197 unused columns from the 200-column table. Because customer_id is not used by the model, BigQuery ML automatically passes it through to the ML.PREDICT output table.0.75 decision cutoff: Setting STRUCT(0.75 AS threshold) overrides the default 0.5 binary classification cutoff so predicted_churn_status reflects the positive class only when its probability exceeds 0.75.predicted_churn_status (STRING) and predicted_churn_status_probs (ARRAY<STRUCT> containing <label, probability> pairs) returns the exact predicted label and class probabilities.TRANSFORM statistics (mean and standard deviation) are applied consistently to every evaluation row.It combines column pruning in QUERY_STATEMENT, automatic pass-through identification, persisted TRANSFORM execution, and native THRESHOLD configuration in a single serverless SQL pass without analytic shuffles or schema mismatches.
SELECT
customer_id,
predicted_churn_status,
predicted_churn_status_probs
FROM
ML.PREDICT(
MODEL `retail.churn_model`,
(
SELECT
customer_id,
ML.STANDARD_SCALER(total_spend) OVER() AS scaled_spend,
days_active
FROM
`retail.customer_features`
),
STRUCT(0.75 AS threshold)
)
This query attempts to manually compute ML.STANDARD_SCALER(total_spend) OVER() AS scaled_spend inside the QUERY_STATEMENT subquery before passing the result into ML.PREDICT.
TRANSFORM clause expect the original pre-transform columns listed inside TRANSFORM (total_spend and days_active) during ML.PREDICT, not the post-transform output alias (scaled_spend). Omitting total_spend causes ML.PREDICT to fail because a required model input column is missing.scaled_spend, recomputing ML.STANDARD_SCALER(...) OVER() across the inference batch calculates a new mean and standard deviation from evaluation data instead of reusing training statistics, and forces an expensive full-table analytic window shuffle over 100 million rows.TRANSFORM graph automatically on raw inputs during ML.PREDICT, ML.EVALUATE, and ML.EXPLAIN_PREDICT.ML.TRANSFORM function rather than embedding preprocessing functions inside ML.PREDICT.total_spend directly avoids redundant window computation and guarantees identical feature scaling.TRANSFORM clause on a table whose feature column was literally named scaled_spend, and you had used a separate transform-only model (ML.TRANSFORM) or precomputed training parameters rather than an unanchored OVER() window.SELECT
customer_id,
IF(predicted_churn_status_probs > 0.75, 'positive', 'negative') AS predicted_churn_status,
predicted_churn_status_probs
FROM
ML.PREDICT(
MODEL `retail.churn_model`,
(
SELECT
customer_id,
total_spend,
days_active
FROM
`retail.customer_features`
)
)
This query runs ML.PREDICT with a column-pruned subquery using the default threshold (0.5) and attempts to override the classification decision in the outer SELECT using IF(predicted_churn_status_probs > 0.75, ...).
predicted_churn_status_probs: For binary classification models in BigQuery ML, predicted_<label_column_name>_probs is not a scalar FLOAT64 probability; it is an ARRAY<STRUCT> containing [<label, probability>] pairs for each class. Comparing an array directly with > 0.75 fails with a GoogleSQL type error.THRESHOLD support: Omitting STRUCT(0.75 AS threshold) leaves the internal cutoff at 0.5 and attempts to hardcode arbitrary 'positive'/'negative' strings in the outer query instead of returning the model's actual trained label values.predicted_churn_status_probs in SQL, you must unnest the array (for example, using UNNEST(predicted_churn_status_probs)) or index into the struct elements and match the target label field.STRUCT(0.75 AS threshold) inside ML.PREDICT is cleaner, less error-prone, and directly assigns the trained positive or negative churn_status label to predicted_churn_status.STRUCT(0.75 AS threshold) intentionally to evaluate multiple custom cutoffs in a single scan, and extracted the positive class probability from the ARRAY<STRUCT> via a scalar subquery over UNNEST(predicted_churn_status_probs) rather than comparing the array directly to a FLOAT64.SELECT
customer_id,
predicted_churn_status,
predicted_churn_status_probs
FROM
ML.PREDICT(
MODEL `retail.churn_model`,
TABLE `retail.customer_features`,
STRUCT(0.75 AS threshold, TRUE AS keep_original_columns)
)
This query attempts to invoke ML.PREDICT directly against the full retail.customer_features table while passing both threshold and keep_original_columns inside the options STRUCT.
KEEP_ORIGINAL_COLUMNS option is only supported for Principal Component Analysis (PCA) models. Passing TRUE AS keep_original_columns to a boosted tree binary classifier causes BigQuery ML to reject the query with an invalid parameter error.TABLE retail.customer_features`` instead of a column-pruned QUERY_STATEMENT instructs BigQuery's columnar storage engine to scan all 200 columns across 100 million rows, significantly increasing bytes scanned and query costs even though only customer_id, total_spend, and days_active are needed.KEEP_ORIGINAL_COLUMNS.KEEP_ORIGINAL_COLUMNS defaults to FALSE and controls whether input features are appended alongside principal_component_<index> columns in PCA inference.TABLE reference also reads the label column (churn_status) unnecessarily.principal_component_<index> outputs) against a compact table where scanning every column was acceptable and you needed the original columns preserved in the output (without threshold, which does not apply to PCA).Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated