> For the complete documentation index, see [llms.txt](https://academy.carto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://academy.carto.com/creating-workflows/workflow-templates/bigquery-ml.md).

# BigQuery ML

{% hint style="success" %}
For this templates, you will need to install the [**BigQuery ML extension package**](https://docs.carto.com/carto-user-manual/workflows/components/bigquery-ml).
{% endhint %}

### Create a classification model

<table data-full-width="false"><thead><tr><th align="center">CARTO DW</th><th width="154" align="center">BigQuery</th><th data-hidden>Snowflake</th><th data-hidden>Redshift</th><th data-hidden>PostgreSQL</th><th data-hidden>CARTO DW</th></tr></thead><tbody><tr><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td></tr></tbody></table>

This example shows how to create a pipeline to train a classification model using [BigQuery ML](https://cloud.google.com/bigquery/docs/e2e-journey), evaluate the model and use it for prediction. In particular, we will create a classification model to estimate customer churn for a telecom company in California.

This example workflow will help you see how telco companies can detect high-risk customers, uncover the reasons behind customer departures, and develop targeted strategies to boost retention and satisfaction by training a classification model.

[**Download example**](https://storage.googleapis.com/carto-workflows-examples/files/bq_ml_create_classification_model.sql)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FSg4F2IuRwyHdIadJ9FiZ%2Fbq_ml_create_classification_model.png?alt=media&amp;token=287d8474-8d8a-42d5-9ac4-43d30cb54f3b" alt=""><figcaption></figcaption></figure>

### Create a regression model

<table data-full-width="false"><thead><tr><th align="center">CARTO DW</th><th width="154" align="center">BigQuery</th><th data-hidden>Snowflake</th><th data-hidden>Redshift</th><th data-hidden>PostgreSQL</th><th data-hidden>CARTO DW</th></tr></thead><tbody><tr><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td></tr></tbody></table>

This example shows how to create a pipeline to train a regression model using [BigQuery ML](https://cloud.google.com/bigquery/docs/e2e-journey), evaluate the model and use it for prediction. In particular, we will create a regression model to predict the average network speed in the LA area.

This example workflow will help you see how telco companies can improve network planning use by training a regression model to estimate the network speed in areas where no measurements are available.

[**Download example**](https://storage.googleapis.com/carto-workflows-examples/files/bq_ml_create_regression_model.sql)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FAbsv12sCQ70JsOcrWX1a%2Fbq_ml_create_regression_model.png?alt=media&amp;token=0bea4f74-5afa-4061-a4f4-17db9f0eb3e2" alt=""><figcaption></figcaption></figure>

### Forecast

<table data-full-width="false"><thead><tr><th align="center">CARTO DW</th><th width="154" align="center">BigQuery</th><th data-hidden>Snowflake</th><th data-hidden>Redshift</th><th data-hidden>PostgreSQL</th><th data-hidden>CARTO DW</th></tr></thead><tbody><tr><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td></tr></tbody></table>

This template shows how to create a forecast model using the BigQuery ML extension package for Workflows. There are three main stages involved:

* **Training a model**, using some input data and adjusting to the desired parameters,
* **Evaluating and understanding** the model and its performance,
* **Predicting to a given horizon** and saving the results.

[**Download example**](https://storage.googleapis.com/carto-workflows-examples/files/bq_ml_forecast.sql)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FUzDRVPu4thPkYGaWYrzB%2Fbq_ml_forecast.png?alt=media&amp;token=eb9d7534-a5f3-427e-9c8b-c4f4cbdd1c97" alt=""><figcaption></figcaption></figure>

### Import a model

<table data-full-width="false"><thead><tr><th align="center">CARTO DW</th><th width="154" align="center">BigQuery</th><th data-hidden>Snowflake</th><th data-hidden>Redshift</th><th data-hidden>PostgreSQL</th><th data-hidden>CARTO DW</th></tr></thead><tbody><tr><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td></tr></tbody></table>

This example shows how to create a pipeline to import a pre-trained model using [BigQuery ML](https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-onnx) and use it for prediction. In particular, we will import a regression model to predict the ration of crime counts per 1000 population in the Chicago area.

[**Download example**](https://storage.googleapis.com/carto-workflows-examples/files/bq_ml_import.sql)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FqfEeHNzrizSE2r0lsx4k%2Fbq_ml_import.png?alt=media&amp;token=ebb76253-ce6c-406e-8581-594e393a0c5a" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://academy.carto.com/creating-workflows/workflow-templates/bigquery-ml.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
