Class SequenceToSequencePlusForecastingTrainingJob (1.30.0)

SequenceToSequencePlusForecastingTrainingJob(
    display_name: typing.Optional[str] = None,
    optimization_objective: typing.Optional[str] = None,
    column_specs: typing.Optional[typing.Dict[str, str]] = None,
    column_transformations: typing.Optional[
        typing.List[typing.Dict[str, typing.Dict[str, str]]]
    ] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    training_encryption_spec_key_name: typing.Optional[str] = None,
    model_encryption_spec_key_name: typing.Optional[str] = None,
)

Class to train Sequence to Sequence (Seq2Seq) forecasting models.

Properties

create_time

Time this resource was created.

display_name

Display name of this resource.

encryption_spec

Customer-managed encryption key options for this Vertex AI resource.

If this is set, then all resources created by this Vertex AI resource will be encrypted with the provided encryption key.

end_time

Time when the TrainingJob resource entered the PIPELINE_STATE_SUCCEEDED, PIPELINE_STATE_FAILED, PIPELINE_STATE_CANCELLED state.

error

Detailed error info for this TrainingJob resource. Only populated when the TrainingJob's state is PIPELINE_STATE_FAILED or PIPELINE_STATE_CANCELLED.

evaluated_data_items_bigquery_uri

BigQuery location of exported evaluated examples from the Training Job

Returns
TypeDescription
strBigQuery uri for the exported evaluated examples if the export feature is enabled for training. None: If the export feature was not enabled for training.

gca_resource

The underlying resource proto representation.

has_failed

Returns True if training has failed.

False otherwise.

labels

User-defined labels containing metadata about this resource.

Read more about labels at https://goo.gl/xmQnxf

name

Name of this resource.

resource_name

Full qualified resource name.

start_time

Time when the TrainingJob entered the PIPELINE_STATE_RUNNING for the first time.

state

Current training state.

update_time

Time this resource was last updated.

Methods

SequenceToSequencePlusForecastingTrainingJob

SequenceToSequencePlusForecastingTrainingJob(
    display_name: typing.Optional[str] = None,
    optimization_objective: typing.Optional[str] = None,
    column_specs: typing.Optional[typing.Dict[str, str]] = None,
    column_transformations: typing.Optional[
        typing.List[typing.Dict[str, typing.Dict[str, str]]]
    ] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    training_encryption_spec_key_name: typing.Optional[str] = None,
    model_encryption_spec_key_name: typing.Optional[str] = None,
)

Constructs a Forecasting Training Job.

Parameters
NameDescription
display_name str

Optional. The user-defined name of this TrainingPipeline.

optimization_objective str

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]

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]]]

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.

project str

Optional. Project to run training in. Overrides project set in aiplatform.init.

location str

Optional. Location to run training in. Overrides location set in aiplatform.init.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to run call training service. Overrides credentials set in aiplatform.init.

labels Dict[str, str]

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 Optional[str]

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. Overrides encryption_spec_key_name set in aiplatform.init.

model_encryption_spec_key_name Optional[str]

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. Overrides encryption_spec_key_name set in aiplatform.init.

Exceptions
TypeDescription
ValueErrorIf both column_transformations and column_specs were provided.

cancel

cancel() -> None

Starts asynchronous cancellation on the TrainingJob. The server makes a best effort to cancel the job, but success is not guaranteed. On successful cancellation, the TrainingJob is not deleted; instead it becomes a job with state set to CANCELLED.

Exceptions
TypeDescription
RuntimeErrorIf this TrainingJob has not started running.

delete

delete(sync: bool = True) -> None

Deletes this Vertex AI resource. WARNING: This deletion is permanent.

Parameter
NameDescription
sync bool

Whether to execute this deletion 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.

done

done() -> bool

Method indicating whether a job has completed.

get

get(
    resource_name: str,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
) -> google.cloud.aiplatform.training_jobs._TrainingJob

Get Training Job for the given resource_name.

Parameters
NameDescription
resource_name str

Required. A fully-qualified resource name or ID.

project str

Optional project to retrieve training job from. If not set, project set in aiplatform.init will be used.

location str

Optional location to retrieve training job from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Custom credentials to use to upload this model. Overrides credentials set in aiplatform.init.

Exceptions
TypeDescription
ValueErrorIf the retrieved training job's training task definition doesn't match the custom training task definition.

get_model

get_model(sync=True) -> google.cloud.aiplatform.models.Model

Vertex AI Model produced by this training, if one was produced.

Parameter
NameDescription
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.

Exceptions
TypeDescription
RuntimeErrorIf training failed or if a model was not produced by this training.
Returns
TypeDescription
modelVertex AI Model produced by this training

list

list(
    filter: typing.Optional[str] = None,
    order_by: typing.Optional[str] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
) -> typing.List[google.cloud.aiplatform.base.VertexAiResourceNoun]

List all instances of this TrainingJob resource.

Example Usage:

aiplatform.CustomTrainingJob.list( filter='display_name="experiment_a27"', order_by='create_time desc' )

Parameters
NameDescription
filter str

Optional. An expression for filtering the results of the request. For field names both snake_case and camelCase are supported.

order_by str

Optional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: display_name, create_time, update_time

project str

Optional. Project to retrieve list from. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to retrieve list from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to retrieve list. Overrides credentials set in aiplatform.init.

run

run(
    dataset: google.cloud.aiplatform.datasets.time_series_dataset.TimeSeriesDataset,
    target_column: str,
    time_column: str,
    time_series_identifier_column: str,
    unavailable_at_forecast_columns: typing.List[str],
    available_at_forecast_columns: typing.List[str],
    forecast_horizon: int,
    data_granularity_unit: str,
    data_granularity_count: int,
    training_fraction_split: typing.Optional[float] = None,
    validation_fraction_split: typing.Optional[float] = None,
    test_fraction_split: typing.Optional[float] = None,
    predefined_split_column_name: typing.Optional[str] = None,
    timestamp_split_column_name: typing.Optional[str] = None,
    weight_column: typing.Optional[str] = None,
    time_series_attribute_columns: typing.Optional[typing.List[str]] = None,
    context_window: typing.Optional[int] = None,
    export_evaluated_data_items: bool = False,
    export_evaluated_data_items_bigquery_destination_uri: typing.Optional[str] = None,
    export_evaluated_data_items_override_destination: bool = False,
    quantiles: typing.Optional[typing.List[float]] = None,
    validation_options: typing.Optional[str] = None,
    budget_milli_node_hours: int = 1000,
    model_display_name: typing.Optional[str] = None,
    model_labels: typing.Optional[typing.Dict[str, str]] = None,
    model_id: typing.Optional[str] = None,
    parent_model: typing.Optional[str] = None,
    is_default_version: typing.Optional[bool] = True,
    model_version_aliases: typing.Optional[typing.Sequence[str]] = None,
    model_version_description: typing.Optional[str] = None,
    additional_experiments: typing.Optional[typing.List[str]] = None,
    hierarchy_group_columns: typing.Optional[typing.List[str]] = None,
    hierarchy_group_total_weight: typing.Optional[float] = None,
    hierarchy_temporal_total_weight: typing.Optional[float] = None,
    hierarchy_group_temporal_total_weight: typing.Optional[float] = None,
    window_column: typing.Optional[str] = None,
    window_stride_length: typing.Optional[int] = None,
    window_max_count: typing.Optional[int] = None,
    holiday_regions: typing.Optional[typing.List[str]] = None,
    sync: bool = True,
    create_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.models.Model

Runs the training job and returns a model.

If training on a Vertex AI dataset, you can use one of the following split configurations: Data fraction splits: Any of training_fraction_split, validation_fraction_split and test_fraction_split may optionally be provided, they must sum to up to 1. If the provided ones sum to less than 1, the remainder is assigned to sets as decided by Vertex AI. If none of the fractions are set, by default roughly 80% of data will be used for training, 10% for validation, and 10% for test.

Predefined splits:
Assigns input data to training, validation, and test sets based on the value of a provided key.
If using predefined splits, `predefined_split_column_name` must be provided.
Supported only for tabular Datasets.

Timestamp splits:
Assigns input data to training, validation, and test sets
based on a provided timestamps. The youngest data pieces are
assigned to training set, next to validation set, and the oldest
to the test set.
Supported only for tabular Datasets.
Parameters
NameDescription
dataset 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. This column must be unavailable at forecast.

time_column str

Required. Name of the column that identifies time order in the time series. This column must be available at forecast.

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.

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.

predefined_split_column_name str

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.

timestamp_split_column_name str

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

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]

Optional. Column names that should be used as attribute columns. Each column is constant within a time series.

context_window int

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 string

Optional. URI of desired destination BigQuery table for exported test set predictions. Expected format: bq://<project_id>:<dataset_id>:

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]

Quantiles to use for the minimize-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

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

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]

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.

model_id str

Optional. The ID to use for the Model produced by this job, which will become the final component of the model resource name. This value may be up to 63 characters, and valid characters are [a-z0-9_-]. The first character cannot be a number or hyphen.

parent_model str

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

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 Sequence[str]

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

Optional. The description of the model version being uploaded by this job.

additional_experiments List[str]

Optional. Additional experiment flags for the time series forcasting training.

hierarchy_group_columns List[str]

Optional. A list of time series attribute column names that define the time series hierarchy. Only one level of hierarchy is supported, ex. region for a hierarchy of stores or department for a hierarchy of products. If multiple columns are specified, time series will be grouped by their combined values, ex. (blue, large) for color and size, up to 5 columns are accepted. If no group columns are specified, all time series are considered to be part of the same group.

hierarchy_group_total_weight float

Optional. The weight of the loss for predictions aggregated over time series in the same hierarchy group.

hierarchy_temporal_total_weight float

Optional. The weight of the loss for predictions aggregated over the horizon for a single time series.

hierarchy_group_temporal_total_weight float

Optional. The weight of the loss for predictions aggregated over both the horizon and time series in the same hierarchy group.

window_column str

Optional. Name of the column that should be used to filter input rows. The column should contain either booleans or string booleans; if the value of the row is True, generate a sliding window from that row.

window_stride_length int

Optional. Step length used to generate input examples. Every window_stride_length rows will be used to generate a sliding window.

window_max_count int

Optional. Number of rows that should be used to generate input examples. If the total row count is larger than this number, the input data will be randomly sampled to hit the count.

holiday_regions List[str]

Optional. The geographical regions to use when creating holiday features. This option is only allowed when data_granularity_unit is day. Acceptable values can come from any of the following levels: Top level: GLOBAL Second level: continental regions NA: North America JAPAC: Japan and Asia Pacific EMEA: Europe, the Middle East and Africa LAC: Latin America and the Caribbean Third level: countries from ISO 3166-1 Country codes.

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_request_timeout float

Optional. The timeout for the create request in seconds.

Exceptions
TypeDescription
RuntimeErrorIf Training job has already been run or is waiting to run.
Returns
TypeDescription
modelThe trained Vertex AI Model resource or None if training did not produce a Vertex AI Model.

to_dict

to_dict() -> typing.Dict[str, typing.Any]

Returns the resource proto as a dictionary.

wait

wait()

Helper method that blocks until all futures are complete.

wait_for_resource_creation

wait_for_resource_creation() -> None

Waits until resource has been created.