比較及分析執行作業

您可以使用 Python 適用的 Agent Platform SDK,查看 Vertex AI Experiments 執行作業資料,並比較執行作業。

Google Cloud 控制台會以視覺化方式呈現與這些執行作業相關聯的資料。

取得實驗執行作業資料

這些範例涉及取得特定實驗執行的執行指標、執行參數、執行階段序列指標、構件和分類指標。

摘要指標

Python

from typing import Dict, Union

from google.cloud import aiplatform


def get_experiment_run_metrics_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
) -> Dict[str, Union[float, int]]:
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name, experiment=experiment, project=project, location=location
    )

    return experiment_run.get_metrics()

  • run_name:為這個工作階段指定適當的執行作業名稱。
  • experiment:這項實驗的名稱或例項。 如要在 Google Cloud 控制台中查看實驗清單,請選取該部分導覽列中的「Experiments」(實驗)。
  • project:您可以在 Google Cloud 控制台歡迎頁面找到這些資訊。
  • location:請參閱「可用位置清單」。

參數

Python

from typing import Dict, Union

from google.cloud import aiplatform


def get_experiment_run_params_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
) -> Dict[str, Union[float, int, str]]:
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name, experiment=experiment, project=project, location=location
    )

    return experiment_run.get_params()

  • run_name:為這個工作階段指定適當的執行作業名稱。
  • experiment:這項實驗的名稱或例項。 如要在 Google Cloud 控制台中查看實驗清單,請選取該部分導覽列中的「Experiments」(實驗)。
  • project:您可以在 Google Cloud 控制台歡迎頁面找到這些資訊。
  • location:請參閱「可用位置清單」。

時間序列指標

Python

from typing import Union

from google.cloud import aiplatform


def get_experiment_run_time_series_metric_data_frame_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
) -> "pd.DataFrame":  # noqa: F821
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name, experiment=experiment, project=project, location=location
    )

    return experiment_run.get_time_series_data_frame()

  • run_name:為這個工作階段指定適當的執行作業名稱。
  • experiment:這項實驗的名稱或例項。 如要在 Google Cloud 控制台中查看實驗清單,請選取該部分導覽列中的「Experiments」(實驗)。
  • project:您可以在 Google Cloud 控制台歡迎頁面找到這些資訊。
  • location:請參閱「可用位置清單」。

構件

Python

from typing import List, Union

from google.cloud import aiplatform
from google.cloud.aiplatform.metadata import artifact


def get_experiment_run_artifacts_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
) -> List[artifact.Artifact]:
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name,
        experiment=experiment,
        project=project,
        location=location,
    )

    return experiment_run.get_artifacts()
  • run_name:為這個工作階段指定適當的執行作業名稱。
  • experiment:這項實驗的名稱或例項。 如要在 Google Cloud 控制台中查看實驗清單,請選取該部分導覽列中的「Experiments」(實驗)。
  • project:您可以在 Google Cloud 控制台歡迎頁面找到這些資訊。
  • location:請參閱「可用位置清單」。

分類指標

Python

from typing import Dict, List, Union

from google.cloud import aiplatform


def get_experiment_run_classification_metrics_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
) -> List[Dict[str, Union[str, List]]]:
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name, experiment=experiment, project=project, location=location
    )

    return experiment_run.get_classification_metrics()

  • run_name:為這個工作階段指定適當的執行作業名稱。
  • experiment:這項實驗的名稱或例項。 如要在 Google Cloud 控制台中查看實驗清單,請選取該部分導覽列中的「Experiments」(實驗)。
  • project:您可以在 Google Cloud 控制台歡迎頁面找到這些資訊。
  • location:請參閱「可用位置清單」。

比較執行作業

您可以使用 Agent Platform SDK for Python 擷取與實驗相關聯的資料。實驗執行的資料會以 DataFrame 傳回。

比較執行作業

實驗執行的資料會以 DataFrame 傳回。

Python

from google.cloud import aiplatform


def get_experiments_data_frame_sample(
    experiment: str,
    project: str,
    location: str,
):
    aiplatform.init(experiment=experiment, project=project, location=location)

    experiments_df = aiplatform.get_experiment_df()

    return experiments_df

  • experiment_name:輸入實驗名稱。 如要查看實驗清單,請在 Google Cloud 控制台的區段導覽列中選取「實驗」。
  • project:您可以在 Google Cloud 控制台的歡迎頁面找到這些 ID。
  • location:請參閱「可用位置清單」。

Google Cloud 控制台

使用 Google Cloud 控制台查看實驗執行作業的詳細資料,並比較實驗執行作業。

查看實驗執行資料

  1. 前往 Google Cloud 控制台的「Experiments」(實驗) 頁面。
    前往「實驗」。
    系統會顯示與專案相關聯的實驗清單。
  2. 選取要查看執行作業的實驗。
    系統會顯示執行作業清單、時間序列資料圖表,以及指標和參數資料表。請注意,在本例中,雖然選取了三個執行作業,但時間序列資料圖表中只會顯示兩條線。第三次實驗執行作業沒有任何可顯示的時間序列資料,因此不會顯示第三條線。
    Agent Platform 執行作業清單、時間序列資料,以及指標和參數資料表
  3. 按一下執行作業名稱,前往詳細資料頁面。
    Agent Platform 實驗執行作業導覽
    導覽列和時間序列資料圖表隨即顯示。
    Agent Platform 導覽列,內含時間序列資料圖表
  4. 如要查看所選執行的指標、參數、構件和詳細資料,請按一下導覽列中的對應按鈕。
    • 指標
      Agent Platform 實驗執行指標
    • 參數
      Agent Platform 實驗執行參數
    • 構件
      Agent Platform 實驗執行作業構件
      如要查看構件歷程,請按一下「在中繼資料儲存庫中開啟構件」連結。與執行作業相關聯的歷程圖會隨即顯示。
      Agent Platform 構件歷程圖
    • 詳細資料
      Agent Platform 實驗執行作業詳細資料

如要與他人共用資料,請使用與檢視表相關聯的網址。例如,分享與實驗相關聯的實驗執行清單:

Agent Platform 共用執行作業清單

比較實驗執行作業

您可以選取要比較的執行作業,無論是在同一個實驗中或跨實驗皆可。

  1. 前往 Google Cloud 控制台的「Experiments」(實驗) 頁面。
    前往「實驗」。
    畫面上會顯示實驗清單。
  2. 選取要比較執行作業的實驗。系統會顯示執行作業清單。Agent Platform 執行作業清單
  3. 選取要比較的實驗執行作業。按一下 [Compare] (比較) 。
    Agent Platform 選取執行作業
    根據預設,圖表會比較所選實驗執行的時間序列指標。 Agent Platform 執行圖表
  4. 如要從專案中的任何實驗新增其他執行作業,請按一下「Add run」(新增執行作業)。Agent Platform 新增執行作業

如要與他人共用資料,請使用與檢視表相關聯的網址。例如,分享時間序列指標資料的比較檢視畫面:

Agent Platform 共用資料

如要瞭解如何更新執行作業的狀態,請參閱「建立及管理實驗執行作業」。

後續步驟