BigQuery
This guide describes how to connect Aporia to a BigQuery data source in order to monitor a new ML Model in production.
We will assume that your model inputs, outputs and optionally delayed actuals are stored in a BigQuery table, or can be queried with a BigQuery view.
The BigQuery data source may also be used to connect to your model's training/test set to be used as a baseline for model monitoring.
Creating a service account
First, create a read-only service account for Aporia:
Under IAM & Admin, go to the Service Accounts section in your Google Cloud Platform console.
Click the Create Service Account button at the top of the tab.
Give the account a name and continue. We recommend naming the account "aporia".
Assign the
roles/bigquery.jobUser
role to the service account.Click the Create Key button, select JSON as the type and click Create. A JSON file will be downloaded – please keep it safe.
Click Done to complete the creation of Aporia’s service account.
Next, add permissions to the relevant tables / views:
Go to the BigQuery service in your Google Cloud Platform console.
In the Explorer panel, expand your project and select a dataset.
Expand the dataset and select a table or view.
Click Share.
On the Share tab, Click Add Principal.
In New principals, enter the name of the Service Account you've created for Aporia in the previous step.
Select the
roles/bigquery.dataViewer
role.Click Save to save the changes for the new user.
ServiceAccount credentials
For authentication without service account credentials, please contact your Aporia account manager.
Creating a BigQuery data source in Aporia
To create a new model to be monitored in Aporia, you can call the aporia.create_model(...)
API:
Each model in Aporia contains different Model Versions. When you (re)train your model, you should create a new model version in Aporia.
Each raw input, feature or prediction is mapped by default to the column of the same name in the BigQuery table or view.
By creating a feature named amount
or a prediction named proba
, for example, the BigQuery data source will expect a column in the BigQuery table named amount
or proba
, respectively.
Next, create an instance of BigQueryDataSource
and pass it to apr_model.connect_serving(...)
or apr_model.connect_training(...)
:
Note that as part of the connect_serving
API, you are required to specify additional 2 columns:
id_column
- A unique ID to represent this prediction.timestamp_column
- A column representing when did this prediction occur.
What's Next
For more information on:
Advanced feature / prediction <-> column mapping
How to integrate delayed actuals
How to integrate training / test sets
Last updated