The ML.TRANSFORM function

This document describes the ML.TRANSFORM function, which you can use to preprocess feature data. This function processes input data by applying the data transformations captured in the TRANSFORM clause of an existing model. The statistics that were calculated for data transformation during model training are applied to the input data of the function.

For more information about which models support feature preprocessing, see End-to-end user journey for each model.

Syntax

ML.TRANSFORM(
  MODEL `project_id.dataset.model`,
  { TABLE `project_id.dataset.table` | (query_statement) }
)

Arguments

ML.TRANSFORM takes the following arguments:

  • project_id: Your project ID.
  • dataset: a STRING value that specifies the BigQuery dataset that contains the model.
  • model: The name of a model. The model must have been created by using a CREATE MODEL statement that includes a TRANSFORM clause to manually preprocess feature data. You can check to see if a model uses a TRANSFORM clause by using the bq show command to look at the model's metadata. If the model was trained using a TRANSFORM clause, the model metadata contains a section about the transform columns. The function returns an error if you specify a model that was trained without a TRANSFORM clause.
  • table: The name of the input table that contains the feature data to preprocess.

    If table is specified, the input column names in the table must match the input column names in the model's TRANSFORM clause, and their types should be compatible according to BigQuery implicit coercion rules. You can get the input column names and data types from the model's metadata, in the section about the feature columns.

  • query_statement: A query that generates the feature data to preprocess. For the supported SQL syntax of the query_statement clause, see GoogleSQL query syntax.

    If query_statement is specified, the input column names from the query must match the input column names in the model's TRANSFORM clause, and their types should be compatible according to BigQuery implicit coercion rules. You can get the input column names and data types from the model's metadata, in the section about the feature columns.

Output

ML.TRANSFORM returns the columns specified in the model's TRANSFORM clause.

Example

The following example returns feature data that has been preprocessed by using the TRANSFORM clause included in the model named mydataset.mymodel in your de