Points de contrôle
Create a Vertex AI Notebook
/ 30
Clone the lab repository
/ 30
Create a BigQuery dataset
/ 30
Create a BQML model to predict user churn
/ 30
Evaluate BQML model
/ 30
Batch predict user churn
/ 30
Deploy a BigQuery ML Customer Churn Classifier to Vertex AI for Online Predictions
- GSP944
- Overview
- Objectives
- Setup and requirements
- Task 1. Enable Google Cloud services
- Task 2. Deploy Vertex Notebook instance
- Task 3. Clone the lab repository
- Task 4. Create a BigQuery dataset
- Task 5. Create a BigQuery ML XGBoost churn propensity model
- Task 6. Evaluate your BigQuery ML model
- Task 7. Batch predict user churn with your BigQuery ML model
- Congratulations!
GSP944
Overview
In this lab, you will train, tune, evaluate, explain, and generate batch and online predictions with a BigQuery ML XGBoost model. You will use a Google Analytics 4 dataset from a real mobile application, Flood it! (Android app, iOS app), to determine the likelihood of users returning to the application. You will generate batch predictions with your BigQuery ML model as well as export and deploy it to Vertex AI for online predictions using the Vertex Python SDK.
BigQuery ML lets you train and do batch inference with machine learning models in BigQuery using standard SQL queries faster by eliminating the need to move data with fewer lines of code.
Vertex AI is Google Cloud's complimentary next generation, unified platform for machine learning development. By developing and deploying BigQuery ML machine learning solutions on Vertex AI, you can leverage a scalable online prediction service and MLOps tools for model retraining and monitoring to significantly enhance your development productivity, the ability to scale your workflow and decision making with your data, and accelerate time to value.
Note: BQML is now BigQuery ML.
This lab is inspired by and extends Churn prediction for game developers using Google Analytics 4 (GA4) and BigQuery ML. Read the blog post and accompanying tutorial for additional depth on this use case and BigQuery ML.
In this lab, you will go one step further and focus on how Vertex AI extends BigQuery ML's capabilities through online prediction so you can incorporate both customer churn predictions into decision making UIs such as Looker dashboards but also online predictions directly into customer applications to power targeted interventions such as targeted incentives.
Objectives
In this lab, you learn how to:
- Explore and preprocess a Google Analytics 4 data sample in BigQuery for machine learning.
- Train a BigQuery ML XGBoost classifier to predict user churn on a mobile gaming application.
- Tune a BigQuery ML XGBoost classifier using BigQuery ML hyperparameter tuning features.
- Evaluate the performance of a BigQuery ML XGBoost classifier.
- Explain your XGBoost model with BigQuery ML Explainable AI global feature attributions.
- Generate batch predictions with your BigQuery ML XGBoost model.
- Export a BigQuery ML XGBoost model to a Google Cloud Storage bucket.
- Upload and deploy a BigQuery ML XGBoost model to a Vertex AI Prediction Endpoint for online predictions.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
- Click Activate Cloud Shell at the top of the Google Cloud console.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Task 1. Enable Google Cloud services
- In Cloud Shell, use
gcloud
commands to enable the services used in the lab:
Task 2. Deploy Vertex Notebook instance
-
In the Google Cloud console, from the Navigation menu (), select Vertex AI.
-
Click Enable All Recommended APIs.
-
On the left-hand side, click Workbench.
-
At the top of the Workbench page, ensure you are in the Instances view.
-
Click Create New.
-
Configure the Instance:
- Name: lab-workbench
-
Region: Set the region to
-
Zone: Set the zone to
- Advanced Options (Optional): If needed, click "Advanced Options" for further customization (e.g., machine type, disk size)
- Click Create.
- Click Open JupyterLab next to the instance name to launch the JupyterLab interface. This will open a new tab in your browser.
- Click the Terminal icon to open a terminal window.
Your terminal window will open in a new tab. You can now run commands in the terminal to interact with your Workbench instance.
Your notebook is now set up.
Click Check my progress to verify the objective.
Task 3. Clone the lab repository
Next you'll clone the training-data-analyst
notebook in your JupyterLab instance.
- In JupyterLab, click the Terminal icon to open a new terminal.
Cancel
for Build Recommended.- To clone the
training-data-analyst
Github repository, type in the following command, and press Enter:
- To confirm that you have cloned the repository, double-click the
training-data-analyst
directory and confirm that you can see its contents.
Click Check my progress to verify the objective.
Navigate to lab notebook
-
In your notebook, navigate to training-data-analyst > quests > vertex-ai > vertex-bqml, and open lab_exercise.ipynb.
-
Continue the lab in the notebook, and run each cell by clicking the Run () icon at the top of the screen. Alternatively, you can execute the code in a cell with SHIFT + ENTER.
Read the narrative and make sure you understand what's happening in each cell. As you progress through the lab notebook, return back to these instructions to complete the graded exercises.
Task 4. Create a BigQuery dataset
Click Check my progress to verify the objective.
Task 5. Create a BigQuery ML XGBoost churn propensity model
Click Check my progress to verify the objective.
Task 6. Evaluate your BigQuery ML model
Click Check my progress to verify the objective.
Task 7. Batch predict user churn with your BigQuery ML model
Click Check my progress to verify the objective.
Congratulations!
In this lab you trained, tuned, explained, and deployed a BigQuery ML user churn model to Vertex AI to generate high business impact batch and online churn predictions to target customers likely to churn with interventions such as in-game rewards and reminder notifications.
Next steps / Learn more
Read more about Vertex AI in the Vertex AI Documentation.
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated December 10, 2024
Lab Last Tested December 10, 2024
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.