
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a BigQuery dataset
/ 20
Create a model to predict visitor transaction
/ 20
Evaluate the model
/ 20
Predict purchases per country
/ 20
Predict purchases per user
/ 20
BigQuery ML enables users to create and execute machine learning models in BigQuery using SQL queries. The goal is to democratise machine learning by enabling SQL practitioners to build models using their existing tools and to increase development speed by eliminating the need for data movement.
There is an available ecommerce dataset that has millions of Google Analytics records for the Google Merchandise Store loaded into BigQuery. In this lab, you use this data to create a model that predicts whether a visitor will make a transaction.
In this lab, you learn how to:
To maximize your learning you should have a basic knowledge of SQL or BigQuery.
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 are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
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.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
The Welcome to BigQuery in the Cloud Console message box opens. This message box provides a link to the quickstart guide and the release notes.
The BigQuery console opens.
bqml_lab
and click Create dataset.Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.
Now, move on to your task!
Here the visitor's device's operating system is used, whether said device is a mobile device, the visitor's country and the number of page views as the criteria for whether a transaction has been made.
In this case, bqml_lab
is the name of the dataset and sample_model
is the name of the model. The model type specified is binary logistic regression. In this case, label
is what you're trying to fit to.
input_label_cols
.
The training data is being limited to those collected from 1 August 2016 to 30 June 2017. This is done to save the last month of data for "prediction". It is further limited to 100,000 data points to save some time.
Running the CREATE MODEL
command creates a Query Job that will run asynchronously so you can, for example, close or refresh the BigQuery UI window.
Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.
If interested, you can get information about the model by expanding bqml_lab
dataset and then clicking the sample_model
model in the UI. Under the Details tab you should find some basic model info and training options used to produce the model. Under Training, you should see a table either a table or graphs, depending on your View as settings:
If used with a linear regression model, the above query returns the following columns:
mean_absolute_error
, mean_squared_error
, mean_squared_log_error
,median_absolute_error
, r2_score
, explained_variance
.If used with a logistic regression model, the above query returns the following columns:
precision
, recall
accuracy
, f1_score
log_loss
, roc_auc
Please consult the machine learning glossary or run a Google search to understand how each of these metrics are calculated and what they mean.
You'll realize the SELECT
and FROM
portions of the query are identical to that used during training. The WHERE
portion reflects the change in time frame and the FROM
portion shows that you're calling ml.EVALUATE
.
You should see a table similar to this:
Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.
With this query you will try to predict the number of transactions made by visitors of each country, sort the results, and select the top 10 countries by purchases:
This query is very similar to the evaluation query demonstrated in the previous section. Instead of ml.EVALUATE
, you're using ml.PREDICT
and the BigQuery ML portion of the query is wrapped with standard SQL commands. For this lab you're interested in the country and the sum of purchases for each country, so that's why SELECT
, GROUP BY
and ORDER BY
. LIMIT
is used to ensure you only get the top 10 results.
You should see a table similar to this:
Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.
Here is another example. This time you will try to predict the number of transactions each visitor makes, sort the results, and select the top 10 visitors by transactions:
You should see a table similar to this:
Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.
Below are multiple choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.
You used BigQuery ML to create a binary logistic regression model, evaluate the model, and use the model to make predictions.
...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 February 22, 2024
Lab Last Tested February 22, 2024
Copyright 2025 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.
Ce contenu n'est pas disponible pour le moment
Nous vous préviendrons par e-mail lorsqu'il sera disponible
Parfait !
Nous vous contacterons par e-mail s'il devient disponible
One lab at a time
Confirm to end all existing labs and start this one