airflow.providers.google.cloud.hooks.vertex_ai.auto_ml

This module contains a Google Cloud Vertex AI hook.

Module Contents

Classes

AutoMLHook

Hook for Google Cloud Vertex AI Auto ML APIs.

class airflow.providers.google.cloud.hooks.vertex_ai.auto_ml.AutoMLHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Hook for Google Cloud Vertex AI Auto ML APIs.

get_pipeline_service_client(region=None)[source]

Return PipelineServiceClient.

get_job_service_client(region=None)[source]

Return JobServiceClient.

get_auto_ml_tabular_training_job(display_name, optimization_prediction_type, optimization_objective=None, column_specs=None, column_transformations=None, optimization_objective_recall_value=None, optimization_objective_precision_value=None, project=None, location=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None)[source]

Return AutoMLTabularTrainingJob object.

get_auto_ml_forecasting_training_job(display_name, optimization_objective=None, column_specs=None, column_transformations=None, project=None, location=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None)[source]

Return AutoMLForecastingTrainingJob object.

get_auto_ml_image_training_job(display_name, prediction_type='classification', multi_label=False, model_type='CLOUD', base_model=None, project=None, location=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None)[source]

Return AutoMLImageTrainingJob object.

get_auto_ml_text_training_job(display_name, prediction_type, multi_label=False, sentiment_max=10, project=None, location=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None)[source]

Return AutoMLTextTrainingJob object.

get_auto_ml_video_training_job(display_name, prediction_type='classification', model_type='CLOUD', project=None, location=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None)[source]

Return AutoMLVideoTrainingJob object.

static extract_model_id(obj)[source]

Return unique id of the Model.

static extract_training_id(resource_name)[source]

Return unique id of the Training pipeline.

wait_for_operation(operation, timeout=None)[source]

Wait for long-lasting operation to complete.

cancel_auto_ml_job()[source]

Cancel Auto ML Job for training pipeline.

create_auto_ml_tabular_training_job(project_id, region, display_name, dataset, target_column, optimization_prediction_type, optimization_objective=None, column_specs=None, column_transformations=None, optimization_objective_recall_value=None, optimization_objective_precision_value=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None, training_fraction_split=None, validation_fraction_split=None, test_fraction_split=None, predefined_split_column_name=None, timestamp_split_column_name=None, weight_column=None, budget_milli_node_hours=1000, model_display_name=None, model_labels=None, disable_early_stopping=False, export_evaluated_data_items=False, export_evaluated_data_items_bigquery_destination_uri=None, export_evaluated_data_items_override_destination=False, sync=True, parent_model=None, is_default_version=None, model_version_aliases=None, model_version_description=None)[source]

Create an AutoML Tabular Training Job.

Parameters
  • project_id (str) – Required. Project to run training in.

  • region (str) – Required. Location to run training in.

  • display_name (str) – Required. The user-defined name of this TrainingPipeline.

  • dataset (google.cloud.aiplatform.datasets.TabularDataset) – Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline’s [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. For tabular Datasets, all their data is exported to training, to pick and choose from.

  • target_column (str) – Required. The name of the column values of which the Model is to predict.

  • parent_model (str | None) – Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

  • is_default_version (bool | None) – Optional. When set to True, the newly uploaded model version will automatically have alias “default” included. Subsequent uses of the model produced by this job without a version specified will use this “default” version. When set to False, the “default” alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be “default” aliased.

  • model_version_aliases (list[str] | None) – Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

  • model_version_description (str | None) – Optional. The description of the model version being uploaded by this job.

  • optimization_prediction_type (str) – The type of prediction the Model is to produce. “classification” - Predict one out of multiple target values is picked for each row. “regression” - Predict a value based on its relation to other values. This type is available only to columns that contain semantically numeric values, i.e. integers or floating point number, even if stored as e.g. strings.

  • optimization_objective (str | None) –

    Optional. Objective function the Model is to be optimized towards. The training task creates a Model that maximizes/minimizes the value of the objective function over the validation set.

    The supported optimization objectives depend on the prediction type, and in the case of classification also the number of distinct values in the target column (two distinct values -> binary, 3 or more distinct values -> multi class). If the field is not set, the default objective function is used.

    Classification (binary): “maximize-au-roc” (default) - Maximize the area under the receiver operating characteristic (ROC) curve. “minimize-log-loss” - Minimize log loss. “maximize-au-prc” - Maximize the area under the precision-recall curve. “maximize-precision-at-recall” - Maximize precision for a specified recall value. “maximize-recall-at-precision” - Maximize recall for a specified precision value.

    Classification (multi class): “minimize-log-loss” (default) - Minimize log loss.

    Regression: “minimize-rmse” (default) - Minimize root-mean-squared error (RMSE). “minimize-mae” - Minimize mean-absolute error (MAE). “minimize-rmsle” - Minimize root-mean-squared log error (RMSLE).

  • column_specs (dict[str, str] | None) – Optional. Alternative to column_transformations where the keys of the dict are column names and their respective values are one of AutoMLTabularTrainingJob.column_data_types. When creating transformation for BigQuery Struct column, the column should be flattened using “.” as the delimiter. Only columns with no child should have a transformation. If an input column has no transformations on it, such a column is ignored by the training, except for the targetColumn, which should have no transformations defined on. Only one of column_transformations or column_specs should be passed.

  • column_transformations (list[dict[str, dict[str, str]]] | None) – Optional. Transformations to apply to the input columns (i.e. columns other than the targetColumn). Each transformation may produce multiple result values from the column’s value, and all are used for training. When creating transformation for BigQuery Struct column, the column should be flattened using “.” as the delimiter. Only columns with no child should have a transformation. If an input column has no transformations on it, such a column is ignored by the training, except for the targetColumn, which should have no transformations defined on. Only one of column_transformations or column_specs should be passed. Consider using column_specs as column_transformations will be deprecated eventually.

  • optimization_objective_recall_value (float | None) – Optional. Required when maximize-precision-at-recall optimizationObjective was picked, represents the recall value at which the optimization is done. The minimum value is 0 and the maximum is 1.0.

  • optimization_objective_precision_value (float | None) – Optional. Required when maximize-recall-at-precision optimizationObjective was picked, represents the precision value at which the optimization is done. The minimum value is 0 and the maximum is 1.0.

  • labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • training_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately.

  • model_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key.

  • training_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

  • validation_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to validate the Model. This is ignored if Dataset is not provided.

  • test_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

  • predefined_split_column_name (str | None) – Optional. The key is a name of one of the Dataset’s data columns. The value of the key (either the label’s value or value in the column) must be one of {training, validation, test}, and it defines to which set the given piece of data is assigned. If for a piece of data the key is not present or has an invalid value, that piece is ignored by the pipeline. Supported only for tabular and time series Datasets.

  • timestamp_split_column_name (str | None) – Optional. The key is a name of one of the Dataset’s data columns. The value of the key values of the key (the values in the column) must be in RFC 3339 date-time format, where time-offset = “Z” (e.g. 1985-04-12T23:20:50.52Z). If for a piece of data the key is not present or has an invalid value, that piece is ignored by the pipeline. Supported only for tabular and time series Datasets. This parameter must be used with training_fraction_split, validation_fraction_split and test_fraction_split.

  • weight_column (str | None) – Optional. Name of the column that should be used as the weight column. Higher values in this column give more importance to the row during Model training. The column must have numeric values between 0 and 10000 inclusively, and 0 value means that the row is ignored. If the weight column field is not set, then all rows are assumed to have equal weight of 1.

  • (int) (budget_milli_node_hours) – Optional. The train budget of creating this Model, expressed in milli node hours i.e. 1,000 value in this field means 1 node hour. The training cost of the model will not exceed this budget. The final cost will be attempted to be close to the budget, though may end up being (even) noticeably smaller - at the backend’s discretion. This especially may happen when further model training ceases to provide any improvements. If the budget is set to a value known to be insufficient to train a Model for the given training set, the training won’t be attempted and will error. The minimum value is 1000 and the maximum is 72000.

  • model_display_name (str | None) – Optional. If the script produces a managed Vertex AI Model. The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. If not provided upon creation, the job’s display_name is used.

  • model_labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • disable_early_stopping (bool) – Required. If true, the entire budget is used. This disables the early stopping feature. By default, the early stopping feature is enabled, which means that training might stop before the entire training budget has been used, if further training does no longer brings significant improvement to the model.

  • export_evaluated_data_items (bool) – Whether to export the test set predictions to a BigQuery table. If False, then the export is not performed.

  • export_evaluated_data_items_bigquery_destination_uri (str | None) –

    Optional. URI of desired destination BigQuery table for exported test set predictions.

    Expected format: bq://<project_id>:<dataset_id>:<table>

    If not specified, then results are exported to the following auto-created BigQuery table: <project_id>:export_evaluated_examples_<model_name>_<yyyy_MM_dd'T'HH_mm_ss_SSS'Z'> .evaluated_examples

    Applies only if [export_evaluated_data_items] is True.

  • export_evaluated_data_items_override_destination (bool) – Whether to override the contents of [export_evaluated_data_items_bigquery_destination_uri], if the table exists, for exported test set predictions. If False, and the table exists, then the training job will fail. Applies only if [export_evaluated_data_items] is True and [export_evaluated_data_items_bigquery_destination_uri] is specified.

  • sync (bool) – Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_auto_ml_forecasting_training_job(project_id, region, display_name, dataset, target_column, time_column, time_series_identifier_column, unavailable_at_forecast_columns, available_at_forecast_columns, forecast_horizon, data_granularity_unit, data_granularity_count, optimization_objective=None, column_specs=None, column_transformations=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None, training_fraction_split=None, validation_fraction_split=None, test_fraction_split=None, predefined_split_column_name=None, weight_column=None, time_series_attribute_columns=None, context_window=None, export_evaluated_data_items=False, export_evaluated_data_items_bigquery_destination_uri=None, export_evaluated_data_items_override_destination=False, quantiles=None, validation_options=None, budget_milli_node_hours=1000, model_display_name=None, model_labels=None, sync=True, parent_model=None, is_default_version=None, model_version_aliases=None, model_version_description=None)[source]

Create an AutoML Forecasting Training Job.

Parameters
  • project_id (str) – Required. Project to run training in.

  • region (str) – Required. Location to run training in.

  • display_name (str) – Required. The user-defined name of this TrainingPipeline.

  • dataset (google.cloud.aiplatform.datasets.TimeSeriesDataset) – Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline’s [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. For time series Datasets, all their data is exported to training, to pick and choose from.

  • target_column (str) – Required. Name of the column that the Model is to predict values for.

  • time_column (str) – Required. Name of the column that identifies time order in the time series.

  • parent_model (str | None) – Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

  • is_default_version (bool | None) – Optional. When set to True, the newly uploaded model version will automatically have alias “default” included. Subsequent uses of the model produced by this job without a version specified will use this “default” version. When set to False, the “default” alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be “default” aliased.

  • model_version_aliases (list[str] | None) – Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

  • model_version_description (str | None) – Optional. The description of the model version being uploaded by this job.

  • time_series_identifier_column (str) – Required. Name of the column that identifies the time series.

  • unavailable_at_forecast_columns (list[str]) – Required. Column names of columns that are unavailable at forecast. Each column contains information for the given entity (identified by the [time_series_identifier_column]) that is unknown before the forecast (e.g. population of a city in a given year, or weather on a given day).

  • available_at_forecast_columns (list[str]) – Required. Column names of columns that are available at forecast. Each column contains information for the given entity (identified by the [time_series_identifier_column]) that is known at forecast.

  • forecast_horizon (int) – Required. The amount of time into the future for which forecasted values for the target are returned. Expressed in number of units defined by the [data_granularity_unit] and [data_granularity_count] field. Inclusive.

  • data_granularity_unit (str) – Required. The data granularity unit. Accepted values are minute, hour, day, week, month, year.

  • data_granularity_count (int) – Required. The number of data granularity units between data points in the training data. If [data_granularity_unit] is minute, can be 1, 5, 10, 15, or 30. For all other values of [data_granularity_unit], must be 1.

  • optimization_objective (str | None) – Optional. Objective function the model is to be optimized towards. The training process creates a Model that optimizes the value of the objective function over the validation set. The supported optimization objectives: “minimize-rmse” (default) - Minimize root-mean-squared error (RMSE). “minimize-mae” - Minimize mean-absolute error (MAE). “minimize-rmsle” - Minimize root-mean-squared log error (RMSLE). “minimize-rmspe” - Minimize root-mean-squared percentage error (RMSPE). “minimize-wape-mae” - Minimize the combination of weighted absolute percentage error (WAPE) and mean-absolute-error (MAE). “minimize-quantile-loss” - Minimize the quantile loss at the defined quantiles. (Set this objective to build quantile forecasts.)

  • column_specs (dict[str, str] | None) – Optional. Alternative to column_transformations where the keys of the dict are column names and their respective values are one of AutoMLTabularTrainingJob.column_data_types. When creating transformation for BigQuery Struct column, the column should be flattened using “.” as the delimiter. Only columns with no child should have a transformation. If an input column has no transformations on it, such a column is ignored by the training, except for the targetColumn, which should have no transformations defined on. Only one of column_transformations or column_specs should be passed.

  • column_transformations (list[dict[str, dict[str, str]]] | None) – Optional. Transformations to apply to the input columns (i.e. columns other than the targetColumn). Each transformation may produce multiple result values from the column’s value, and all are used for training. When creating transformation for BigQuery Struct column, the column should be flattened using “.” as the delimiter. Only columns with no child should have a transformation. If an input column has no transformations on it, such a column is ignored by the training, except for the targetColumn, which should have no transformations defined on. Only one of column_transformations or column_specs should be passed. Consider using column_specs as column_transformations will be deprecated eventually.

  • labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • training_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately.

  • model_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key.

  • training_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

  • validation_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to validate the Model. This is ignored if Dataset is not provided.

  • test_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

  • predefined_split_column_name (str | None) – Optional. The key is a name of one of the Dataset’s data columns. The value of the key (either the label’s value or value in the column) must be one of {TRAIN, VALIDATE, TEST}, and it defines to which set the given piece of data is assigned. If for a piece of data the key is not present or has an invalid value, that piece is ignored by the pipeline. Supported only for tabular and time series Datasets.

  • weight_column (str | None) – Optional. Name of the column that should be used as the weight column. Higher values in this column give more importance to the row during Model training. The column must have numeric values between 0 and 10000 inclusively, and 0 value means that the row is ignored. If the weight column field is not set, then all rows are assumed to have equal weight of 1.

  • time_series_attribute_columns (list[str] | None) – Optional. Column names that should be used as attribute columns. Each column is constant within a time series.

  • context_window (int | None) – Optional. The amount of time into the past training and prediction data is used for model training and prediction respectively. Expressed in number of units defined by the [data_granularity_unit] and [data_granularity_count] fields. When not provided uses the default value of 0 which means the model sets each series context window to be 0 (also known as “cold start”). Inclusive.

  • export_evaluated_data_items (bool) – Whether to export the test set predictions to a BigQuery table. If False, then the export is not performed.

  • export_evaluated_data_items_bigquery_destination_uri (str | None) – Optional. URI of desired destination BigQuery table for exported test set predictions. Expected format: bq://<project_id>:<dataset_id>:<table> If not specified, then results are exported to the following auto-created BigQuery table: <project_id>:export_evaluated_examples_<model_name>_<yyyy_MM_dd'T'HH_mm_ss_SSS'Z'> .evaluated_examples Applies only if [export_evaluated_data_items] is True.

  • export_evaluated_data_items_override_destination (bool) – Whether to override the contents of [export_evaluated_data_items_bigquery_destination_uri], if the table exists, for exported test set predictions. If False, and the table exists, then the training job will fail. Applies only if [export_evaluated_data_items] is True and [export_evaluated_data_items_bigquery_destination_uri] is specified.

  • quantiles (list[float] | None) – Quantiles to use for the minizmize-quantile-loss [AutoMLForecastingTrainingJob.optimization_objective]. This argument is required in this case. Accepts up to 5 quantiles in the form of a double from 0 to 1, exclusive. Each quantile must be unique.

  • validation_options (str | None) – Validation options for the data validation component. The available options are: “fail-pipeline” - (default), will validate against the validation and fail the pipeline if it fails. “ignore-validation” - ignore the results of the validation and continue the pipeline

  • budget_milli_node_hours (int) – Optional. The train budget of creating this Model, expressed in milli node hours i.e. 1,000 value in this field means 1 node hour. The training cost of the model will not exceed this budget. The final cost will be attempted to be close to the budget, though may end up being (even) noticeably smaller - at the backend’s discretion. This especially may happen when further model training ceases to provide any improvements. If the budget is set to a value known to be insufficient to train a Model for the given training set, the training won’t be attempted and will error. The minimum value is 1000 and the maximum is 72000.

  • model_display_name (str | None) – Optional. If the script produces a managed Vertex AI Model. The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. If not provided upon creation, the job’s display_name is used.

  • model_labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • sync (bool) – Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_auto_ml_image_training_job(project_id, region, display_name, dataset, prediction_type='classification', multi_label=False, model_type='CLOUD', base_model=None, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None, training_fraction_split=None, validation_fraction_split=None, test_fraction_split=None, training_filter_split=None, validation_filter_split=None, test_filter_split=None, budget_milli_node_hours=None, model_display_name=None, model_labels=None, disable_early_stopping=False, sync=True, parent_model=None, is_default_version=None, model_version_aliases=None, model_version_description=None)[source]

Create an AutoML Image Training Job.

Parameters
  • project_id (str) – Required. Project to run training in.

  • region (str) – Required. Location to run training in.

  • display_name (str) – Required. The user-defined name of this TrainingPipeline.

  • dataset (google.cloud.aiplatform.datasets.ImageDataset) – Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline’s [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. For tabular Datasets, all their data is exported to training, to pick and choose from.

  • prediction_type (str) – The type of prediction the Model is to produce, one of: “classification” - Predict one out of multiple target values is picked for each row. “object_detection” - Predict a value based on its relation to other values. This type is available only to columns that contain semantically numeric values, i.e. integers or floating point number, even if stored as e.g. strings.

  • parent_model (str | None) – Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

  • is_default_version (bool | None) – Optional. When set to True, the newly uploaded model version will automatically have alias “default” included. Subsequent uses of the model produced by this job without a version specified will use this “default” version. When set to False, the “default” alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be “default” aliased.

  • model_version_aliases (list[str] | None) – Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

  • model_version_description (str | None) – Optional. The description of the model version being uploaded by this job.

  • multi_label (bool) – Required. Default is False. If false, a single-label (multi-class) Model will be trained (i.e. assuming that for each image just up to one annotation may be applicable). If true, a multi-label Model will be trained (i.e. assuming that for each image multiple annotations may be applicable). This is only applicable for the “classification” prediction_type and will be ignored otherwise.

  • model_type (str) – Required. One of the following: “CLOUD” - Default for Image Classification. A Model best tailored to be used within Google Cloud, and which cannot be exported. “CLOUD_HIGH_ACCURACY_1” - Default for Image Object Detection. A model best tailored to be used within Google Cloud, and which cannot be exported. Expected to have a higher latency, but should also have a higher prediction quality than other cloud models. “CLOUD_LOW_LATENCY_1” - A model best tailored to be used within Google Cloud, and which cannot be exported. Expected to have a low latency, but may have lower prediction quality than other cloud models. “MOBILE_TF_LOW_LATENCY_1” - A model that, in addition to being available within Google Cloud, can also be exported as TensorFlow or Core ML model and used on a mobile or edge device afterwards. Expected to have low latency, but may have lower prediction quality than other mobile models. “MOBILE_TF_VERSATILE_1” - A model that, in addition to being available within Google Cloud, can also be exported as TensorFlow or Core ML model and used on a mobile or edge device with afterwards. “MOBILE_TF_HIGH_ACCURACY_1” - A model that, in addition to being available within Google Cloud, can also be exported as TensorFlow or Core ML model and used on a mobile or edge device afterwards. Expected to have a higher latency, but should also have a higher prediction quality than other mobile models.

  • base_model (google.cloud.aiplatform.models.Model | None) – Optional. Only permitted for Image Classification models. If it is specified, the new model will be trained based on the base model. Otherwise, the new model will be trained from scratch. The base model must be in the same Project and Location as the new Model to train, and have the same model_type.

  • labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • training_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately.

  • model_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key.

  • training_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

  • validation_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to validate the Model. This is ignored if Dataset is not provided.

  • test_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

  • training_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to train the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • validation_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to validate the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • test_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to test the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • budget_milli_node_hours (int | None) – Optional. The train budget of creating this Model, expressed in milli node hours i.e. 1,000 value in this field means 1 node hour. Defaults by prediction_type: classification - For Cloud models the budget must be: 8,000 - 800,000 milli node hours (inclusive). The default value is 192,000 which represents one day in wall time, assuming 8 nodes are used. object_detection - For Cloud models the budget must be: 20,000 - 900,000 milli node hours (inclusive). The default value is 216,000 which represents one day in wall time, assuming 9 nodes are used. The training cost of the model will not exceed this budget. The final cost will be attempted to be close to the budget, though may end up being (even) noticeably smaller - at the backend’s discretion. This especially may happen when further model training ceases to provide any improvements. If the budget is set to a value known to be insufficient to train a Model for the given training set, the training won’t be attempted and will error.

  • model_display_name (str | None) – Optional. The display name of the managed Vertex AI Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. If not provided upon creation, the job’s display_name is used.

  • model_labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • disable_early_stopping (bool) – Required. If true, the entire budget is used. This disables the early stopping feature. By default, the early stopping feature is enabled, which means that training might stop before the entire training budget has been used, if further training does no longer brings significant improvement to the model.

  • sync (bool) – Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_auto_ml_text_training_job(project_id, region, display_name, dataset, prediction_type, multi_label=False, sentiment_max=10, labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None, training_fraction_split=None, validation_fraction_split=None, test_fraction_split=None, training_filter_split=None, validation_filter_split=None, test_filter_split=None, model_display_name=None, model_labels=None, sync=True, parent_model=None, is_default_version=None, model_version_aliases=None, model_version_description=None)[source]

Create an AutoML Text Training Job.

Parameters
  • project_id (str) – Required. Project to run training in.

  • region (str) – Required. Location to run training in.

  • display_name (str) – Required. The user-defined name of this TrainingPipeline.

  • dataset (google.cloud.aiplatform.datasets.TextDataset) – Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline’s [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition].

  • prediction_type (str) – The type of prediction the Model is to produce, one of: “classification” - A classification model analyzes text data and returns a list of categories that apply to the text found in the data. Vertex AI offers both single-label and multi-label text classification models. “extraction” - An entity extraction model inspects text data for known entities referenced in the data and labels those entities in the text. “sentiment” - A sentiment analysis model inspects text data and identifies the prevailing emotional opinion within it, especially to determine a writer’s attitude as positive, negative, or neutral.

  • parent_model (str | None) – Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

  • is_default_version (bool | None) – Optional. When set to True, the newly uploaded model version will automatically have alias “default” included. Subsequent uses of the model produced by this job without a version specified will use this “default” version. When set to False, the “default” alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be “default” aliased.

  • model_version_aliases (list[str] | None) – Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

  • model_version_description (str | None) – Optional. The description of the model version being uploaded by this job.

  • multi_label (bool) – Required and only applicable for text classification task. If false, a single-label (multi-class) Model will be trained (i.e. assuming that for each text snippet just up to one annotation may be applicable). If true, a multi-label Model will be trained (i.e. assuming that for each text snippet multiple annotations may be applicable).

  • sentiment_max (int) – Required and only applicable for sentiment task. A sentiment is expressed as an integer ordinal, where higher value means a more positive sentiment. The range of sentiments that will be used is between 0 and sentimentMax (inclusive on both ends), and all the values in the range must be represented in the dataset before a model can be created. Only the Annotations with this sentimentMax will be used for training. sentimentMax value must be between 1 and 10 (inclusive).

  • labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • training_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately.

  • model_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key.

  • training_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

  • validation_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to validate the Model. This is ignored if Dataset is not provided.

  • test_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

  • training_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to train the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • validation_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to validate the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • test_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to test the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • model_display_name (str | None) – Optional. The display name of the managed Vertex AI Model. The name can be up to 128 characters long and can consist of any UTF-8 characters. If not provided upon creation, the job’s display_name is used.

  • model_labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • sync (bool) – Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_auto_ml_video_training_job(project_id, region, display_name, dataset, prediction_type='classification', model_type='CLOUD', labels=None, training_encryption_spec_key_name=None, model_encryption_spec_key_name=None, training_fraction_split=None, test_fraction_split=None, training_filter_split=None, test_filter_split=None, model_display_name=None, model_labels=None, sync=True, parent_model=None, is_default_version=None, model_version_aliases=None, model_version_description=None)[source]

Create an AutoML Video Training Job.

Parameters
  • project_id (str) – Required. Project to run training in.

  • region (str) – Required. Location to run training in.

  • display_name (str) – Required. The user-defined name of this TrainingPipeline.

  • dataset (google.cloud.aiplatform.datasets.VideoDataset) – Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline’s [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. For tabular Datasets, all their data is exported to training, to pick and choose from.

  • prediction_type (str) – The type of prediction the Model is to produce, one of: “classification” - A video classification model classifies shots and segments in your videos according to your own defined labels. “object_tracking” - A video object tracking model detects and tracks multiple objects in shots and segments. You can use these models to track objects in your videos according to your own pre-defined, custom labels. “action_recognition” - A video action recognition model pinpoints the location of actions with short temporal durations (~1 second).

  • parent_model (str | None) – Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

  • is_default_version (bool | None) – Optional. When set to True, the newly uploaded model version will automatically have alias “default” included. Subsequent uses of the model produced by this job without a version specified will use this “default” version. When set to False, the “default” alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be “default” aliased.

  • model_version_aliases (list[str] | None) – Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

  • model_version_description (str | None) – Optional. The description of the model version being uploaded by this job.

  • model_type (str) – Required. One of the following: “CLOUD” - available for “classification”, “object_tracking” and “action_recognition” A Model best tailored to be used within Google Cloud, and which cannot be exported. “MOBILE_VERSATILE_1” - available for “classification”, “object_tracking” and “action_recognition” A model that, in addition to being available within Google Cloud, can also be exported (see ModelService.ExportModel) as a TensorFlow or TensorFlow Lite model and used on a mobile or edge device with afterwards. “MOBILE_CORAL_VERSATILE_1” - available only for “object_tracking” A versatile model that is meant to be exported (see ModelService.ExportModel) and used on a Google Coral device. “MOBILE_CORAL_LOW_LATENCY_1” - available only for “object_tracking” A model that trades off quality for low latency, to be exported (see ModelService.ExportModel) and used on a Google Coral device. “MOBILE_JETSON_VERSATILE_1” - available only for “object_tracking” A versatile model that is meant to be exported (see ModelService.ExportModel) and used on an NVIDIA Jetson device. “MOBILE_JETSON_LOW_LATENCY_1” - available only for “object_tracking” A model that trades off quality for low latency, to be exported (see ModelService.ExportModel) and used on an NVIDIA Jetson device.

  • labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • training_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately.

  • model_encryption_spec_key_name (str | None) – Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key.

  • training_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

  • test_fraction_split (float | None) – Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

  • training_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to train the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • test_filter_split (str | None) – Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to test the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

  • model_display_name (str | None) – Optional. The display name of the managed Vertex AI Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. If not provided upon creation, the job’s display_name is used.

  • model_labels (dict[str, str] | None) – Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

  • sync (bool) – Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

delete_training_pipeline(project_id, region, training_pipeline, retry=DEFAULT, timeout=None, metadata=())[source]

Delete a TrainingPipeline.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • training_pipeline (str) – Required. The name of the TrainingPipeline resource to be deleted.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

get_training_pipeline(project_id, region, training_pipeline, retry=DEFAULT, timeout=None, metadata=())[source]

Get a TrainingPipeline.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • training_pipeline (str) – Required. The name of the TrainingPipeline resource.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

list_training_pipelines(project_id, region, page_size=None, page_token=None, filter=None, read_mask=None, retry=DEFAULT, timeout=None, metadata=())[source]

List TrainingPipelines in a Location.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • filter (str | None) –

    Optional. The standard list filter. Supported fields:

    • display_name supports = and !=.

    • state supports = and !=.

    Some examples of using the filter are:

    • state="PIPELINE_STATE_SUCCEEDED" AND display_name="my_pipeline"

    • state="PIPELINE_STATE_RUNNING" OR display_name="my_pipeline"

    • NOT display_name="my_pipeline"

    • state="PIPELINE_STATE_FAILED"

  • page_size (int | None) – Optional. The standard list page size.

  • page_token (str | None) – Optional. The standard list page token. Typically obtained via [ListTrainingPipelinesResponse.next_page_token][google.cloud.aiplatform.v1.ListTrainingPipelinesResponse.next_page_token] of the previous [PipelineService.ListTrainingPipelines][google.cloud.aiplatform.v1.PipelineService.ListTrainingPipelines] call.

  • read_mask (str | None) – Optional. Mask specifying which fields to read.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Was this entry helpful?