0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Vertex AutoML の分類モデル予測結果をBigQueryで確認する方法

Posted at

AutoMLで分類モデルのバッチ予測結果をBigQueryに出力すると、結果はREPEATEDという型でクラスとスコアが格納されます。
ここから、最もスコアが高い分類結果を抽出するには以下のように一度REPEATED型をUNNESTしてからWINDOW関数でスコアが高い順にして、一番スコアが高いものだけWHERE句で指定できます。

SELECT
  customer_id,
  classes,
  scores
FROM (
  SELECT
    customer_id,
    classes,
    scores,
    ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY scores DESC) AS rank
  FROM
    myproject.mydataset.predictions_2023_09_13T19_47_23_623Z_960 p,
    UNNEST(p.predicted_class.classes) AS classes,
    UNNEST(p.predicted_class.scores) AS scores )
WHERE
  rank=1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?