Checkpoints
Develop and Deploy model using Python
/ 40
Real time prediction Dataflow job is running
/ 30
Real time predictions in BigQuery
/ 30
Real Time Machine Learning with Cloud Dataflow and Vertex AI
GSP275
Overview
In this lab you implement a real-time, streaming, machine learning (ML) pipeline that uses Cloud Dataflow and Vertex AI.
Dataflow is a managed service for executing a wide variety of data processing patterns.
Vertex AI is a unified ML platform used to build, deploy, and scale ML models with pre-trained and custom tooling within a unified artificial intelligence platform.
The historical dataset this lab uses is from the US Bureau of Transport Statistics website and provides historic information about internal flights in the United States.
This lab uses a set of code samples and scripts developed for the Data Science on Google Cloud Platform, 2nd Edition from O'Reilly Media, Inc.
Objectives
-
Configure and execute a real time flight event simulation in Python
-
Configure and deploy a streaming Google Cloud Dataflow job to provide real-time flight delay 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.
How to start your lab and sign in to the Google Cloud Console
-
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
- The Open Google Console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.
-
Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.
Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
Click through the subsequent pages:
- Accept the terms and conditions.
- Do not add recovery options or two-factor authentication (because this is a temporary account).
- Do not sign up for free trials.
After a few moments, the Cloud Console opens in this tab.
Task 1. Clone the Data Science on Google Cloud repository
-
In the Cloud Console, on the Navigation menu (
), click Compute Engine > VM instances.
-
Click the SSH button inline with
lab-vm-ql
VM to launch and connect to a terminal. This terminal is called terminal-1. -
Click Connect to confirm the connection.
-
In terminal-1, enter the following command to clone the repository:
-
Navigate to the repository source directory for this lab:
-
Install the required packages:
Task 2. Machine learning training dataset
-
Run a Dataflow pipeline to create the training dataset:
While the pipeline is running, use the Google Cloud Console to monitor the progress of the job.
-
In the Cloud Console, on the Navigation menu (
), click More Products > Dataflow.
-
Click the name of the Dataflow job to open the job details page. This lets you monitor the progress of your job.
Task 3. Train the model
Run a script to train the model. For more information about the script, see Chapter 10, Data Science on Google Cloud Platform, 2nd Edition.
-
Run script that copies over the Ch10 model.py and train_on_vertexai.py files and makes the necessary changes:
-
Train custom ML model on the enriched dataset:
-
In the Cloud Console, on the Navigation menu, click Vertex AI > Training to monitor the training pipeline.
-
When the status is Finished, click on the training pipeline name to monitor the deployment status.
Click Check my progress to verify the objective.
-
In terminal-1, create a small, local sample of BigQuery datasets for local experimentation:
-
Run a local pipeline to invoke predictions:
-
Verify the results:
Task 4. Stream data through your pipeline
-
In Cloud Console, click the SSH button next to
lab-vm-ql
VM to launch another terminal. This terminal is terminal-2. -
Click Connect to confirm the connection.
-
In terminal-2, run the following to start the flight simulation script:
This script generates flight data events using the real flight data from 2015.
-
In terminal-1, run the real-time prediction Dataflow job:
- In the Cloud Console, from the Navigation menu, click Dataflow, then the job name to monitor the running pipeline.
Click Check my progress to verify the objective.
-
With the pipeline running, navigate to the BigQuery console and verify that flight information is indeed getting streamed in.
-
In the Cloud Console, click Navigation menu > BigQuery.
-
In the Query Editor, add the following query:
- If the query has an error (red exclamation point) wait a couple more minutes until the query check passes (green check mark) then click RUN.
When the script runs, you see data being written into this BigQuery table, the real-time prediction service running on Cloud Dataflow is generating predictions in real-time using the flight data generated by the simulate.py
script.
Click Check my progress to verify the objective.
Congratulations!
You implemented a real-time, streaming machine learning pipeline that uses Cloud Dataflow and Vertex AI.
Finish your quest
This self-paced lab is part of the Data Science on Google Cloud: Machine Learning quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in any quest that contains this lab and get immediate completion credit. See the Google Cloud Skills Boost catalog to see all available quests.
Take your next lab
This is the last lab in this Quest! If you did not take the labs in order, continue with another lab in this quest, for example:
Or, continue your learning with another quest, for example Advanced ML: ML Infrastructure.
Next steps / learn more
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 September 28, 2022
Lab Last Tested June 16, 2022
Copyright 2023 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.