Client for Cloud AutoML API#

class google.cloud.automl_v1beta1.AutoMlClient(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]#

AutoML Server API.

The resource names are assigned by the server. The server never reuses names that it has created after the resources with those names are deleted.

An ID of a resource is the last element of the item’s resource name. For projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then the id for the item is {dataset_id}.

Currently the only supported location_id is “us-central1”.

On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.

Constructor.

Parameters
  • (Union[AutoMlGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.AutoMlGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.

  • channel (grpc.Channel) – DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

  • credentials (google.auth.credentials.Credentials) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

  • client_config (dict) – DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

  • client_options (Union[dict, google.api_core.client_options.ClientOptions]) – Client options used to set user options on the client. API Endpoint should be set through client_options.

classmethod annotation_spec_path(project, location, dataset, annotation_spec)[source]#

Return a fully-qualified annotation_spec string.

classmethod column_spec_path(project, location, dataset, table_spec, column_spec)[source]#

Return a fully-qualified column_spec string.

create_dataset(parent, dataset, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Creates a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # TODO: Initialize `dataset`:
>>> dataset = {}
>>>
>>> response = client.create_dataset(parent, dataset)
Parameters
  • parent (str) – The resource name of the project to create the dataset for.

  • dataset (Union[dict, Dataset]) –

    The dataset to create.

    If a dict is provided, it must be of the same form as the protobuf message Dataset

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A Dataset instance.

Raises
create_model(parent, model, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Creates a model. Returns a Model in the response field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # TODO: Initialize `model`:
>>> model = {}
>>>
>>> response = client.create_model(parent, model)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • parent (str) – Resource name of the parent project where the model is being created.

  • model (Union[dict, Model]) –

    The model to create.

    If a dict is provided, it must be of the same form as the protobuf message Model

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
classmethod dataset_path(project, location, dataset)[source]#

Return a fully-qualified dataset string.

delete_dataset(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Deletes a dataset and all of its contents. Returns empty response in the response field when it completes, and delete_details in the metadata field.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> response = client.delete_dataset(name)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – The resource name of the dataset to delete.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
delete_model(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Deletes a model. Returns google.protobuf.Empty in the response field when it completes, and delete_details in the metadata field.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> response = client.delete_model(name)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Resource name of the model being deleted.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
deploy_model(name, image_object_detection_model_deployment_metadata=None, image_classification_model_deployment_metadata=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different parametrs (as e.g. changing

node_number) will reset the deployment state without pausing the model’s availability.

Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> response = client.deploy_model(name)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
Returns

A _OperationFuture instance.

Raises
enums = <module 'google.cloud.automl_v1beta1.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/automl_v1beta1/gapic/enums.py'>#
export_data(name, output_config, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Exports dataset’s data to the provided output location. Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> # TODO: Initialize `output_config`:
>>> output_config = {}
>>>
>>> response = client.export_data(name, output_config)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Required. The resource name of the dataset.

  • output_config (Union[dict, OutputConfig]) –

    Required. The desired output location.

    If a dict is provided, it must be of the same form as the protobuf message OutputConfig

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
export_evaluated_examples(name, output_config, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Exports examples on which the model was evaluated (i.e. which were in the TEST set of the dataset the model was created from), together with their ground truth annotations and the annotations created (predicted) by the model. The examples, ground truth and predictions are exported in the state they were at the moment the model was evaluated.

This export is available only for 30 days since the model evaluation is created.

Currently only available for Tables.

Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # TODO: Initialize `output_config`:
>>> output_config = {}
>>>
>>> response = client.export_evaluated_examples(name, output_config)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Required. The resource name of the model whose evaluated examples are to be exported.

  • output_config (Union[dict, ExportEvaluatedExamplesOutputConfig]) –

    Required. The desired output location and configuration.

    If a dict is provided, it must be of the same form as the protobuf message ExportEvaluatedExamplesOutputConfig

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
export_model(name, output_config, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Exports a trained, “export-able”, model to a user specified Google Cloud Storage location. A model is considered export-able if and only if it has an export format defined for it in

ModelExportOutputConfig.

Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # TODO: Initialize `output_config`:
>>> output_config = {}
>>>
>>> response = client.export_model(name, output_config)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Required. The resource name of the model to export.

  • output_config (Union[dict, ModelExportOutputConfig]) –

    Required. The desired output location and configuration.

    If a dict is provided, it must be of the same form as the protobuf message ModelExportOutputConfig

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
classmethod from_service_account_file(filename, *args, **kwargs)[source]#

Creates an instance of this client using the provided credentials file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AutoMlClient

classmethod from_service_account_json(filename, *args, **kwargs)#

Creates an instance of this client using the provided credentials file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AutoMlClient

get_annotation_spec(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets an annotation spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.annotation_spec_path('[PROJECT]', '[LOCATION]', '[DATASET]', '[ANNOTATION_SPEC]')
>>>
>>> response = client.get_annotation_spec(name)
Parameters
  • name (str) – The resource name of the annotation spec to retrieve.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A AnnotationSpec instance.

Raises
get_column_spec(name, field_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets a column spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.column_spec_path('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]', '[COLUMN_SPEC]')
>>>
>>> response = client.get_column_spec(name)
Parameters
  • name (str) – The resource name of the column spec to retrieve.

  • field_mask (Union[dict, FieldMask]) –

    Mask specifying which fields to read.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A ColumnSpec instance.

Raises
get_dataset(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> response = client.get_dataset(name)
Parameters
  • name (str) – The resource name of the dataset to retrieve.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A Dataset instance.

Raises
get_model(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets a model.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> response = client.get_model(name)
Parameters
  • name (str) – Resource name of the model.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A Model instance.

Raises
get_model_evaluation(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets a model evaluation.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_evaluation_path('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]')
>>>
>>> response = client.get_model_evaluation(name)
Parameters
  • name (str) – Resource name for the model evaluation.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A ModelEvaluation instance.

Raises
get_table_spec(name, field_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Gets a table spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.table_spec_path('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]')
>>>
>>> response = client.get_table_spec(name)
Parameters
  • name (str) – The resource name of the table spec to retrieve.

  • field_mask (Union[dict, FieldMask]) –

    Mask specifying which fields to read.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A TableSpec instance.

Raises
import_data(name, input_config, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Imports data into a dataset. For Tables this method can only be called on an empty Dataset.

For Tables:

  • A schema_inference_version parameter must be explicitly set. Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> # TODO: Initialize `input_config`:
>>> input_config = {}
>>>
>>> response = client.import_data(name, input_config)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Required. Dataset name. Dataset must already exist. All imported annotations and examples will be added.

  • input_config (Union[dict, InputConfig]) –

    Required. The desired input location and its domain specific semantics, if any.

    If a dict is provided, it must be of the same form as the protobuf message InputConfig

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
list_column_specs(parent, field_mask=None, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Lists column specs in a table spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.table_spec_path('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]')
>>>
>>> # Iterate over all results
>>> for element in client.list_column_specs(parent):
...     # process element
...     pass
>>>
>>>
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_column_specs(parent).pages:
...     for element in page:
...         # process element
...         pass
Parameters
  • parent (str) – The resource name of the table spec to list column specs from.

  • field_mask (Union[dict, FieldMask]) –

    Mask specifying which fields to read.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • filter_ (str) – Filter expression, see go/filtering.

  • page_size (int) – The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PageIterator instance. An iterable of ColumnSpec instances. You can also iterate over the pages of the response using its pages property.

Raises
list_datasets(parent, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Lists datasets in a project.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # Iterate over all results
>>> for element in client.list_datasets(parent):
...     # process element
...     pass
>>>
>>>
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_datasets(parent).pages:
...     for element in page:
...         # process element
...         pass
Parameters
  • parent (str) – The resource name of the project from which to list datasets.

  • filter_ (str) –

    An expression for filtering the results of the request.

    • dataset_metadata - for existence of the case (e.g. image_classification_dataset_metadata:*). Some examples of using the filter are:

    • translation_dataset_metadata:* –> The dataset has translation_dataset_metadata.

  • page_size (int) – The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PageIterator instance. An iterable of Dataset instances. You can also iterate over the pages of the response using its pages property.

Raises
list_model_evaluations(parent, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Lists model evaluations.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # Iterate over all results
>>> for element in client.list_model_evaluations(parent):
...     # process element
...     pass
>>>
>>>
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_model_evaluations(parent).pages:
...     for element in page:
...         # process element
...         pass
Parameters
  • parent (str) – Resource name of the model to list the model evaluations for. If modelId is set as “-“, this will list model evaluations from across all models of the parent location.

  • filter_ (str) –

    An expression for filtering the results of the request.

    • annotation_spec_id - for =, != or existence. See example below for the last.

    Some examples of using the filter are:

    • annotation_spec_id!=4 –> The model evaluation was done for annotation spec with ID different than 4.

    • NOT annotation_spec_id:* –> The model evaluation was done for aggregate of all annotation specs.

  • page_size (int) – The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PageIterator instance. An iterable of ModelEvaluation instances. You can also iterate over the pages of the response using its pages property.

Raises
list_models(parent, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Lists models.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # Iterate over all results
>>> for element in client.list_models(parent):
...     # process element
...     pass
>>>
>>>
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_models(parent).pages:
...     for element in page:
...         # process element
...         pass
Parameters
  • parent (str) – Resource name of the project, from which to list the models.

  • filter_ (str) –

    An expression for filtering the results of the request.

    • model_metadata - for existence of the case (e.g. video_classification_model_metadata:*).

    • dataset_id - for = or !=. Some examples of using the filter are:

    • image_classification_model_metadata:* –> The model has image_classification_model_metadata.

    • dataset_id=5 –> The model was created from a dataset with ID 5.

  • page_size (int) – The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PageIterator instance. An iterable of Model instances. You can also iterate over the pages of the response using its pages property.

Raises
list_table_specs(parent, field_mask=None, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Lists table specs in a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> parent = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> # Iterate over all results
>>> for element in client.list_table_specs(parent):
...     # process element
...     pass
>>>
>>>
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_table_specs(parent).pages:
...     for element in page:
...         # process element
...         pass
Parameters
  • parent (str) – The resource name of the dataset to list table specs from.

  • field_mask (Union[dict, FieldMask]) –

    Mask specifying which fields to read.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • filter_ (str) – Filter expression, see go/filtering.

  • page_size (int) – The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PageIterator instance. An iterable of TableSpec instances. You can also iterate over the pages of the response using its pages property.

Raises
classmethod location_path(project, location)[source]#

Return a fully-qualified location string.

classmethod model_evaluation_path(project, location, model, model_evaluation)[source]#

Return a fully-qualified model_evaluation string.

classmethod model_path(project, location, model)[source]#

Return a fully-qualified model string.

classmethod table_spec_path(project, location, dataset, table_spec)[source]#

Return a fully-qualified table_spec string.

undeploy_model(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Undeploys a model. If the model is not deployed this method has no effect.

Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> response = client.undeploy_model(name)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Resource name of the model to undeploy.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
update_column_spec(column_spec, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Updates a column spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> # TODO: Initialize `column_spec`:
>>> column_spec = {}
>>>
>>> response = client.update_column_spec(column_spec)
Parameters
  • column_spec (Union[dict, ColumnSpec]) –

    The column spec which replaces the resource on the server.

    If a dict is provided, it must be of the same form as the protobuf message ColumnSpec

  • update_mask (Union[dict, FieldMask]) –

    The update mask applies to the resource.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A ColumnSpec instance.

Raises
update_dataset(dataset, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Updates a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> # TODO: Initialize `dataset`:
>>> dataset = {}
>>>
>>> response = client.update_dataset(dataset)
Parameters
  • dataset (Union[dict, Dataset]) –

    The dataset which replaces the resource on the server.

    If a dict is provided, it must be of the same form as the protobuf message Dataset

  • update_mask (Union[dict, FieldMask]) –

    The update mask applies to the resource.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A Dataset instance.

Raises
update_table_spec(table_spec, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Updates a table spec.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.AutoMlClient()
>>>
>>> # TODO: Initialize `table_spec`:
>>> table_spec = {}
>>>
>>> response = client.update_table_spec(table_spec)
Parameters
  • table_spec (Union[dict, TableSpec]) –

    The table spec which replaces the resource on the server.

    If a dict is provided, it must be of the same form as the protobuf message TableSpec

  • update_mask (Union[dict, FieldMask]) –

    The update mask applies to the resource.

    If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A TableSpec instance.

Raises
class google.cloud.automl_v1beta1.PredictionServiceClient(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]#

AutoML Prediction API.

On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.

Constructor.

Parameters
  • (Union[PredictionServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.PredictionServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.

  • channel (grpc.Channel) – DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

  • credentials (google.auth.credentials.Credentials) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

  • client_config (dict) – DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

  • client_options (Union[dict, google.api_core.client_options.ClientOptions]) – Client options used to set user options on the client. API Endpoint should be set through client_options.

batch_predict(name, input_config, output_config, params=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Perform a batch prediction. Unlike the online Predict, batch prediction result won’t be immediately available in the response. Instead, a long running operation object is returned. User can poll the operation result via GetOperation method. Once the operation is done, BatchPredictResult is returned in the response field. Available for following ML problems:

  • Image Classification

  • Image Object Detection

  • Video Classification

  • Video Object Tracking * Text Extraction

  • Tables

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.PredictionServiceClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # TODO: Initialize `input_config`:
>>> input_config = {}
>>>
>>> # TODO: Initialize `output_config`:
>>> output_config = {}
>>>
>>> response = client.batch_predict(name, input_config, output_config)
>>>
>>> def callback(operation_future):
...     # Handle result.
...     result = operation_future.result()
>>>
>>> response.add_done_callback(callback)
>>>
>>> # Handle metadata.
>>> metadata = response.metadata()
Parameters
  • name (str) – Name of the model requested to serve the batch prediction.

  • input_config (Union[dict, BatchPredictInputConfig]) –

    Required. The input configuration for batch prediction.

    If a dict is provided, it must be of the same form as the protobuf message BatchPredictInputConfig

  • output_config (Union[dict, BatchPredictOutputConfig]) –

    Required. The Configuration specifying where output predictions should be written.

    If a dict is provided, it must be of the same form as the protobuf message BatchPredictOutputConfig

  • params (dict[str -> str]) –

    Additional domain-specific parameters for the predictions, any string must be up to 25000 characters long.

    • For Text Classification:

      score_threshold - (float) A value from 0.0 to 1.0. When the model makes predictions for a text snippet, it will only produce results that have at least this confidence score. The default is 0.5.

    • For Image Classification:

      score_threshold - (float) A value from 0.0 to 1.0. When the model makes predictions for an image, it will only produce results that have at least this confidence score. The default is 0.5.

    • For Image Object Detection:

      score_threshold - (float) When Model detects objects on the image, it will only produce bounding boxes which have at least this confidence score. Value in 0 to 1 range, default is 0.5. max_bounding_box_count - (int64) No more than this number of bounding boxes will be produced per image. Default is 100, the requested value may be limited by server.

    • For Video Classification : score_threshold - (float) A value from 0.0 to 1.0. When the model makes predictions for a video, it will only produce results that have at least this confidence score. The default is 0.5. segment_classification - (boolean) Set to true to request segment-level classification. AutoML Video Intelligence returns labels and their confidence scores for the entire segment of the video that user specified in the request configuration. The default is “true”. shot_classification - (boolean) Set to true to request shot-level classification. AutoML Video Intelligence determines the boundaries for each camera shot in the entire segment of the video that user specified in the request configuration. AutoML Video Intelligence then returns labels and their confidence scores for each detected shot, along with the start and end time of the shot. WARNING: Model evaluation is not done for this classification type, the quality of it depends on training data, but there are no metrics provided to describe that quality. The default is “false”. 1s_interval_classification - (boolean) Set to true to request classification for a video at one-second intervals. AutoML Video Intelligence returns labels and their confidence scores for each second of the entire segment of the video that user specified in the request configuration. WARNING: Model evaluation is not done for this classification type, the quality of it depends on training data, but there are no metrics provided to describe that quality. The default is “false”.

    • For Video Object Tracking: score_threshold - (float) When Model detects objects on video frames, it will only produce bounding boxes which have at least this confidence score. Value in 0 to 1 range, default is 0.5. max_bounding_box_count - (int64) No more than this number of bounding boxes will be returned per frame. Default is 100, the requested value may be limited by server. min_bounding_box_size - (float) Only bounding boxes with shortest edge at least that long as a relative value of video frame size will be returned. Value in 0 to 1 range. Default is 0.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A _OperationFuture instance.

Raises
enums = <module 'google.cloud.automl_v1beta1.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/automl_v1beta1/gapic/enums.py'>#
classmethod from_service_account_file(filename, *args, **kwargs)[source]#

Creates an instance of this client using the provided credentials file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

PredictionServiceClient

classmethod from_service_account_json(filename, *args, **kwargs)#

Creates an instance of this client using the provided credentials file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

PredictionServiceClient

classmethod model_path(project, location, model)[source]#

Return a fully-qualified model string.

predict(name, payload, params=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

Perform an online prediction. The prediction result will be directly returned in the response. Available for following ML problems, and their expected request payloads:

  • Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.

  • Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.

  • Text Classification - TextSnippet, content up to 60,000 characters, UTF-8 encoded.

  • Text Extraction - TextSnippet, content up to 30,000 characters, UTF-8 NFC encoded.

  • Translation - TextSnippet, content up to 25,000 characters, UTF-8 encoded.

  • Tables - Row, with column values matching the columns of the model, up to 5MB. Not available for FORECASTING

prediction_type.

  • Text Sentiment - TextSnippet, content up 500 characters, UTF-8 encoded.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.PredictionServiceClient()
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # TODO: Initialize `payload`:
>>> payload = {}
>>>
>>> response = client.predict(name, payload)
Parameters
  • name (str) – Name of the model requested to serve the prediction.

  • payload (Union[dict, ExamplePayload]) –

    Required. Payload to perform a prediction on. The payload must match the problem type that the model was trained to solve.

    If a dict is provided, it must be of the same form as the protobuf message ExamplePayload

  • params (dict[str -> str]) –

    Additional domain-specific parameters, any string must be up to 25000 characters long.

    • For Image Classification:

      score_threshold - (float) A value from 0.0 to 1.0. When the model makes predictions for an image, it will only produce results that have at least this confidence score. The default is 0.5.

    • For Image Object Detection: score_threshold - (float) When Model detects objects on the image, it will only produce bounding boxes which have at least this confidence score. Value in 0 to 1 range, default is 0.5. max_bounding_box_count - (int64) No more than this number of bounding boxes will be returned in the response. Default is 100, the requested value may be limited by server.

    • For Tables: feature_importance - (boolean) Whether

    [feature_importance][[google.cloud.automl.v1beta1.TablesModelColumnInfo.feature_importance] should be populated in the returned

    [TablesAnnotation(-s)][[google.cloud.automl.v1beta1.TablesAnnotation]. The default is false.

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

  • timeout (Optional[float]) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

  • metadata (Optional[Sequence[Tuple[str, str]]]) – Additional metadata that is provided to the method.

Returns

A PredictResponse instance.

Raises
class google.cloud.automl_v1beta1.TablesClient(project=None, region='us-central1', client=None, prediction_client=None, gcs_client=None, **kwargs)[source]#

AutoML Tables API helper.

This is intended to simplify usage of the auto-generated python client, in particular for the AutoML Tables product.

Constructor.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
Parameters
  • project (Optional[string]) – The project all future calls will default to. Most methods take project as an optional parameter, and can override your choice of project supplied here.

  • region (Optional[string]) – The region all future calls will default to. Most methods take region as an optional parameter, and can override your choice of region supplied here. Note, only us-central1 is supported to-date.

  • transport (Union[AutoMlGrpcTransport, Callable[[Credentials, type], AutoMlGrpcTransport]) – A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.

  • channel (grpc.Channel) – DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

  • credentials (google.auth.credentials.Credentials) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

  • client_config (dict) – DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

  • client_options (Union[dict, google.api_core.client_options.ClientOptions]) – Client options used to set user options on the client. API Endpoint should be set through client_options.

batch_predict(pandas_dataframe=None, bigquery_input_uri=None, bigquery_output_uri=None, gcs_input_uris=None, gcs_output_uri_prefix=None, model=None, model_name=None, model_display_name=None, project=None, region=None, credentials=None, inputs=None, **kwargs)[source]#

Makes a batch prediction on a model. This does _not_ require the model to be deployed.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.batch_predict(
...     gcs_input_uris='gs://inputs/input.csv',
...     gcs_output_uri_prefix='gs://outputs/',
...     model_display_name='my_model'
...  ).result()
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment.

  • pandas_dataframe (Optional[pandas.DataFrame]) – A Pandas Dataframe object containing the data you want to predict off of. The data will be converted to CSV, and this CSV will be staged to GCS in gs://{project}-automl-tables-staging/{uploaded_csv_name} This must be supplied if neither gcs_input_uris nor bigquery_input_uri is supplied.

  • gcs_input_uris (Optional(Union[List[string], string])) – Either a list of or a single GCS URI containing the data you want to predict off of. This must be supplied if neither pandas_dataframe nor bigquery_input_uri is supplied.

  • gcs_output_uri_prefix (Optional[string]) – The folder in GCS you want to write output to. This must be supplied if bigquery_output_uri is not.

  • bigquery_input_uri (Optional[string]) – The BigQuery table to input data from. This must be supplied if neither pandas_dataframe nor gcs_input_uris is supplied.

  • bigquery_output_uri (Optional[string]) – The BigQuery table to output data to. This must be supplied if gcs_output_uri_prefix is not.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to predict with. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to predict with. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to predict with . This must be supplied if model_display_name or model_name are not supplied.

Returns

A _OperationFuture instance.

Raises
clear_test_train_column(dataset=None, dataset_display_name=None, dataset_name=None, project=None, region=None, **kwargs)[source]#

Clears the test/train (ml_use) column which designates which data belongs to the test and train sets.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.clear_test_train_column(dataset_display_name='my_dataset')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A Dataset instance.

Raises
clear_time_column(dataset=None, dataset_display_name=None, dataset_name=None, project=None, region=None, **kwargs)[source]#

Clears the time column which designates which data will be of type timestamp and will be used for the timeseries data.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.set_time_column(dataset_display_name='my_dataset')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A TableSpec instance.

Raises
clear_weight_column(dataset=None, dataset_display_name=None, dataset_name=None, project=None, region=None, **kwargs)[source]#

Clears the weight column for a given dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.clear_weight_column(dataset_display_name='my_dataset')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A Dataset instance.

Raises
create_dataset(dataset_display_name, metadata={}, project=None, region=None, **kwargs)[source]#

Create a dataset. Keep in mind, importing data is a separate step.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.create_dataset(dataset_display_name='my_dataset')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (string) – A human-readable name to refer to this dataset by.

Returns

A Dataset instance.

Raises
create_model(model_display_name, dataset=None, dataset_display_name=None, dataset_name=None, train_budget_milli_node_hours=None, optimization_objective=None, project=None, region=None, model_metadata={}, include_column_spec_names=None, exclude_column_spec_names=None, **kwargs)[source]#

Create a model. This will train your model on the given dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> m = client.create_model('my_model', dataset_display_name='my_dataset')
>>>
>>> m.result() # blocks on result
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_display_name (string) – A human-readable name to refer to this model by.

  • train_budget_milli_node_hours (int) – The amount of time (in thousandths of an hour) to spend training. This value must be between 1,000 and 72,000 inclusive (between 1 and 72 hours).

  • optimization_objective (string) – The metric AutoML tables should optimize for.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to train your model on. This must be supplied if dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to train your model on. This must be supplied if dataset_display_name or dataset are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to train your model on. This must be supplied if dataset_display_name or dataset_name are not supplied.

  • model_metadata (Optional[Dict]) – Optional model metadata to supply to the client.

  • include_column_spec_names (Optional[string]) – The list of the names of the columns you want to include to train your model on.

  • exclude_column_spec_names (Optional[string]) – The list of the names of the columns you want to exclude and not train your model on.

Returns

A _OperationFuture instance.

Raises
delete_dataset(dataset=None, dataset_display_name=None, dataset_name=None, project=None, region=None, **kwargs)[source]#

Deletes a dataset. This does not delete any models trained on this dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> op = client.delete_dataset(dataset_display_name='my_dataset')
>>>
>>> op.result() # blocks on delete request
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to delete. This must be supplied if dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to delete. This must be supplied if dataset_display_name or dataset are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to delete. This must be supplied if dataset_display_name or dataset_name are not supplied.

Returns

A _OperationFuture instance.

Raises
delete_model(model=None, model_display_name=None, model_name=None, project=None, region=None, **kwargs)[source]#

Deletes a model. Note this will not delete any datasets associated with this model.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> op = client.delete_model(model_display_name='my_model')
>>>
>>> op.result() # blocks on delete request
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to delete. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to delete. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to delete. This must be supplied if model_display_name or model_name are not supplied.

Returns

A _OperationFuture instance.

Raises
deploy_model(model=None, model_name=None, model_display_name=None, project=None, region=None, **kwargs)[source]#

Deploys a model. This allows you make online predictions using the model you’ve deployed.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> op = client.deploy_model(model_display_name='my_model')
>>>
>>> op.result() # blocks on deploy request
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to deploy. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to deploy. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to deploy. This must be supplied if model_display_name or model_name are not supplied.

Returns

A _OperationFuture instance.

Raises
export_data(dataset=None, dataset_display_name=None, dataset_name=None, gcs_output_uri_prefix=None, bigquery_output_uri=None, project=None, region=None, **kwargs)[source]#

Exports data from a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.create_dataset(dataset_display_name='my_dataset')
>>>
>>> client.export_data(dataset=d,
...     gcs_output_uri_prefix='gs://cloud-ml-tables-data/bank-marketing.csv')
...
>>> def callback(operation_future):
...    result = operation_future.result()
...
>>> response.add_done_callback(callback)
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to export data from. This must be supplied if dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to export data from. This must be supplied if dataset_display_name or dataset are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to export data from. This must be supplied if dataset_display_name or dataset_name are not supplied.

  • gcs_output_uri_prefix (Optional[Union[string, Sequence[string]]]) – A single gs://.. prefixed URI to export to. This must be supplied if bigquery_output_uri is not.

  • bigquery_output_uri (Optional[string]) – A URI pointing to the BigQuery table containing the data to export. This must be supplied if gcs_output_uri_prefix is not.

Returns

A _OperationFuture instance.

Raises
get_column_spec(column_spec_name, project=None, region=None, **kwargs)[source]#

Gets a single column spec in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.get_column_spec('my_column_spec')
>>>
Parameters
  • column_spec_name (string) – This is the fully-qualified name generated by the AutoML API for this column spec.

  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

Returns

A ColumnSpec instance.

Raises
get_dataset(project=None, region=None, dataset_name=None, dataset_display_name=None, **kwargs)[source]#

Gets a single dataset in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.get_dataset(dataset_display_name='my_dataset')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_name (Optional[string]) – This is the fully-qualified name generated by the AutoML API for this dataset. This is not to be confused with the human-assigned dataset_display_name that is provided when creating a dataset. Either dataset_name or dataset_display_name must be provided.

  • dataset_display_name (Optional[string]) – This is the name you provided for the dataset when first creating it. Either dataset_name or dataset_display_name must be provided.

Returns

A Dataset instance if found, None otherwise.

Raises
get_model(project=None, region=None, model_name=None, model_display_name=None, **kwargs)[source]#

Gets a single model in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.get_model(model_display_name='my_model')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_name (Optional[string]) – This is the fully-qualified name generated by the AutoML API for this model. This is not to be confused with the human-assigned model_display_name that is provided when creating a model. Either model_name or model_display_name must be provided.

  • model_display_name (Optional[string]) – This is the name you provided for the model when first creating it. Either model_name or model_display_name must be provided.

Returns

A Model instance.

Raises
get_model_evaluation(model_evaluation_name, project=None, region=None, **kwargs)[source]#

Gets a single evaluation model in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.get_model_evaluation('my_model_evaluation')
>>>
Parameters
  • model_evaluation_name (string) – This is the fully-qualified name generated by the AutoML API for this model evaluation.

  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

Returns

A ModelEvaluation instance.

Raises
get_table_spec(table_spec_name, project=None, region=None, **kwargs)[source]#

Gets a single table spec in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.get_table_spec('my_table_spec')
>>>
Parameters
  • table_spec_name (string) – This is the fully-qualified name generated by the AutoML API for this table spec.

  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

Returns

A TableSpec instance.

Raises
import_data(dataset=None, dataset_display_name=None, dataset_name=None, pandas_dataframe=None, gcs_input_uris=None, bigquery_input_uri=None, project=None, region=None, credentials=None, **kwargs)[source]#

Imports data into a dataset.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> d = client.create_dataset(dataset_display_name='my_dataset')
>>>
>>> client.import_data(dataset=d,
...     gcs_input_uris='gs://cloud-ml-tables-data/bank-marketing.csv')
...
>>> def callback(operation_future):
...    result = operation_future.result()
...
>>> response.add_done_callback(callback)
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to import data into. This must be supplied if dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to import data into. This must be supplied if dataset_display_name or dataset are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to import data into. This must be supplied if dataset_display_name or dataset_name are not supplied.

  • pandas_dataframe (Optional[pandas.DataFrame]) – A Pandas Dataframe object containing the data to import. The data will be converted to CSV, and this CSV will be staged to GCS in gs://{project}-automl-tables-staging/{uploaded_csv_name} This parameter must be supplied if neither gcs_input_uris nor bigquery_input_uri is supplied.

  • gcs_input_uris (Optional[Union[string, Sequence[string]]]) – Either a single gs://.. prefixed URI, or a list of URIs referring to GCS-hosted CSV files containing the data to import. This must be supplied if neither bigquery_input_uri nor pandas_dataframe is supplied.

  • bigquery_input_uri (Optional[string]) – A URI pointing to the BigQuery table containing the data to import. This must be supplied if neither gcs_input_uris nor pandas_dataframe is supplied.

Returns

A _OperationFuture instance.

Raises
list_column_specs(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, project=None, region=None, **kwargs)[source]#

Lists column specs.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> for s in client.list_column_specs(dataset_display_name='my_dataset')
...     # process the spec
...     pass
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose specs you want to read. If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name was provided, we use this index to determine which table to read column specs from.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to read specs from. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to read specs from. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to read specs from. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to read specs from. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to read specs from. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to read specs from. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A PageIterator instance. An iterable of ColumnSpec instances. You can also iterate over the pages of the response using its pages property.

Raises
list_datasets(project=None, region=None, **kwargs)[source]#

List all datasets in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> ds = client.list_datasets()
>>>
>>> for d in ds:
...     # do something
...     pass
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

Returns

A PageIterator instance. An iterable of Dataset instances. You can also iterate over the pages of the response using its pages property.

Raises
list_model_evaluations(project=None, region=None, model=None, model_display_name=None, model_name=None, **kwargs)[source]#

List all model evaluations for a given model.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> ms = client.list_model_evaluations(model_display_name='my_model')
>>>
>>> for m in ms:
...     # do something
...     pass
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to list evaluations for. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to list evaluations for. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to list evaluations for. This must be supplied if model_display_name or model_name are not supplied.

Returns

A PageIterator instance. An iterable of ModelEvaluation instances. You can also iterate over the pages of the response using its pages property.

Raises
list_models(project=None, region=None, **kwargs)[source]#

List all models in a particular project and region.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> ms = client.list_models()
>>>
>>> for m in ms:
...     # do something
...     pass
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

Returns

A PageIterator instance. An iterable of Model instances. You can also iterate over the pages of the response using its pages property.

Raises
list_table_specs(dataset=None, dataset_display_name=None, dataset_name=None, project=None, region=None, **kwargs)[source]#

Lists table specs.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> for s in client.list_table_specs(dataset_display_name='my_dataset')
...     # process the spec
...     pass
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to read specs from. This must be supplied if dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to read specs from. This must be supplied if dataset_display_name or dataset are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to read specs from. This must be supplied if dataset_display_name or dataset_name are not supplied.

Returns

A PageIterator instance. An iterable of TableSpec instances. You can also iterate over the pages of the response using its pages property.

Raises
predict(inputs, model=None, model_name=None, model_display_name=None, project=None, region=None, **kwargs)[source]#

Makes a prediction on a deployed model. This will fail if the model was not deployed.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.predict(inputs={'Age': 30, 'Income': 12, 'Category': 'A'}
...     model_display_name='my_model')
...
>>> client.predict([30, 12, 'A'], model_display_name='my_model')
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • inputs (Union[List[string], Dict[string, string]]) – Either the sorted list of column values to predict with, or a key-value map of column display name to value to predict with.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to predict with. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to predict with. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to predict with . This must be supplied if model_display_name or model_name are not supplied.

Returns

A PredictResponse instance.

Raises
set_target_column(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, column_spec_name=None, column_spec_display_name=None, project=None, region=None, **kwargs)[source]#

Sets the target column for a given table.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.set_target_column(dataset_display_name='my_dataset',
...     column_spec_display_name='Income')
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • column_spec_name (Optional[string]) – The name AutoML-assigned name for the column you want to set as the target column.

  • column_spec_display_name (Optional[string]) – The human-readable name of the column you want to set as the target column. If this is supplied in place of column_spec_name, you also need to provide either a way to lookup the source dataset (using one of the dataset* kwargs), or the table_spec_name of the table this column belongs to.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose target column you want to set . If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name or column_spec_name was provided, we use this index to determine which table to set the target column on.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the target column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the target column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the target column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the target column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the target column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the target column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A Dataset instance.

Raises
set_test_train_column(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, column_spec_name=None, column_spec_display_name=None, project=None, region=None, **kwargs)[source]#

Sets the test/train (ml_use) column which designates which data belongs to the test and train sets. This column must be categorical.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.set_test_train_column(dataset_display_name='my_dataset',
...     column_spec_display_name='TestSplit')
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • column_spec_name (Optional[string]) – The name AutoML-assigned name for the column you want to set as the test/train column.

  • column_spec_display_name (Optional[string]) – The human-readable name of the column you want to set as the test/train column. If this is supplied in place of column_spec_name, you also need to provide either a way to lookup the source dataset (using one of the dataset* kwargs), or the table_spec_name of the table this column belongs to.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose test/train column you want to set . If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name or column_spec_name was provided, we use this index to determine which table to set the test/train column on.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the test/train column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the test/train column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A Dataset instance.

Raises
set_time_column(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, column_spec_name=None, column_spec_display_name=None, project=None, region=None, **kwargs)[source]#

Sets the time column which designates which data will be of type timestamp and will be used for the timeseries data. This column must be of type timestamp.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.set_time_column(dataset_display_name='my_dataset',
...     column_spec_name='Unix Time')
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • column_spec_name (Optional[string]) – The name AutoML-assigned name for the column you want to set as the time column.

  • column_spec_display_name (Optional[string]) – The human-readable name of the column you want to set as the time column. If this is supplied in place of column_spec_name, you also need to provide either a way to lookup the source dataset (using one of the dataset* kwargs), or the table_spec_name of the table this column belongs to.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose time column you want to set . If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name or column_spec_name was provided, we use this index to determine which table to set the time column on.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the time column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the time column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A TableSpec instance.

Raises
set_weight_column(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, column_spec_name=None, column_spec_display_name=None, project=None, region=None, **kwargs)[source]#

Sets the weight column for a given table.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.set_weight_column(dataset_display_name='my_dataset',
...     column_spec_display_name='Income')
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • column_spec_name (Optional[string]) – The name AutoML-assigned name for the column you want to set as the weight column.

  • column_spec_display_name (Optional[string]) – The human-readable name of the column you want to set as the weight column. If this is supplied in place of column_spec_name, you also need to provide either a way to lookup the source dataset (using one of the dataset* kwargs), or the table_spec_name of the table this column belongs to.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose weight column you want to set . If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name or column_spec_name was provided, we use this index to determine which table to set the weight column on.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update the weight column of. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update the weight column of. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A Dataset instance.

Raises
undeploy_model(model=None, model_name=None, model_display_name=None, project=None, region=None, **kwargs)[source]#

Undeploys a model.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> op = client.undeploy_model(model_display_name='my_model')
>>>
>>> op.result() # blocks on undeploy request
>>>
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • model_display_name (Optional[string]) – The human-readable name given to the model you want to undeploy. This must be supplied if model or model_name are not supplied.

  • model_name (Optional[string]) – The AutoML-assigned name given to the model you want to undeploy. This must be supplied if model_display_name or model are not supplied.

  • model (Optional[model]) – The model instance you want to undeploy. This must be supplied if model_display_name or model_name are not supplied.

Returns

A _OperationFuture instance.

Raises
update_column_spec(dataset=None, dataset_display_name=None, dataset_name=None, table_spec_name=None, table_spec_index=0, column_spec_name=None, column_spec_display_name=None, type_code=None, nullable=None, project=None, region=None, **kwargs)[source]#

Updates a column’s specs.

Example

>>> from google.cloud import automl_v1beta1
>>>
>>> from google.oauth2 import service_account
>>>
>>> client = automl_v1beta1.TablesClient(
...     credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json')
...     project='my-project', region='us-central1')
...
>>> client.update_column_specs(dataset_display_name='my_dataset',
...     column_spec_display_name='Outcome', type_code='CATEGORY')
...
Parameters
  • project (Optional[string]) – If you have initialized the client with a value for project it will be used if this parameter is not supplied. Keep in mind, the service account this client was initialized with must have access to this project.

  • region (Optional[string]) – If you have initialized the client with a value for region it will be used if this parameter is not supplied.

  • column_spec_name (Optional[string]) – The name AutoML-assigned name for the column you want to update.

  • column_spec_display_name (Optional[string]) – The human-readable name of the column you want to update. If this is supplied in place of column_spec_name, you also need to provide either a way to lookup the source dataset (using one of the dataset* kwargs), or the table_spec_name of the table this column belongs to.

  • table_spec_name (Optional[string]) – The AutoML-assigned name for the table whose specs you want to update. If not supplied, the client can determine this name from a source Dataset object.

  • table_spec_index (Optional[int]) – If no table_spec_name was provided, we use this index to determine which table to update column specs on.

  • dataset_display_name (Optional[string]) – The human-readable name given to the dataset you want to update specs on. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update specs on. This must be supplied if table_spec_name, dataset or dataset_name are not supplied.

  • dataset_name (Optional[string]) – The AutoML-assigned name given to the dataset you want to update specs one. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update specs on. This must be supplied if table_spec_name, dataset or dataset_display_name are not supplied.

  • dataset (Optional[Dataset]) – The Dataset instance you want to update specs on. If no table_spec_name is supplied, this will be used together with table_spec_index to infer the name of table to update specs on. This must be supplied if table_spec_name, dataset_name or dataset_display_name are not supplied.

Returns

A ColumnSpec instance.

Raises
class google.cloud.automl_v1beta1.GcsClient(bucket_name=None, client=None, credentials=None)[source]#

Uploads Pandas DataFrame to a bucket in Google Cloud Storage.

Constructor.

Parameters
  • bucket_name (Optional[str]) – The name of Google Cloud Storage bucket for this client to send requests to.

  • client (Optional[storage.Client]) – A Google Cloud Storage Client instance.

  • credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment.

ensure_bucket_exists(project, region)[source]#

Checks if a bucket named ‘{project}-automl-tables-staging’ exists.

If this bucket doesn’t exist, creates one. If this bucket already exists in project, do nothing. If this bucket exists in a different project that we don’t have access to, creates a bucket named ‘{project}-automl-tables-staging-{create_timestamp}’ because bucket’s name must be globally unique. Save the created bucket’s name and reuse this for future requests.

Parameters
  • project (str) – The project that stores the bucket.

  • region (str) – The region of the bucket.

Returns

A string representing the created bucket name.

upload_pandas_dataframe(dataframe, uploaded_csv_name=None)[source]#

Uploads a Pandas DataFrame as CSV to the bucket.

Parameters
  • dataframe (pandas.DataFrame) – The Pandas Dataframe to be uploaded.

  • uploaded_csv_name (Optional[str]) – The name for the uploaded CSV.

Returns

A string representing the GCS URI of the uploaded CSV.