Your retail company wants to predict customer churn using historical purchase data stored in BigQuery. The dataset includes customer demographics, purchase history, and a label indicating whether the customer churned or not. You want to build a machine learning model to identify customers at risk of churning. You need to create and train a logistic regression model for predicting customer churn, using the customer_data table with the churned column as the target label.
Which BigQuery ML query should you use?
Answer(s): B
Explanation:
In BigQuery ML, when creating a logistic regression model to predict customer churn, the correct query should:
Exclude the target label column (in this case, churned) from the feature columns, as it is used for training and not as a feature input.
Rename the target label column to label, as BigQuery ML requires the target column to be named label.
The chosen query satisfies these requirements:
SELECT * EXCEPT(churned), churned AS label: Excludes churned from features and renames it to label.
The OPTIONS(model_type='logistic_reg') specifies that a logistic regression model is being trained.
This setup ensures the model is correctly trained using the features in the dataset while targeting the churned column for predictions.
Reveal Solution Next Question