As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

google.cloud.bigquery.model.Model

class google.cloud.bigquery.model.Model(model_ref)[source]

Model represents a machine learning model resource.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/models

Parameters

model_ref (Union[google.cloud.bigquery.model.ModelReference, str]) – A pointer to a model. If model_ref is a string, it must included a project ID, dataset ID, and model ID, each separated by ..

__init__(model_ref)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(model_ref)

Initialize self.

from_api_repr(resource)

Factory: construct a model resource given its API representation

to_api_repr()

Construct the API resource representation of this model.

Attributes

created

Datetime at which the model was created (None until set from the server).

dataset_id

ID of dataset containing the model.

description

Description of the model (defaults to None).

encryption_configuration

Custom encryption configuration for the model.

etag

ETag for the model resource (None until set from the server).

expires

The datetime when this model expires.

feature_columns

Input feature columns that were used to train this model.

friendly_name

Title of the table (defaults to None).

label_columns

Label columns that were used to train this model.

labels

Labels for the table.

location

The geographic location where the model resides.

model_id

The model ID.

model_type

Type of the model resource.

modified

Datetime at which the model was last modified (None until set from the server).

path

URL path for the model’s APIs.

project

Project bound to the model

reference

A ModelReference pointing to this model.

training_runs

Information for all training runs in increasing order of start time.

property created

Datetime at which the model was created (None until set from the server).

Read-only.

Type

Union[datetime.datetime, None]

property dataset_id

ID of dataset containing the model.

Type

str

property description

Description of the model (defaults to None).

Type

Optional[str]

property encryption_configuration

Custom encryption configuration for the model.

Custom encryption configuration (e.g., Cloud KMS keys) or None if using default encryption.

See protecting data with Cloud KMS keys in the BigQuery documentation.

Type

Optional[google.cloud.bigquery.encryption_configuration.EncryptionConfiguration]

property etag

ETag for the model resource (None until set from the server).

Read-only.

Type

str

property expires

The datetime when this model expires. If not present, the model will persist indefinitely. Expired models will be deleted and their storage reclaimed.

Type

Union[datetime.datetime, None]

property feature_columns

Input feature columns that were used to train this model.

Read-only.

An iterable of StandardSqlField.

Type

Sequence[google.cloud.bigquery_v2.types.StandardSqlField]

property friendly_name

Title of the table (defaults to None).

Raises

ValueError – For invalid value types.

Type

Optional[str]

classmethod from_api_repr(resource: dict)google.cloud.bigquery.model.Model[source]

Factory: construct a model resource given its API representation

Parameters

resource (Dict[str, object]) – Model resource representation from the API

Returns

Model parsed from resource.

Return type

google.cloud.bigquery.model.Model

property label_columns

Label columns that were used to train this model. The output of the model will have a predicted_ prefix to these columns.

Read-only.

An iterable of StandardSqlField.

Type

Sequence[google.cloud.bigquery_v2.types.StandardSqlField]

property labels

Labels for the table.

This method always returns a dict. To change a model’s labels, modify the dict, then call Client.update_model. To delete a label, set its value to None before updating.

Type

Optional[Dict[str, str]]

property location

The geographic location where the model resides. This value is inherited from the dataset.

Read-only.

Type

str

property model_id

The model ID.

Type

str

property model_type

Type of the model resource.

Read-only.

The value is one of elements of the ModelType enumeration.

Type

google.cloud.bigquery_v2.types.Model.ModelType

property modified

Datetime at which the model was last modified (None until set from the server).

Read-only.

Type

Union[datetime.datetime, None]

property path

URL path for the model’s APIs.

Type

str

property project

Project bound to the model

Type

str

property reference

A ModelReference pointing to this model.

Read-only.

Returns

pointer to this model.

Return type

google.cloud.bigquery.model.ModelReference

to_api_repr()dict[source]

Construct the API resource representation of this model.

Returns

Model reference represented as an API resource

Return type

Dict[str, object]

property training_runs

Information for all training runs in increasing order of start time.

Read-only.

An iterable of TrainingRun.

Type

Sequence[google.cloud.bigquery_v2.types.Model.TrainingRun]