使用 BigQuery 預測功能建立入住率分析應用程式

Gemini Enterprise Agent Platform Vision 是 AI 輔助平台,可用於擷取、分析及儲存影片 資料。Gemini Enterprise Agent Platform Vision 可讓您建構及部署 AI 應用程式。您可以運用 Gemini Enterprise Agent Platform Vision 與其他產品元件的整合功能,建構端對端 Gemini Enterprise Agent Platform Vision 解決方案。

如要開始使用 Gemini Enterprise Agent Platform Vision 平台實作解決方案,請參閱下列 Agent Platform Vision 概念和元件:

  • 串流:代表解決方案中的影片串流層。串流來源可以是即時影像 (例如 IP 攝影機) 或影片檔案 (例如 MP4 檔案)。

  • 應用程式:啟用串流和 AI 處理器之間的連線,對影片執行機器學習作業。舉例來說,您可以將攝影機串流影像連結至 AI 模型,計算經過攝影機前的人數。

  • 應用程式輸出目的地:將分析後的資料傳送至儲存目的地 (Gemini Enterprise Agent Platform Vision 的 Media Warehouse 或 BigQuery),或接收即時資料。將資料儲存至 Gemini Enterprise Agent Platform Vision 的 Media Warehouse 後,您就能搜尋分析輸出內容和中繼資料,這些資料來自用於擷取串流資料的 AI 處理中。儲存至 BigQuery 後,您就能使用該產品的離線分析功能。如果您直接接收應用程式輸出內容,可以運用洞察資料,立即制定業務決策。詳情請參閱「總覽:將應用程式輸出結果連結至資料目的地」。

目標

本教學課程說明如何執行下列操作:

  • 建立 BigQuery 資料集與資料表。
  • 建構 Gemini Enterprise Agent Platform Vision 人流分析應用程式,並連結至 BigQuery。
  • 建立 Compute Engine VM 執行個體並設定環境。
  • 將影片從 VM 執行個體串流至應用程式。
  • 使用儲存的應用程式輸出內容,透過 BigQuery ML 建立預測模型。

費用

在本文件中,您會使用下列 Google Cloud計費元件:

您可以使用 Pricing Calculator,根據預測用量估算費用。

初次使用 Google Cloud 的使用者可能符合免費試用期資格。

完成本文所述工作後,您可以刪除建立的資源,避免繼續計費,詳情請參閱「清除所用資源」。

事前準備

  1. 登入 Google Cloud 帳戶。如果您未曾使用過 Google Cloud,歡迎建立帳戶,親自體驗實際使用我們產品的成效。新客戶還能獲得價值 $300 美元的免費抵免額,用於執行、測試及部署工作負載。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the BigQuery, Compute Engine and Vision AI APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  5. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the following roles to the service account: Vision AI > Vision AI Editor, Compute Engine > Compute Instance Admin (beta), BigQuery > BigQuery Data Owner, Storage > Storage Object Viewer†.

      To grant a role, find the Select a role list, then select the role.

      To grant additional roles, click Add another role and add each additional role.

    7. Click Continue.
    8. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  6. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  7. Install the Google Cloud CLI.

  8. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  9. To initialize the gcloud CLI, run the following command:

    gcloud init
  10. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  11. Verify that billing is enabled for your Google Cloud project.

  12. Enable the BigQuery, Compute Engine and Vision AI APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  13. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the following roles to the service account: Vision AI > Vision AI Editor, Compute Engine > Compute Instance Admin (beta), BigQuery > BigQuery Data Owner, Storage > Storage Object Viewer†.

      To grant a role, find the Select a role list, then select the role.

      To grant additional roles, click Add another role and add each additional role.

    7. Click Continue.
    8. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  14. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  15. Install the Google Cloud CLI.

  16. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  17. To initialize the gcloud CLI, run the following command:

    gcloud init

† 只有在從 Cloud Storage bucket 複製影片樣本檔案時,才需要這個角色。

設定 BigQuery 以接收資料

如要接收資料並根據數據分析應用程式資料進行預測,您必須建立與處理後資訊相符的 BigQuery 資料集和資料表。

建立資料集

您必須先建立資料集,才能建立 BigQuery 資料表,接收應用程式的分析資訊。

控制台

  1. 在 Google Cloud 控制台開啟「BigQuery」頁面。

    前往「BigQuery」頁面

  2. 在「Explorer」面板中,選取要建立資料集的專案。

  3. 展開 「Actions」(動作) 選項,然後點選「Create dataset」(建立資料集)。

  4. 在「Create dataset」(建立資料集) 頁面:

    • 在「Dataset ID」(資料集 ID) 中輸入 occupancy_dataset。
    • 在「Data location」(資料位置) 部分,選擇資料集的地理位置。資料集在建立之後,該位置就無法改變。

    • 針對「Default table expiration」(預設資料表到期時間),選擇下列其中一個選項:

      • [Never] (永不):(預設) 在資料集中建立的資料表永遠不會自動刪除,只能手動刪除。
      • [Number of days after table creation] (資料表建立後的天數):這個值會決定新建立的資料集什麼時候會遭到刪除。如果您在建立資料表時未設定資料表到期時間,系統就會套用這個值。

    • 點選「建立資料集」。

建立 BigQuery 資料表

控制台

  1. 前往 Google Cloud 控制台的「BigQuery」頁面。

    前往 BigQuery

  2. 在「Explorer」窗格中展開專案,然後選取 occupancy_dataset 資料集。
  3. 在「Dataset info」(資料集資訊) 部分,按一下 「Create table」(建立資料表)。
  4. 在「Create table」(建立資料表) 面板中,指定下列詳細資料:
    1. 在「Source」(來源) 部分,從「Create table from」(建立資料表來源) 清單中選取「Empty table」(空白資料表)。
    2. 在「Destination」(目的地) 部分,指定下列詳細資料:
      1. 確認「Dataset」(資料集) 欄位中已指定 occupancy_dataset。
      2. 在「Table」(資料表) 欄位中輸入 occupancy_dataset_table。
      3. 確認「資料表類型」欄位設為「原生資料表」。
    3. 在「Schema」(結構定義) 部分,輸入結構定義。您可以按照下列步驟手動輸入結構定義資訊:
      • 按一下 「Edit as text」(以文字形式編輯),然後貼上下列 JSON 陣列結構定義。使用 JSON 陣列時,您可以使用與建立 JSON 結構定義檔案相同的程序來產生結構定義。
        [
            {
              "name": "ingestion_time",
              "type": "TIMESTAMP",
              "mode": "REQUIRED"
            },
            {
              "name": "application",
              "type": "STRING",
              "mode": "REQUIRED"
            },
            {
              "name": "instance",
              "type": "STRING",
              "mode": "REQUIRED"
            },
            {
              "name": "node",
              "type": "STRING",
              "mode": "REQUIRED"
            },
            {
              "name": "annotation",
              "type": "STRING"
            }
        ]
    4. 點選「建立資料表」。

建立人數計算應用程式

設定 BigQuery 資料集和資料表後,即可建立應用程式,處理傳送至這些 BigQuery 資源的資料。

建立空白的應用程式

您必須先建立空白應用程式,才能填入應用程式圖表。

控制台

在 Google Cloud 控制台建立應用程式。

  1. 開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Applications」(應用程式) 分頁。

    前往「應用程式」分頁

  2. 按一下「 建立」按鈕。

  3. 輸入 occupancy-bq-app 做為應用程式名稱,然後選擇區域。

  4. 點選「建立」。

新增應用程式元件節點

建立空白應用程式後,您可以在應用程式圖表中新增三個節點:

  1. 擷取節點:擷取資料的串流資源,資料來源是您建立的 Compute Engine VM 執行個體。
  2. 處理節點:對擷取的資料執行人流分析模型。
  3. BigQuery 節點:連接器節點,可讓應用程式將中繼資料儲存至 BigQuery 資料表。

控制台

在控制台的應用程式中新增元件節點。

  1. 開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Applications」(應用程式) 分頁。

    前往「應用程式」分頁

  2. 在清單中,選取 occupancy-bq-app 應用程式名稱旁的「View app」(查看應用程式)。系統會將您導向處理管道的圖表視覺化。

新增資料擷取節點

  1. 如要新增輸入串流節點,請在側邊選單的「Connectors」(連接器) 區段中選取「Streams」(串流) 選項。

  2. 在隨即開啟的「Stream」(串流) 選單中,選取「Source」(來源) 區段中的 「Add Stream」(新增串流)。

  3. 在「Add streams」(新增串流) 選單中,選擇 「Register new streams」(註冊新串流),然後新增 occupancy-bq-stream 做為串流名稱。

  4. 如要將串流新增至應用程式圖表,請按一下「Add streams」(新增串流)。

新增資料處理節點

  1. 如要新增人流計數模型節點,請在側邊選單的「Specialized models」(專用模型) 部分中,選取「occupancy analytics」(人流分析) 選項。

  2. 保留預設選項 「People」(人物) 和 「Vehicles」(車輛)。

新增 BigQuery 節點

  1. 如要新增輸出目的地 (儲存空間) 節點,請在側邊選單的「Connectors」(連接器) 區段中選取「BigQuery」選項。

  2. 在「BigQuery」BigQuery選單中搜尋 occupancy_dataset_table,然後選取資料表。

  3. 在「Store metadata from:」(中繼資料儲存來源:) 區段中,選取「 Streams」和「 Occupancy analytics」。

部署應用程式以供使用

使用所有必要元件建構端對端應用程式後,最後一個步驟是部署應用程式。

控制台

  1. 開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Applications」(應用程式) 分頁。

    前往「應用程式」分頁

  2. 在清單中找到 occupancy-bq-app 應用程式,然後選取旁邊的「View app」(查看應用程式)。

  3. 在應用程式圖表建構工具頁面中,按一下 「Deploy」(部署) 按鈕。

  4. 在隨後的確認對話方塊中,選取「Deploy」(部署)。

    部署作業可能需要幾分鐘才能完成。部署完成後,節點旁會顯示綠色勾號。

設定遠端電腦來串流播放影片

您已部署人數計算應用程式,可接收、處理串流資料,並將資料儲存至 BigQuery 資料表,接下來必須將影片資料串流至應用程式。

在本教學課程中,您將建立託管影片的 Compute Engine VM 執行個體,並從 VM 傳送該串流影片資料。

建立 Linux VM

如要從 Compute Engine VM 執行個體傳送影片,第一步是建立 VM 執行個體。

控制台

  1. 前往控制台的「VM instances」(VM 執行個體) 頁面。

    前往 VM 執行個體

  2. 選取您的專案並點選 [繼續]。

  3. 點選「建立執行個體」。

  4. 指定 VM 的名稱。詳情請參閱「資源命名慣例」。

  5. (選用) 變更這個 VM 的「可用區」。Compute Engine 會隨機排列每個區域中的可用區清單,鼓勵使用者使用多個可用區。

  6. 接受其餘預設選項。如要進一步瞭解這些選項,請參閱「建立及啟動 VM」。

  7. 如要建立並啟動 VM,請按一下 [Create] (建立)。

設定 VM 環境

VM 啟動後,您可以使用控制台在瀏覽器中建立 SSH 連線。建立連線後,您可以下載 vaictl 指令列工具,將影片擷取到應用程式中。

控制台

建立與 VM 的 SSH 連線

  1. 前往控制台的「VM instances」(VM 執行個體) 頁面。

    前往 VM 執行個體

  2. 在您建立的執行個體列中,按一下「Connect」(連線) 區段中的「SSH」。瀏覽器會在新視窗中開啟 SSH 連線。

    使用者介面中的 SSH 選項

下載 vaictl 指令列工具

  1. 在「SSH-in-browser」視窗中,使用下列指令下載 Gemini Enterprise Agent Platform Vision (vaictl) 指令列工具:

    wget https://github.com/google/visionai/releases/download/v0.0.5/visionai_0.0-5_amd64.deb
    
  2. 執行下列指令,安裝指令列工具:

    sudo apt install ./visionai_0.0-5_amd64.deb
    
  3. 您可以執行下列指令,測試安裝作業:

    vaictl --help
    

將影片檔案擷取至應用程式

設定 VM 環境後,您可以複製影片樣本檔案,然後使用 vaictl 將影片資料串流至人數統計應用程式。

傳送這個指令後,請先讓資料串流幾個小時,再繼續下一個步驟。

直接透過瀏覽器進行 SSH 連線

將影片樣本複製到 VM

  1. 在 VM 的瀏覽器內 SSH 視窗中,使用下列 gcloud storage cp 指令複製影片範例。替換下列變數:
    • SOURCE:要使用的影片檔案位置。您可以使用自己的影片檔案來源 (例如 gs://BUCKET_NAME/FILENAME.mp4),或使用下列其中一部影片樣本:
      • gs://cloud-samples-data/vertex-ai-vision/street_vehicles_people.mp4 (有人和車輛的影片,影片來源)
      • gs://cloud-samples-data/vertex-ai-vision/highway_vehicles.mp4 (僅含車輛的影片,影片來源)
    gcloud storage cp SOURCE .

從 VM 串流影片,並將資料擷取至應用程式

  1. 如要將這個本機影片檔案傳送至應用程式輸入串流,請使用下列指令。您必須替換下列變數:
    • PROJECT_ID: Google Cloud 專案 ID。
    • LOCATION_ID:地區 ID。例如:us-central1。更多資訊。
    • LOCAL_FILE.EXT:本機影片檔案的檔案名稱。例如 my-video.mp4。
    • --loop 旗標:選用。循環播放檔案資料來模擬串流。

    這個指令會將影片檔案串流至串流。如果使用 --loop 旗標,影片會循環播放至串流中,直到您停止指令為止:

    vaictl -p PROJECT_ID \
        -l LOCATION_ID \
        -c application-cluster-0 \
        --service-endpoint visionai.googleapis.com \
    send video-file to streams 'occupancy-bq-stream' --file-path LOCAL_FILE.EXT --loop

從啟動 vaictl 擷取作業到影片顯示在資訊主頁中,可能需要約 100 秒。

串流擷取功能可用後,請在 Gemini Enterprise Agent Platform Vision 資訊主頁的「Streams」(串流) 分頁中選取 occupancy-bq-stream 串流,即可查看影片動態消息。

前往「串流」分頁

使用 BigQuery ML 建構預測模型

現在,您已擁有一個可正常運作的應用程式,可將中繼資料儲存至 BigQuery。將幾小時的資料串流至應用程式後,您就可以開始使用 BigQuery ML 建構預測模型。

選用:執行占用率查詢

您可以執行簡單的查詢,查看儲存在資料表中的應用程式產生資料。

控制台

  1. 在 Google Cloud 控制台開啟「BigQuery」頁面。

    前往「BigQuery」

  2. 選取 occupancy_dataset 旁的「展開」圖示 ,然後選取 occupancy_dataset_table。

  3. 在資料表詳細資料檢視畫面中,按一下「Compose new query」(編寫新查詢)。

    撰寫新查詢

  4. 在「Query editor」(查詢編輯器) 文字區域中,輸入下列 Google 標準 SQL 查詢:

    SELECT
     *
    FROM (
     SELECT
       TIMESTAMP_TRUNC(PARSE_TIMESTAMP('"%Y-%m-%dT%H:%M:%E*SZ"', JSON_QUERY(annotation,
             "$.currentTime")), MINUTE) currentTime,
       CAST(JSON_QUERY(annotation,
           '$.stats.fullFrameCount[0].count') AS INT64) AS count,
       JSON_QUERY(annotation,
         '$.stats.fullFrameCount[0].entity.labelString') AS type
     FROM
       `PROJECT_ID.occupancy_dataset.occupancy_dataset_table` )
    WHERE
     count IS NOT NULL
  5. 選用:如要變更資料處理位置,請依序點選「Edit」(編輯) >「Query settings」(查詢設定)。在「Processing location」(處理位置) 下方,按一下「Auto-select」(自動選取),然後選擇資料的位置。最後,按一下「Save」(儲存) 即可更新查詢設定。

  6. 按一下 [Run] (執行)。

這會建立一個查詢工作,將輸出寫入暫時性資料表。

執行這項查詢後,系統會產生一個資料表,其中包含影片中有人出現的時間和計數資訊。

currentTime 數量 類型
2022-08-10 16:17:00 UTC 2 「Person」
2022-08-10 16:17:00 UTC 2 「Person」
2022-08-10 16:17:00 UTC 4 「Person」
2022-08-10 16:17:00 UTC 1 「Person」
2022-08-10 16:17:00 UTC 5 「Person」
2022-08-10 16:17:00 UTC 2 「Person」

建立訓練用檢視表

查看儲存至資料表的資料後,您可以建立檢視表,然後檢查結果資料表的內容。您可以使用這個檢視表資料訓練預測模型。

您可以編寫 SQL 查詢來建立檢視表,定義檢視表可存取的資料。SQL 查詢必須包含 SELECT 陳述式。如要進一步瞭解 BigQuery 檢視表,請參閱「檢視表簡介」。

如要建立訓練資料表檢視畫面,請按照下列步驟操作:

控制台

  1. 在 Google Cloud 控制台開啟「BigQuery」頁面。

    前往「BigQuery」

  2. 選取 occupancy_dataset 旁的「展開」圖示 ,然後選取 occupancy_dataset_table。

  3. 在資料表詳細資料檢視畫面中,按一下「Compose new query」(編寫新查詢)。

    撰寫新查詢

  4. 在「Query editor」(查詢編輯器) 文字區域中,輸入下列 Google 標準 SQL 查詢:

    CREATE VIEW `PROJECT_ID.occupancy_dataset.forecast_training_data` AS (
      WITH
        raw_counts AS (
        SELECT
          *
        FROM (
          SELECT
            TIMESTAMP_TRUNC(
              PARSE_TIMESTAMP('"%Y-%m-%dT%H:%M:%E*SZ"',
                              JSON_QUERY(annotation,
                                          "$.currentTime")),
                            MINUTE) AS currentTime,
            CAST(JSON_QUERY(annotation,
                '$.stats.fullFrameCount[0].count') AS INT64) AS count,
            JSON_QUERY(annotation,
              '$.stats.fullFrameCount[0].entity.labelString') AS type
          FROM
            `PROJECT_ID.occupancy_dataset.occupancy_dataset_table` )
        WHERE
          count IS NOT NULL )
      SELECT
        currentTime,
        SUM(count) AS total_count,
        type
      FROM
        raw_counts
      GROUP BY
        currentTime, type)
  5. 按一下「執行」。

選用:查詢檢視表

執行下列查詢,查看新檢視表訓練資料的結果:

控制台

  1. 在 occupancy_dataset_table 資料表詳細資料檢視畫面中,按一下 「Compose new query」(編寫新查詢)。

  2. 在「Query editor」(查詢編輯器) 文字區域中,輸入下列 Google 標準 SQL 查詢:

    SELECT
     *
    FROM
      `PROJECT_ID.occupancy_dataset.forecast_training_data`
    ORDER BY
     currentTime, type
    LIMIT
     100
  3. 按一下「執行」。

這會傳回依時間排序的結果,如下所示:

currentTime total_count 類型
2022-08-10 16:17:00 UTC 129 「Person」
2022-08-10 16:18:00 UTC 150 「Person」
2022-08-10 16:19:00 UTC 80 「Person」
2022-08-10 16:20:00 UTC 129 「Person」
2022-08-10 16:21:00 UTC 142 「Person」
2022-08-10 16:22:00 UTC 71 「Person」
2022-08-10 16:22:00 UTC 2 *「車輛」

使用 BigQuery ML 訓練預測模型

現在您已在檢視表中取得資料,可做為訓練資料,因此可以使用 BigQuery ML 訓練預測模型。

控制台

  1. 在 occupancy_dataset_table 資料表詳細資料檢視畫面中,按一下 「Compose new query」(編寫新查詢)。

  2. 在「Query editor」(查詢編輯器) 文字區域中,輸入下列 Google 標準 SQL 查詢:

    CREATE OR REPLACE MODEL `PROJECT_ID.occupancy_dataset.occupancy_forecast_model`
      OPTIONS( MODEL_TYPE = "ARIMA_PLUS",
        TIME_SERIES_TIMESTAMP_COL = "currentTime",
        TIME_SERIES_DATA_COL = "total_count",
        TIME_SERIES_ID_COL = "type" ) AS
    SELECT
      *
    FROM
      `PROJECT_ID.occupancy_dataset.forecast_training_data`
  3. 按一下「執行」。

查詢需要幾分鐘才會完成。第一次疊代完成後,模型 (occupancy_forecast_model) 會顯示在導覽面板中。由於查詢使用 CREATE MODEL 陳述式建立模型,因此不會顯示查詢結果。

您可以查看「Model stats」(模型統計資料) 分頁,觀察模型訓練過程。第一次疊代完成後,分頁就會更新。每次疊代完成後,統計資料都會持續更新。

使用 BigQuery 取得入住率預測結果

模型訓練完成後,您可以取得模型對人數的預測結果。

下列 ML.FORECAST 查詢使用 HORIZON 函式輸入內容,預測未來 60 分鐘的情況。

控制台

  1. 在 occupancy_dataset_table 資料表詳細資料檢視畫面中,按一下 「Compose new query」(編寫新查詢)。

  2. 在「Query editor」(查詢編輯器) 文字區域中,輸入下列 Google 標準 SQL 查詢:

    SELECT
      *
    FROM
      ML.FORECAST(MODEL `PROJECT_ID.occupancy_dataset.occupancy_forecast_model`,
      STRUCT(60 AS HORIZON))
  3. 按一下「執行」。

模型會針對類型為 "Person" 的未來時間戳記,在 forecast_value 下產生預測。舉例來說,在 2022-08-12 的 11:06:00,模型預測總共會有約 15.26 個「人」。

類型 forecast_timestamp forecast_value standard_error confidence_level prediction_interval_lower_bound prediction_interval_upper_bound
「Person」 2022-08-12 11:06:00 UTC 15.2621986941298 2.56470066 0.95 10.2444693 20.2799280
「Person」 2022-08-12 11:07:00 UTC 13.235260043001354 3.19379743 0.95 6.98672921 19.4837908
「Person」 2022-08-12 11:08:00 UTC 16.257331475128712 3.87581375 0.95 8.67446430 23.8401986
「Person」 2022-08-12 11:09:00 UTC 31.432229611853742 4.24905293 0.95 23.1191356 39.7453236
「Person」 2022-08-12 11:10:00 UTC 26.199214148193725 4.26157413 0.95 17.8616229 34.5368053
「Person」 2022-08-12 11:11:00 UTC 26.211573546307324 4.27962512 0.95 17.8386663 34.5844807

清除所用資源

為避免因為本教學課程所用資源,導致系統向 Google Cloud 收取費用,請刪除含有相關資源的專案,或者保留專案但刪除個別資源。

刪除專案

  1. 前往 Google Cloud 控制台的「Manage resources」(管理資源) 頁面。

    前往「Manage resources」(管理資源)

  2. 在專案清單中選取要刪除的專案,然後點選「Delete」(刪除)。
  3. 在對話方塊中輸入專案 ID,然後按一下 [Shut down] (關閉) 以刪除專案。

刪除個別資源

刪除 Compute Engine VM 執行個體

  1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。

    前往 VM 執行個體

  2. 勾選要刪除的執行個體核取方塊。
  3. 如要刪除執行個體,請依序點選 >「More actions」(更多動作) 和「Delete」(刪除),然後按照指示操作。

刪除 BigQuery 資料集

  1. 在 Google Cloud 控制台開啟「BigQuery」頁面。

    前往 BigQuery

  2. 選取專案旁的 展開,然後找出 occupancy_dataset 資料集。
  3. 如要刪除資料集,請依序點選 「Actions」(動作) 和「Delete」(刪除),然後按照指示操作。

刪除串流

  1. 在 Google Cloud 控制台中,前往「Streams」(串流) 頁面。

    前往「Streams」(串流) 分頁

  2. 找出 occupancy-bq-stream 串流。
  3. 如要刪除串流,請依序點選 「Actions」(動作) 和「Delete stream」(刪除串流),然後按照指示操作。

刪除應用程式

  1. 前往 Google Cloud 控制台的「Applications」(應用程式) 頁面。

    前往「應用程式」分頁

  2. 找出 occupancy-bq-app 應用程式。
  3. 如要刪除應用程式,請依序點選 「Actions」(動作) 和「Delete application」(刪除應用程式),然後按照指示操作。

後續步驟