예측 모델 학습

이 페이지에서는 Google Cloud 콘솔 또는 Vertex AI API를 사용하여 테이블 형식 데이터 세트에서 예측 모델을 학습시키는 방법을 보여줍니다.

시작하기 전에

예측 모델을 학습시키기 전에 다음을 완료해야 합니다.

모델 학습

Google Cloud 콘솔

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 데이터 세트 페이지로 이동합니다.

    데이터 세트 페이지로 이동

  2. 모델을 학습시키는 데 사용할 데이터 세트의 이름을 클릭하여 세부정보 페이지를 엽니다.

  3. 데이터 유형이 주석 세트를 사용하는 경우 이 모델에 사용할 주석 세트를 선택합니다.

  4. 새 모델 학습을 클릭합니다.

  5. 기타를 선택합니다.

  6. 학습 방법 페이지에서 다음과 같이 구성합니다.

    1. 모델 학습 방법을 선택합니다. 자세한 내용은 모델 학습 방법을 참조하세요.

    2. 계속을 클릭합니다.

  7. 모델 세부정보 페이지에서 다음과 같이 구성합니다.

    1. 새 모델의 표시 이름을 입력합니다.

    2. 타겟 열을 선택합니다.

      타겟 열은 모델이 예측할 값입니다. 타겟 열 요구사항 자세히 알아보기

    3. 데이터 세트의 시계열 식별자타임스탬프을 설정하지 않았다면 지금 선택합니다.

    4. 데이터 세부사항을 선택합니다. 휴일 효과 모델링을 사용하려면 Daily를 선택합니다. 데이터 세부사항 선택 방법 알아보기

    5. 선택사항: 공휴일 리전 드롭다운에서 지리적 리전을 하나 이상 선택하여 공휴일 효과 모델링을 사용 설정합니다. 학습 중에 Vertex AI는 타임스탬프 열의 날짜와 지정된 지리적 리전을 기준으로 모델 내에 휴일 범주형 특성을 만듭니다. 데이터 세부사항Daily로 설정된 경우에만 이 옵션을 선택할 수 있습니다. 기본적으로 휴일 효과 모델링은 사용 중지됩니다. 휴일 효과 모델링에 사용되는 지리적 리전에 대한 자세한 내용은 휴일 리전을 참조하세요.

    6. 환경설정 기간예측 범위를 입력합니다.

      예측 범위는 모델이 예측 데이터 각 행의 타겟 값 예측을 수행할 향후 기간을 결정합니다. 예측 범위데이터 세부사항 단위로 지정됩니다.

      환경설정 기간은 학습 중(또는 예측 시) 모델이 찾을 이전 기간을 설정합니다. 즉, 각 학습 데이터 포인트의 환경설정 기간은 모델이 예측 패턴을 찾는 이전 기간의 범위를 결정합니다. 환경설정 기간데이터 세부사항 단위로 지정됩니다.

      자세히 알아보기

    7. 테스트 데이터 세트를 BigQuery로 내보내려면 BigQuery에 테스트 데이터 세트 내보내기를 선택하고 테이블 이름을 입력합니다.

    8. 데이터 분할을 수동으로 제어하거나 예측 창을 구성하려면 고급 옵션을 엽니다.

    9. 기본 데이터 분할은 시간순이며, 표준은 80/10/10%입니다. 어떤 분할에 어떤 행을 할당할지 수동으로 지정하려면 수동을 선택하고 데이터 분할 열을 지정합니다.

      데이터 분할 자세히 알아보기

    10. 예측 구간 생성에 대해 순환 기간 전략을 선택합니다. 기본 전략은 개수입니다.

      • 개수: 제공된 텍스트 상자에 최대 구간 수 값을 설정합니다.
      • 스트라이트: 제공된 텍스트 상자에 스트라이드 길이 값을 설정합니다.
      • : 제공된 드롭다운에서 적절한 열 이름을 선택합니다.

      자세한 내용은 순환 기간 전략을 참조하세요.

    11. 계속을 클릭합니다.

  8. 학습 옵션 페이지에서 다음과 같이 구성합니다.

    1. 아직 클릭하지 않았다면 통계 생성을 클릭합니다.

      통계를 생성하면 변환 드롭다운 메뉴가 채워집니다.

    2. 열 목록을 검토하고 모델 학습에 사용하지 않아야 하는 열을 학습에서 제외합니다.

      데이터 분할 열을 사용하는 경우 해당 열을 포함해야 합니다.

    3. 포함된 특성에 대해 선택된 변환을 검토하고 필요한 업데이트를 수행합니다.

      선택한 변환에 유효하지 않은 데이터가 포함된 행은 학습에서 제외됩니다. 변환에 대해 자세히 알아보세요.

    4. 학습에 포함한 각 열에서 해당 특성과 시계열의 관계 및 예측 시 사용 가능한 특성 유형을 지정합니다. 특성 유형 및 가용성에 대해 자세히 알아보세요.

    5. 가중치 열을 지정하거나, 최적화 목표를 기본값에서 변경하거나, 계층적 예측을 사용 설정하려면, 고급 옵션을 엽니다.

    6. 선택사항. 가중치 열을 지정하려면 드롭다운 목록에서 선택합니다. 가중치 열에 대해 자세히 알아보세요.

    7. 선택사항. 최적화 목표를 선택하려면 목록에서 선택합니다. 최적화 목표에 대해 자세히 알아보세요.

    8. 선택사항. 계층적 예측을 사용하려면 계층적 예측 사용 설정을 선택합니다. 다음 세 가지 그룹화 옵션 중에서 선택할 수 있습니다.

      • No grouping
      • Group by columns
      • Group all

      다음과 같은 집계 손실 가중치를 설정할 수도 있습니다.

      • Group total weight. 이 필드는 Group by columns 또는 Group all 옵션을 선택한 경우에만 설정할 수 있습니다.
      • Temporal total weight.
      • Group temporal total weight. 이 필드는 Group by columns 또는 Group all 옵션을 선택한 경우에만 설정할 수 있습니다.

      계층적 예측에 대해 자세히 알아보세요.

    9. 계속을 클릭합니다.

  9. 컴퓨팅 및 가격 책정 페이지에서 다음과 같이 구성합니다.

    1. 모델을 학습시킬 최대 시간을 입력합니다. 이 설정은 학습 비용에 상한선을 설정하는 데 도움이 됩니다. 새 모델을 만드는 데 관련된 다른 작업이 있으므로 실제 경과 시간은 이 값보다 길 수 있습니다.

      추천 학습 시간은 예측 범위의 크기 및 학습 데이터와 관련이 있습니다. 아래 표는 예측 학습 실행 예시 및 고품질 모델을 학습시키는 데 필요한 학습 시간 범위를 제공합니다.

      특징 예측 범위 학습 시간
      1,200만 개 10 6 3~6시간
      2,000만 개 50 13 6~12시간
      1,600만 개 30 365 24~48시간

      학습 가격에 대한 자세한 내용은 가격 책정 페이지를 참조하세요.

    2. 학습 시작을 클릭합니다.

      데이터의 규모 및 복잡성과 학습 예산(지정한 경우)에 따라 모델 학습에 많은 시간이 소요될 수 있습니다. 탭을 닫았다가 나중에 다시 돌아와도 됩니다. 모델 학습이 완료되면 이메일이 전송됩니다.

API

언어 또는 환경에 대한 탭을 선택합니다.

REST

trainingPipelines.create 명령어를 사용하여 모델을 학습시킵니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 리전
  • PROJECT: 프로젝트 ID
  • TRAINING_PIPELINE_DISPLAY_NAME: 이 작업에 대해 생성된 학습 파이프라인의 표시 이름입니다.
  • TRAINING_TASK_DEFINITION: 모델 학습 메서드
    • Time series Dense Encoder(TiDE)
      gs://google-cloud-aiplatform/schema/trainingjob/definition/time_series_dense_encoder_forecasting_1.0.0.yaml
    • Temporal Fusion Transformer(TFT)
      gs://google-cloud-aiplatform/schema/trainingjob/definition/temporal_fusion_transformer_time_series_forecasting_1.0.0.yaml
    • AutoML(L2L)
      gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_forecasting_1.0.0.yaml
    • Seq2Seq+
      gs://google-cloud-aiplatform/schema/trainingjob/definition/seq2seq_plus_time_series_forecasting_1.0.0.yaml
    자세한 내용은 모델 학습 방법을 참조하세요.
  • TARGET_COLUMN: 이 모델에서 예측할 열(값)입니다.
  • TIME_COLUMN: 시간 열입니다. 자세히 알아보기
  • TIME_SERIES_IDENTIFIER_COLUMN: 시계열 식별자 열입니다. 자세히 알아보기
  • WEIGHT_COLUMN: (선택사항) 가중치 열입니다. 자세히 알아보기
  • TRAINING_BUDGET: 모델이 학습시키려는 최대 시간(밀리 노드 시간, 1,000밀리 노드 시간은 1노드 시간과 동일).
  • GRANULARITY_UNIT: 학습 데이터, 예측 범위, 환경설정 기간의 세부사항에 사용할 단위입니다. minute, hour, day, week, month, year일 수 있습니다. 휴일 효과 모델링을 사용하려면 day를 선택합니다. 데이터 세부사항 선택 방법 알아보기
  • GRANULARITY_QUANTITY: 학습 데이터에서 관찰 사이의 간격을 구성하는 세분화 단위 수입니다. 분을 제외한 모든 단위에 대해 하나여야 하며 1, 5, 10, 15 또는 30일 수 있습니다. 데이터 세부사항 선택 방법 알아보기
  • GROUP_COLUMNS: 계층 구조 수준의 그룹화를 식별하는 학습 입력 테이블의 열 이름입니다. 열은 `time_series_attribute_columns`여야 합니다. 자세히 알아보기
  • GROUP_TOTAL_WEIGHT: 개별 손실을 기준으로 한 그룹 집계 손실의 가중치입니다. `0.0` 으로 설정하거나 설정하지 않으면 사용 중지됩니다. 그룹 열이 설정되지 않으면 모든 시계열이 동일한 그룹의 일부로 취급되며 모든 시계열에서 집계됩니다. 자세히 알아보기
  • TEMPORAL_TOTAL_WEIGHT: 개별 손실을 기준으로 한 시간 집계 손실의 가중치입니다. `0.0` 으로 설정하거나 설정하지 않으면 사용 중지됩니다. 자세히 알아보기
  • GROUP_TEMPORAL_TOTAL_WEIGHT: 개별 손실을 기준으로 한 총(그룹 x 시간) 집계 손실의 가중치입니다. `0.0` 으로 설정하거나 설정하지 않으면 사용 중지됩니다. 그룹 열이 설정되지 않으면 모든 시계열이 동일한 그룹의 일부로 취급되며 모든 시계열에서 집계됩니다. 자세히 알아보기
  • HOLIDAY_REGIONS: (선택사항) 하나 이상의 지리적 리전을 선택하여 휴일 효과 모델링을 사용 설정할 수 있습니다. 학습 중에 Vertex AI는 TIME_COLUMN의 날짜와 지정된 지리적 리전을 기준으로 모델 내에 휴일 범주형 특성을 만듭니다. 사용 설정하려면 GRANULARITY_UNITday로 설정하고 HOLIDAY_REGIONS 필드에 하나 이상의 리전을 지정합니다. 기본적으로 휴일 효과 모델링은 사용 중지됩니다. 자세한 내용은 휴일 리전을 참조하세요.
  • FORECAST_HORIZON: 예측 범위는 모델이 예측 데이터 각 행의 타겟 값 예측을 수행할 향후 기간을 결정합니다. 예측 범위는 데이터 세부사항 단위(GRANULARITY_UNIT)로 지정됩니다. 자세히 알아보기
  • CONTEXT_WINDOW: 환경설정 기간은 학습 중(또는 예측 시) 모델이 찾을 이전 기간을 설정합니다. 즉, 각 학습 데이터 포인트의 환경설정 기간은 모델이 예측 패턴을 찾는 이전 기간의 범위를 결정합니다. 환경설정 기간은 데이터 세부사항 단위(GRANULARITY_UNIT)로 지정됩니다. 자세히 알아보기
  • OPTIMIZATION_OBJECTIVE: 기본적으로 Vertex AI는 평균 제곱근 오차(RMSE)를 최소화합니다. 예측 모델에 다른 최적화 목표를 원하는 경우 예측 모델의 최적화 목표 옵션 중 하나를 선택하세요. 분위수 손실을 최소화하기로 선택하는 경우 QUANTILES 값도 지정해야 합니다.
  • PROBABILISTIC_INFERENCE: (선택사항) true로 설정하면 Vertex AI에서 예측 확률 분포를 모델링합니다. 확률적 추론은 노이즈가 많은 데이터를 처리하고 불확실성을 수치화하여 모델 품질을 향상시킬 수 있습니다. QUANTILES가 지정되면 Vertex AI에서 확률 분포의 분위수도 반환합니다. 확률적 추론은 Time series Dense Encoder (TiDE) and the AutoML (L2L) training methods. It is incompatible with hierarchical forecasting and the minimize-quantile-loss optimization objective. 와만 호환됩니다.
  • QUANTILES: Quantiles to use for the minimize-quantile-loss optimization objective and probabilistic inference. Provide a list of up to five unique numbers between 0 and 1, exclusive.
  • TIME_SERIES_ATTRIBUTE_COL: The name or names of the columns that are time series attributes. Learn more.
  • AVAILABLE_AT_FORECAST_COL: The name or names of the covariate columns whose value is known at forecast time. Learn more.
  • UNAVAILABLE_AT_FORECAST_COL: The name or names of the covariate columns whose value is unknown at forecast time. Learn more.
  • TRANSFORMATION_TYPE: The transformation type is provided for each column used to train the model. Learn more.
  • COLUMN_NAME: The name of the column with the specified transformation type. Every column used to train the model must be specified.
  • MODEL_DISPLAY_NAME: Display name for the newly trained model.
  • DATASET_ID: ID for the training Dataset.
  • You can provide a Split object to control your data split. For information about controlling data split, see Control the data split using REST.
  • You can provide a windowConfig object to configure a rolling window strategy for forecast window generation. For further information, see Configure the rolling window strategy using REST.
  • PROJECT_NUMBER: Your project's automatically generated project number

HTTP method and URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
    "displayName": "TRAINING_PIPELINE_DISPLAY_NAME",
    "trainingTaskDefinition": "TRAINING_TASK_DEFINITION",
    "trainingTaskInputs": {
        "targetColumn": "TARGET_COLUMN",
        "timeColumn": "TIME_COLUMN",
        "timeSeriesIdentifierColumn": "TIME_SERIES_IDENTIFIER_COLUMN",
        "weightColumn": "WEIGHT_COLUMN",
        "trainBudgetMilliNodeHours": TRAINING_BUDGET,
        "dataGranularity": {"unit": "GRANULARITY_UNIT", "quantity": GRANULARITY_QUANTITY},
        "hierarchyConfig": {"groupColumns": GROUP_COLUMNS, "groupTotalWeight": GROUP_TOTAL_WEIGHT, "temporalTotalWeight": TEMPORAL_TOTAL_WEIGHT, "groupTemporalTotalWeight": GROUP_TEMPORAL_TOTAL_WEIGHT}
        "holidayRegions" : ["HOLIDAY_REGIONS_1", "HOLIDAY_REGIONS_2", ...]
        "forecast_horizon": FORECAST_HORIZON,
        "context_window": CONTEXT_WINDOW,
        "optimizationObjective": "OPTIMIZATION_OBJECTIVE",
        "quantiles": "QUANTILES",
        "enableProbabilisticInference": "PROBABILISTIC_INFERENCE",
        "time_series_attribute_columns": ["TIME_SERIES_ATTRIBUTE_COL_1", "TIME_SERIES_ATTRIBUTE_COL_2", ...]
        "available_at_forecast_columns": ["AVAILABLE_AT_FORECAST_COL_1", "AVAILABLE_AT_FORECAST_COL_2", ...]
        "unavailable_at_forecast_columns": ["UNAVAILABLE_AT_FORECAST_COL_1", "UNAVAILABLE_AT_FORECAST_COL_2", ...]
        "transformations": [
            {"TRANSFORMATION_TYPE_1":  {"column_name" : "COLUMN_NAME_1"} },
            {"TRANSFORMATION_TYPE_2":  {"column_name" : "COLUMN_NAME_2"} },
            ...
    },
    "modelToUpload": {"displayName": "MODEL_DISPLAY_NAME"},
    "inputDataConfig": {
      "datasetId": "DATASET_ID",
    }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/trainingPipelines/TRAINING_PIPELINE_ID",
  "displayName": "myModelName",
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_tabular_1.0.0.yaml",
  "modelToUpload": {
    "displayName": "myModelName"
  },
  "state": "PIPELINE_STATE_PENDING",
  "createTime": "2020-08-18T01:22:57.479336Z",
  "updateTime": "2020-08-18T01:22:57.479336Z"
}

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.

def create_training_pipeline_forecasting_time_series_dense_encoder_sample(
    project: str,
    display_name: str,
    dataset_id: str,
    location: str = "us-central1",
    model_display_name: str = "my_model",
    target_column: str = "target_column",
    time_column: str = "date",
    time_series_identifier_column: str = "time_series_id",
    unavailable_at_forecast_columns: List[str] = [],
    available_at_forecast_columns: List[str] = [],
    forecast_horizon: int = 1,
    data_granularity_unit: str = "week",
    data_granularity_count: int = 1,
    training_fraction_split: float = 0.8,
    validation_fraction_split: float = 0.1,
    test_fraction_split: float = 0.1,
    budget_milli_node_hours: int = 8000,
    timestamp_split_column_name: str = "timestamp_split",
    weight_column: str = "weight",
    time_series_attribute_columns: List[str] = [],
    context_window: int = 0,
    export_evaluated_data_items: bool = False,
    export_evaluated_data_items_bigquery_destination_uri: Optional[str] = None,
    export_evaluated_data_items_override_destination: bool = False,
    quantiles: Optional[List[float]] = None,
    enable_probabilistic_inference: bool = False,
    validation_options: Optional[str] = None,
    predefined_split_column_name: Optional[str] = None,
    sync: bool = True,
):
    aiplatform.init(project=project, location=location)

    # Create training job
    forecasting_tide_job = aiplatform.TimeSeriesDenseEncoderForecastingTrainingJob(
        display_name=display_name,
        optimization_objective="minimize-rmse",
    )

    # Retrieve existing dataset
    dataset = aiplatform.TimeSeriesDataset(dataset_id)

    # Run training job
    model = forecasting_tide_job.run(
        dataset=dataset,
        target_column=target_column,
        time_column=time_column,
        time_series_identifier_column=time_series_identifier_column,
        unavailable_at_forecast_columns=unavailable_at_forecast_columns,
        available_at_forecast_columns=available_at_forecast_columns,
        forecast_horizon=forecast_horizon,
        data_granularity_unit=data_granularity_unit,
        data_granularity_count=data_granularity_count,
        training_fraction_split=training_fraction_split,
        validation_fraction_split=validation_fraction_split,
        test_fraction_split=test_fraction_split,
        predefined_split_column_name=predefined_split_column_name,
        timestamp_split_column_name=timestamp_split_column_name,
        weight_column=weight_column,
        time_series_attribute_columns=time_series_attribute_columns,
        context_window=context_window,
        export_evaluated_data_items=export_evaluated_data_items,
        export_evaluated_data_items_bigquery_destination_uri=export_evaluated_data_items_bigquery_destination_uri,
        export_evaluated_data_items_override_destination=export_evaluated_data_items_override_destination,
        quantiles=quantiles,
        enable_probabilistic_inference=enable_probabilistic_inference,
        validation_options=validation_options,
        budget_milli_node_hours=budget_milli_node_hours,
        model_display_name=model_display_name,
        sync=sync,
    )

    model.wait()

    print(model.display_name)
    print(model.resource_name)
    print(model.uri)
    return model

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.

def create_training_pipeline_forecasting_temporal_fusion_transformer_sample(
    project: str,
    display_name: str,
    dataset_id: str,
    location: str = "us-central1",
    model_display_name: str = "my_model",
    target_column: str = "target_column",
    time_column: str = "date",
    time_series_identifier_column: str = "time_series_id",
    unavailable_at_forecast_columns: List[str] = [],
    available_at_forecast_columns: List[str] = [],
    forecast_horizon: int = 1,
    data_granularity_unit: str = "week",
    data_granularity_count: int = 1,
    training_fraction_split: float = 0.8,
    validation_fraction_split: float = 0.1,
    test_fraction_split: float = 0.1,
    budget_milli_node_hours: int = 8000,
    timestamp_split_column_name: str = "timestamp_split",
    weight_column: str = "weight",
    time_series_attribute_columns: List[str] = [],
    context_window: int = 0,
    export_evaluated_data_items: bool = False,
    export_evaluated_data_items_bigquery_destination_uri: Optional[str] = None,
    export_evaluated_data_items_override_destination: bool = False,
    validation_options: Optional[str] = None,
    predefined_split_column_name: Optional[str] = None,
    sync: bool = True,
):
    aiplatform.init(project=project, location=location)

    # Create training job
    forecasting_tft_job = aiplatform.TemporalFusionTransformerForecastingTrainingJob(
        display_name=display_name,
        optimization_objective="minimize-rmse",
    )

    # Retrieve existing dataset
    dataset = aiplatform.TimeSeriesDataset(dataset_id)

    # Run training job
    model = forecasting_tft_job.run(
        dataset=dataset,
        target_column=target_column,
        time_column=time_column,
        time_series_identifier_column=time_series_identifier_column,
        unavailable_at_forecast_columns=unavailable_at_forecast_columns,
        available_at_forecast_columns=available_at_forecast_columns,
        forecast_horizon=forecast_horizon,
        data_granularity_unit=data_granularity_unit,
        data_granularity_count=data_granularity_count,
        training_fraction_split=training_fraction_split,
        validation_fraction_split=validation_fraction_split,
        test_fraction_split=test_fraction_split,
        predefined_split_column_name=predefined_split_column_name,
        timestamp_split_column_name=timestamp_split_column_name,
        weight_column=weight_column,
        time_series_attribute_columns=time_series_attribute_columns,
        context_window=context_window,
        export_evaluated_data_items=export_evaluated_data_items,
        export_evaluated_data_items_bigquery_destination_uri=export_evaluated_data_items_bigquery_destination_uri,
        export_evaluated_data_items_override_destination=export_evaluated_data_items_override_destination,
        validation_options=validation_options,
        budget_milli_node_hours=budget_milli_node_hours,
        model_display_name=model_display_name,
        sync=sync,
    )

    model.wait()

    print(model.display_name)
    print(model.resource_name)
    print(model.uri)
    return model

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.

def create_training_pipeline_forecasting_sample(
    project: str,
    display_name: str,
    dataset_id: str,
    location: str = "us-central1",
    model_display_name: str = "my_model",
    target_column: str = "target_column",
    time_column: str = "date",
    time_series_identifier_column: str = "time_series_id",
    unavailable_at_forecast_columns: List[str] = [],
    available_at_forecast_columns: List[str] = [],
    forecast_horizon: int = 1,
    data_granularity_unit: str = "week",
    data_granularity_count: int = 1,
    training_fraction_split: float = 0.8,
    validation_fraction_split: float = 0.1,
    test_fraction_split: float = 0.1,
    budget_milli_node_hours: int = 8000,
    timestamp_split_column_name: str = "timestamp_split",
    weight_column: str = "weight",
    time_series_attribute_columns: List[str] = [],
    context_window: int = 0,
    export_evaluated_data_items: bool = False,
    export_evaluated_data_items_bigquery_destination_uri: Optional[str] = None,
    export_evaluated_data_items_override_destination: bool = False,
    quantiles: Optional[List[float]] = None,
    enable_probabilistic_inference: bool = False,
    validation_options: Optional[str] = None,
    predefined_split_column_name: Optional[str] = None,
    sync: bool = True,
):
    aiplatform.init(project=project, location=location)

    # Create training job
    forecasting_job = aiplatform.AutoMLForecastingTrainingJob(
        display_name=display_name, optimization_objective="minimize-rmse"
    )

    # Retrieve existing dataset
    dataset = aiplatform.TimeSeriesDataset(dataset_id)

    # Run training job
    model = forecasting_job.run(
        dataset=dataset,
        target_column=target_column,
        time_column=time_column,
        time_series_identifier_column=time_series_identifier_column,
        unavailable_at_forecast_columns=unavailable_at_forecast_columns,
        available_at_forecast_columns=available_at_forecast_columns,
        forecast_horizon=forecast_horizon,
        data_granularity_unit=data_granularity_unit,
        data_granularity_count=data_granularity_count,
        training_fraction_split=training_fraction_split,
        validation_fraction_split=validation_fraction_split,
        test_fraction_split=test_fraction_split,
        predefined_split_column_name=predefined_split_column_name,
        timestamp_split_column_name=timestamp_split_column_name,
        weight_column=weight_column,
        time_series_attribute_columns=time_series_attribute_columns,
        context_window=context_window,
        export_evaluated_data_items=export_evaluated_data_items,
        export_evaluated_data_items_bigquery_destination_uri=export_evaluated_data_items_bigquery_destination_uri,
        export_evaluated_data_items_override_destination=export_evaluated_data_items_override_destination,
        quantiles=quantiles,
        enable_probabilistic_inference=enable_probabilistic_inference,
        validation_options=validation_options,
        budget_milli_node_hours=budget_milli_node_hours,
        model_display_name=model_display_name,
        sync=sync,
    )

    model.wait()

    print(model.display_name)
    print(model.resource_name)
    print(model.uri)
    return model

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.

def create_training_pipeline_forecasting_seq2seq_sample(
    project: str,
    display_name: str,
    dataset_id: str,
    location: str = "us-central1",
    model_display_name: str = "my_model",
    target_column: str = "target_column",
    time_column: str = "date",
    time_series_identifier_column: str = "time_series_id",
    unavailable_at_forecast_columns: List[str] = [],
    available_at_forecast_columns: List[str] = [],
    forecast_horizon: int = 1,
    data_granularity_unit: str = "week",
    data_granularity_count: int = 1,
    training_fraction_split: float = 0.8,
    validation_fraction_split: float = 0.1,
    test_fraction_split: float = 0.1,
    budget_milli_node_hours: int = 8000,
    timestamp_split_column_name: str = "timestamp_split",
    weight_column: str = "weight",
    time_series_attribute_columns: List[str] = [],
    context_window: int = 0,
    export_evaluated_data_items: bool = False,
    export_evaluated_data_items_bigquery_destination_uri: Optional[str] = None,
    export_evaluated_data_items_override_destination: bool = False,
    validation_options: Optional[str] = None,
    predefined_split_column_name: Optional[str] = None,
    sync: bool = True,
):
    aiplatform.init(project=project, location=location)

    # Create training job
    forecasting_seq2seq_job = aiplatform.SequenceToSequencePlusForecastingTrainingJob(
        display_name=display_name, optimization_objective="minimize-rmse"
    )

    # Retrieve existing dataset
    dataset = aiplatform.TimeSeriesDataset(dataset_id)

    # Run training job
    model = forecasting_seq2seq_job.run(
        dataset=dataset,
        target_column=target_column,
        time_column=time_column,
        time_series_identifier_column=time_series_identifier_column,
        unavailable_at_forecast_columns=unavailable_at_forecast_columns,
        available_at_forecast_columns=available_at_forecast_columns,
        forecast_horizon=forecast_horizon,
        data_granularity_unit=data_granularity_unit,
        data_granularity_count=data_granularity_count,
        training_fraction_split=training_fraction_split,
        validation_fraction_split=validation_fraction_split,
        test_fraction_split=test_fraction_split,
        predefined_split_column_name=predefined_split_column_name,
        timestamp_split_column_name=timestamp_split_column_name,
        weight_column=weight_column,
        time_series_attribute_columns=time_series_attribute_columns,
        context_window=context_window,
        export_evaluated_data_items=export_evaluated_data_items,
        export_evaluated_data_items_bigquery_destination_uri=export_evaluated_data_items_bigquery_destination_uri,
        export_evaluated_data_items_override_destination=export_evaluated_data_items_override_destination,
        validation_options=validation_options,
        budget_milli_node_hours=budget_milli_node_hours,
        model_display_name=model_display_name,
        sync=sync,
    )

    model.wait()

    print(model.display_name)
    print(model.resource_name)
    print(model.uri)
    return model

Control the data split using REST

You can control how your training data is split between the training, validation, and test sets. Use a split column to manually specify the data split for each row and provide it as part of a PredefinedSplit Split object in the inputDataConfig of the JSON request.

DATA_SPLIT_COLUMN is the column containing the data split values (TRAIN, VALIDATION, TEST).

 "predefinedSplit": {
   "key": DATA_SPLIT_COLUMN
 },

Learn more about data splits.

Configure the rolling window strategy using REST

You can provide a windowConfig object to configure a rolling window strategy for forecast window generation. The default strategy is maxCount.

  • To use the maxCount option, add the following to trainingTaskInputs of the JSON request. MAX_COUNT_VALUE refers to the maximum number of windows.

     "windowConfig": {
       "maxCount": MAX_COUNT_VALUE
     },
     ```
    
  • To use the strideLength option, add the following to trainingTaskInputs of the JSON request. STRIDE_LENGTH_VALUE refers to the value of the stride length.

     "windowConfig": {
       "strideLength": STRIDE_LENGTH_VALUE
     },
     ```
    
  • To use the column option, add the following to trainingTaskInputs of the JSON request. COLUMN_NAME refers to the name of the column with True or False values.

     "windowConfig": {
       "column": "COLUMN_NAME"
     },
     ```
    

To learn more, see Rolling window strategies.

What's next