models
Creates, updates, deletes, gets or lists a models
resource.
Overview
Name | models |
Type | Resource |
Id | google.bigquery.models |
Fields
The following fields are returned by SELECT
queries:
- get
- list
Successful response
Name | Datatype | Description |
---|---|---|
bestTrialId | string (int64) | The best trial_id across all training runs. |
creationTime | string (int64) | Output only. The time when this model was created, in millisecs since the epoch. |
defaultTrialId | string (int64) | Output only. The default trial_id to use in TVFs when the trial_id is not passed in. For single-objective hyperparameter tuning models, this is the best trial ID. For multi-objective hyperparameter tuning models, this is the smallest trial ID among all Pareto optimal trials. |
description | string | Optional. A user-friendly description of this model. |
encryptionConfiguration | object | Custom encryption configuration (e.g., Cloud KMS keys). This shows the encryption configuration of the model data while stored in BigQuery storage. This field can be used with PatchModel to update encryption key for an already encrypted model. (id: EncryptionConfiguration) |
etag | string | Output only. A hash of this resource. |
expirationTime | string (int64) | Optional. The time when this model expires, in milliseconds since the epoch. If not present, the model will persist indefinitely. Expired models will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created models. |
featureColumns | array | Output only. Input feature columns for the model inference. If the model is trained with TRANSFORM clause, these are the input of the TRANSFORM clause. |
friendlyName | string | Optional. A descriptive name for this model. |
hparamSearchSpaces | object | Output only. All hyperparameter search spaces in this model. (id: HparamSearchSpaces) |
hparamTrials | array | Output only. Trials of a hyperparameter tuning model sorted by trial_id. |
labelColumns | array | Output only. Label columns that were used to train this model. The output of the model will have a "predicted_" prefix to these columns. |
labels | object | The labels associated with this model. You can use these to organize and group your models. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. |
lastModifiedTime | string (int64) | Output only. The time when this model was last modified, in millisecs since the epoch. |
location | string | Output only. The geographic location where the model resides. This value is inherited from the dataset. |
modelReference | object | Required. Unique identifier for this model. (id: ModelReference) |
modelType | string | Output only. Type of the model resource. |
optimalTrialIds | array | Output only. For single-objective hyperparameter tuning models, it only contains the best trial. For multi-objective hyperparameter tuning models, it contains all Pareto optimal trials sorted by trial_id. |
remoteModelInfo | object | Output only. Remote model info (id: RemoteModelInfo) |
trainingRuns | array | Information for all training runs in increasing order of start_time. |
transformColumns | array | Output only. This field will be populated if a TRANSFORM clause was used to train a model. TRANSFORM clause (if used) takes feature_columns as input and outputs transform_columns. transform_columns then are used to train the model. |
Successful response
Name | Datatype | Description |
---|---|---|
bestTrialId | string (int64) | The best trial_id across all training runs. |
creationTime | string (int64) | Output only. The time when this model was created, in millisecs since the epoch. |
defaultTrialId | string (int64) | Output only. The default trial_id to use in TVFs when the trial_id is not passed in. For single-objective hyperparameter tuning models, this is the best trial ID. For multi-objective hyperparameter tuning models, this is the smallest trial ID among all Pareto optimal trials. |
description | string | Optional. A user-friendly description of this model. |
encryptionConfiguration | object | Custom encryption configuration (e.g., Cloud KMS keys). This shows the encryption configuration of the model data while stored in BigQuery storage. This field can be used with PatchModel to update encryption key for an already encrypted model. (id: EncryptionConfiguration) |
etag | string | Output only. A hash of this resource. |
expirationTime | string (int64) | Optional. The time when this model expires, in milliseconds since the epoch. If not present, the model will persist indefinitely. Expired models will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created models. |
featureColumns | array | Output only. Input feature columns for the model inference. If the model is trained with TRANSFORM clause, these are the input of the TRANSFORM clause. |
friendlyName | string | Optional. A descriptive name for this model. |
hparamSearchSpaces | object | Output only. All hyperparameter search spaces in this model. (id: HparamSearchSpaces) |
hparamTrials | array | Output only. Trials of a hyperparameter tuning model sorted by trial_id. |
labelColumns | array | Output only. Label columns that were used to train this model. The output of the model will have a "predicted_" prefix to these columns. |
labels | object | The labels associated with this model. You can use these to organize and group your models. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. |
lastModifiedTime | string (int64) | Output only. The time when this model was last modified, in millisecs since the epoch. |
location | string | Output only. The geographic location where the model resides. This value is inherited from the dataset. |
modelReference | object | Required. Unique identifier for this model. (id: ModelReference) |
modelType | string | Output only. Type of the model resource. |
optimalTrialIds | array | Output only. For single-objective hyperparameter tuning models, it only contains the best trial. For multi-objective hyperparameter tuning models, it contains all Pareto optimal trials sorted by trial_id. |
remoteModelInfo | object | Output only. Remote model info (id: RemoteModelInfo) |
trainingRuns | array | Information for all training runs in increasing order of start_time. |
transformColumns | array | Output only. This field will be populated if a TRANSFORM clause was used to train a model. TRANSFORM clause (if used) takes feature_columns as input and outputs transform_columns. transform_columns then are used to train the model. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get | select | projectId , +datasetId , +modelId | Gets the specified model resource by model ID. | |
list | select | projectId , +datasetId | maxResults , pageToken | Lists all models in the specified dataset. Requires the READER dataset role. After retrieving the list of models, you can get information about a particular model by calling the models.get method. |
patch | update | projectId , +datasetId , +modelId | Patch specific fields in the specified model. | |
delete | delete | projectId , +datasetId , +modelId | Deletes the model specified by modelId from the dataset. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
+datasetId | string | |
+modelId | string | |
projectId | string | |
maxResults | integer (uint32) | |
pageToken | string |
SELECT
examples
- get
- list
Gets the specified model resource by model ID.
SELECT
bestTrialId,
creationTime,
defaultTrialId,
description,
encryptionConfiguration,
etag,
expirationTime,
featureColumns,
friendlyName,
hparamSearchSpaces,
hparamTrials,
labelColumns,
labels,
lastModifiedTime,
location,
modelReference,
modelType,
optimalTrialIds,
remoteModelInfo,
trainingRuns,
transformColumns
FROM google.bigquery.models
WHERE projectId = '{{ projectId }}' -- required
AND +datasetId = '{{ +datasetId }}' -- required
AND +modelId = '{{ +modelId }}' -- required;
Lists all models in the specified dataset. Requires the READER dataset role. After retrieving the list of models, you can get information about a particular model by calling the models.get method.
SELECT
bestTrialId,
creationTime,
defaultTrialId,
description,
encryptionConfiguration,
etag,
expirationTime,
featureColumns,
friendlyName,
hparamSearchSpaces,
hparamTrials,
labelColumns,
labels,
lastModifiedTime,
location,
modelReference,
modelType,
optimalTrialIds,
remoteModelInfo,
trainingRuns,
transformColumns
FROM google.bigquery.models
WHERE projectId = '{{ projectId }}' -- required
AND +datasetId = '{{ +datasetId }}' -- required
AND maxResults = '{{ maxResults }}'
AND pageToken = '{{ pageToken }}';
UPDATE
examples
- patch
Patch specific fields in the specified model.
UPDATE google.bigquery.models
SET
data__bestTrialId = '{{ bestTrialId }}',
data__description = '{{ description }}',
data__encryptionConfiguration = '{{ encryptionConfiguration }}',
data__expirationTime = '{{ expirationTime }}',
data__friendlyName = '{{ friendlyName }}',
data__labels = '{{ labels }}',
data__modelReference = '{{ modelReference }}',
data__trainingRuns = '{{ trainingRuns }}'
WHERE
projectId = '{{ projectId }}' --required
AND +datasetId = '{{ +datasetId }}' --required
AND +modelId = '{{ +modelId }}' --required
RETURNING
bestTrialId,
creationTime,
defaultTrialId,
description,
encryptionConfiguration,
etag,
expirationTime,
featureColumns,
friendlyName,
hparamSearchSpaces,
hparamTrials,
labelColumns,
labels,
lastModifiedTime,
location,
modelReference,
modelType,
optimalTrialIds,
remoteModelInfo,
trainingRuns,
transformColumns;
DELETE
examples
- delete
Deletes the model specified by modelId from the dataset.
DELETE FROM google.bigquery.models
WHERE projectId = '{{ projectId }}' --required
AND +datasetId = '{{ +datasetId }}' --required
AND +modelId = '{{ +modelId }}' --required;