# 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="/files/CA0BGIxBxRcs4N4IZ7CF" 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="/files/9FXBbE9EuIxPsKQZf2rX" 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="/files/uU7zZWqdv5pXOFGoZRHS" 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="/files/fnLaoxtzz1azfJxeOU63" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
