Google Professional Machine Learning Engineer Question 28
Single answerGoogle Cloud PlatformYou are a data scientist at a retail company and have trained a BigQuery ML model to predict customer churn. The model is stored in a BigQuery dataset named retail_churn under the models schema. You have a new table new_customers in the dataset customer_data, containing recent customer activity data. You need to generate predictions for this data using your model and store the results in a new table predictions_output in the same customer_data dataset. Which SQL query should you use?
- A
SELECT * FROM ML.PREDICT(MODEL
retail_churn.models, TABLEcustomer_data.new_customers) - B
CREATE TABLE
customer_data.predictions_outputAS SELECT * FROM ML.PREDICT(MODELretail_churn.models, TABLEcustomer_data.new_customers) - C
SELECT * FROM ML.EVALUATE(MODEL
retail_churn.models, TABLEcustomer_data.new_customers) - D
CREATE TABLE
customer_data.predictions_outputAS SELECT * FROM ML.EVALUATE(MODELretail_churn.models, TABLEcustomer_data.new_customers)
Show answer and explanation
Correct answer: B
Explanation
To generate predictions using a BigQuery ML model, you use the ML.PREDICT function. If you need to store the predictions in a new table, you can combine ML.PREDICT with a CREATE TABLE statement. Option 2 meets both requirements: it generates predictions using ML.PREDICT and stores them in the specified output table.
- A. Incorrect.
This query uses ML.PREDICT correctly to generate predictions, but it doesn't store the results in the required
predictions_outputtable. - B. Correct.
This query correctly uses ML.PREDICT to generate predictions and stores the results in the
predictions_outputtable, satisfying all requirements. - C. Incorrect.
ML.EVALUATE is used for evaluating model performance, not for generating predictions, so this query is incorrect.
- D. Incorrect.
This query uses ML.EVALUATE, which is not intended for generating predictions, and it also attempts to store evaluation results in the
predictions_outputtable, making it doubly incorrect.