Predicting COVID-19 cases using BigQuery ML
By: Prerana Shekhar
Tags: Machine Learning, Covid 19, Simple, Google Data Studio, Bigquery

Exploring BigQuery ML and Data Studio using the COVID-19 dataset.

With the increasing demand for machine learning, we all are eager to explore various datasets and try our hands-on modeling, prediction, and evaluation. However, this requires extensive knowledge of coding and ML frameworks.

Photo by Dominik Scythe on Unsplash

Don’t worry!!!

You don’t need to know PYTHON to do this!! You don’t need to search for DATASETS!!

Google’s BigQuery ML enables us to do this with basic SQL queries. Before we jump into exploring the COVID-19 dataset, let’s get an overview of BigQuery.

What is BigQuery?

“BigQuery is a fully managed, serverless, highly scalable, and cost-effective multi-cloud data warehouse that enables scalable analysis over petabytes of data.”[1] It has a lot of features. To name a few,

BigQuery Omni, that allows you to analyze data across clouds.

BigQuery ML enables data scientists and analytics to build and process models using simple SQL queries.

BigQuery BI Engine is a super-fast in-memory service that allows users to analyze complex datasets that process with subsecond response time.

BigQuery GIS helps to visualize geospatial data using geography data types.

Why BigQuery ML is so easy?

In a typical machine learning problem, one generally looks for datasets, utilizes Jupyter Notebook or Spyder to import the data, train, and test the model. Machine learning on large datasets requires extensive programming and knowledge of ML frameworks. However, BigQuery ML makes it very simple. BigQuery ML empowers data analysts to use machine learning through existing SQL tools and skills [2]. BigQuery ML provides a range of publicly available datasets that are updated in realtime. It minimizes the task of importing huge datasets. With the help of simple SQL queries and Data Studio, one can visualize the data. Model the data using the CREATE MODEL statement, by specifying the MODEL_TYPE. Once, the model is trained, it can be predicted using ML.PREDICT and evaluated using ML.EVALUATE.

BigQuery ML training models

BigQuery ML supports various models such as:

Linear Regression

K-means clustering

Time series

Deep Neural network

Multiclass Logistic regression

Binary Logistic regression

Matrix Factorization

Boosted Tree

BigQuery ML visualization tool — Data Studio

BigQuery ML easily integrates with Data Studio. Data Studio helps to visualize data interactively with various graphs like Time series chart, Pie chart, Geo map, Google maps, Treemap, bar chart, and so on. The parameter and metrics can be easily modified with simple Web UI. In the below example we will try to explore various charts to analyze the data.

Enough of reading!!!

Now let’s get started with a simple example!

Amidst the pandemic, why not do a little bit more analysis on the real data and have insights about the current situation. Here we strive to explore the Covid19 New York Times dataset. This dataset has two tables that give information about the confirmed cases and deaths.

us_counties

us_states

Log in to Google Cloud Console, create a project, and get started with BigQuery.

Let’s visualize the Covid-19 data in the United States. Run the following query in BigQuery to visualize the table “us_states”.

Data Visualization

SELECT * FROM `bigquery-public-data.covid19_nyt.us_states`

ORDER BY date DESC;

Table: us_states

Run the below query to visualize the table “us_counties”.

SELECT * FROM `bigquery-public-data.covid19_nyt.us_counties`

ORDER BY state_name;

Table: us_counties

To find the total number of confirmed cases by each state, run the below query.

WITH state_name_latest_date AS (

SELECT state_name, max(date) AS max_date

FROM `bigquery-public-data.covid19_nyt.us_states`

WHERE state_name = state_name

GROUP BY state_name)





SELECT us.state_name, us.confirmed_cases

FROM state_name_latest_date snld

JOIN `bigquery-public-data.covid19_nyt.us_states` us ON

snld.state_name = us.state_name

AND snld.max_date = us.date

ORDER BY us.confirmed_cases DESC;

Indicates the total number of confirmed cases by state

Click on the link to explore the interactive graph of confirmed cases in Data Studio https://datastudio.google.com/reporting/d2adc5c6-2d4c-4f3e-9af7-11b64089bdc8