バッチ予測

このページでは、複数行のデータを一度に AutoML Tables に読み込んで、各行の予測を取得する方法について説明します。

はじめに

モデルを作成(トレーニング)した後、batchPredict メソッドを使用してバッチ予測の非同期リクエストを行うことができます。入力データはテーブル形式で batchPredict メソッドに渡します。各行で、モデルで使用されるようにトレーニングした特徴の値を指定します。batchPredict メソッドはこのデータをモデルに送信し、各データ行の予測を返します。

予測の実行を継続するには、モデルを 6 か月ごとに再トレーニングする必要があります。

バッチ予測のリクエスト

バッチ予測では、データソースと結果の格納先を BigQuery テーブルまたは Cloud Storage の CSV ファイルで指定します。格納元と格納先で同じテクノロジーを使用する必要はありません。たとえば、データソースに BigQuery を使用し、結果の格納先に Cloud Storage の CSV ファイルを使用することも可能です。必要に応じて、次の 2 つのタスクから適切な手順を行ってください。

データソースには、モデルのトレーニングに使用したすべての列を含む表形式のデータが含まれている必要があります。トレーニング データに含まれなかった列や、トレーニング データに含まれているがトレーニングへの使用からは除外された列を含めることができます。これらの追加の列は予測出力に含まれますが、予測の生成には使用されません。

BigQuery テーブルの使用

入力データの列名とデータ型は、トレーニング データで使用したデータと一致する必要があります。列の順序とトレーニング データの順序は異なっていても構いません。

BigQuery テーブルの要件

  • BigQuery のデータソース テーブルは、100 GB 以下でなければなりません。
  • US または EU のロケーションにあるマルチリージョンの BigQuery データセットを使用する必要があります。
  • テーブルが別のプロジェクトにある場合は、そのプロジェクトの AutoML Tables サービス アカウントに BigQuery Data Editor 役割を指定する必要があります。 詳細

バッチ予測のリクエスト

Console

  1. Google Cloud Console で [AutoML テーブル] ページに移動します。

    [AutoML テーブル] ページに移動

  2. [モデル] を選択し、使用するモデルを開きます。

  3. [テストと使用] タブを選択します。

  4. [バッチ予測] をクリックします。

  5. [入力データセット] で [BigQuery のテーブル] を選択し、データソースのプロジェクト、データセット、テーブル ID を入力します。

  6. [結果] で [BigQuery プロジェクト] を選択し、結果の格納先のプロジェクト ID を入力します。

  7. 各特徴が予測に及ぼす影響を確認するには、[特徴量の重要度を生成] を選択します。

    特徴量の重要度を生成すると、予測に必要な時間とコンピューティング リソースが増加します。ローカル特徴量の重要度は、Cloud Storage の結果の格納先では使用できません。

  8. [バッチ予測を送信] をクリックし、バッチ予測をリクエストします。

    AutoML Tables の [バッチ予測] ページ

REST

バッチ予測をリクエストするには、models.batchPredict メソッドを使用します。

リクエストのデータを使用する前に、次のように置き換えます。

  • endpoint: グローバル ロケーションの場合は automl.googleapis.com、EU リージョンの場合は eu-automl.googleapis.com
  • project-id: Google Cloud プロジェクト ID
  • location:リソースのロケーション:グローバルの場合はus-central1、EUの場合はeu
  • model-id:モデルの ID。例: TBL543
  • dataset-id: 予測データが配置されている BigQuery データセットの ID。
  • table-id: 予測データが存在する BigQuery テーブルの ID。

    AutoML Tables は、prediction-<model_name>-<timestamp>という名前の予測結果のサブフォルダをproject-id.dataset-id.table-idに作成します。

HTTP メソッドと URL:

POST https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict

JSON 本文のリクエスト:

{
  "inputConfig": {
    "bigquerySource": {
      "inputUri": "bq://project-id.dataset-id.table-id"
    },
  },
  "outputConfig": {
    "bigqueryDestination": {
      "outputUri": "bq://project-id"
    },
  },
}

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict"

PowerShell

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict" | Select-Object -Expand Content
バッチ予測は長時間実行オペレーションです。オペレーションのステータスをポーリングするか、オペレーションが完了するまで待つことができます。詳細

ローカル特徴量の重要度を取得するには、リクエスト データに feature_importance パラメータを追加します。詳しくは、ローカル特徴量の重要度をご覧ください。

Java

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.automl.v1beta1.BatchPredictInputConfig;
import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig;
import com.google.cloud.automl.v1beta1.BatchPredictRequest;
import com.google.cloud.automl.v1beta1.BatchPredictResult;
import com.google.cloud.automl.v1beta1.BigQueryDestination;
import com.google.cloud.automl.v1beta1.BigQuerySource;
import com.google.cloud.automl.v1beta1.ModelName;
import com.google.cloud.automl.v1beta1.OperationMetadata;
import com.google.cloud.automl.v1beta1.PredictionServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

abstract class TablesBatchPredictBigQuery {

  static void batchPredict() throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String inputUri = "bq://YOUR_PROJECT_ID.bqDatasetID.bqTableId";
    String outputUri = "bq://YOUR_PROJECT_ID";
    batchPredict(projectId, modelId, inputUri, outputUri);
  }

  static void batchPredict(String projectId, String modelId, String inputUri, String outputUri)
      throws IOException, ExecutionException, InterruptedException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PredictionServiceClient client = PredictionServiceClient.create()) {
      // Get the full path of the model.
      ModelName name = ModelName.of(projectId, "us-central1", modelId);

      // Configure the source of the file from BigQuery
      BigQuerySource bigQuerySource = BigQuerySource.newBuilder().setInputUri(inputUri).build();
      BatchPredictInputConfig inputConfig =
          BatchPredictInputConfig.newBuilder().setBigquerySource(bigQuerySource).build();

      // Configure where to store the output in BigQuery
      BigQueryDestination bigQueryDestination =
          BigQueryDestination.newBuilder().setOutputUri(outputUri).build();
      BatchPredictOutputConfig outputConfig =
          BatchPredictOutputConfig.newBuilder().setBigqueryDestination(bigQueryDestination).build();

      // Build the request that will be sent to the API
      BatchPredictRequest request =
          BatchPredictRequest.newBuilder()
              .setName(name.toString())
              .setInputConfig(inputConfig)
              .setOutputConfig(outputConfig)
              .build();

      // Start an asynchronous request
      OperationFuture<BatchPredictResult, OperationMetadata> future =
          client.batchPredictAsync(request);

      System.out.println("Waiting for operation to complete...");
      future.get();
      System.out.println("Batch Prediction results saved to BigQuery.");
    }
  }
}

Node.js

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細


/**
 * Demonstrates using the AutoML client to request prediction from
 * automl tables using bigQuery.
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
// const computeRegion = '[REGION_NAME]' e.g., "us-central1";
// const modelId = '[MODEL_ID]' e.g., "TBL4704590352927948800";
// const inputUri = '[BIGQUERY_PATH]'
// e.g., "bq://<project_id>.<dataset_id>.<table_id>",
// `The Big Query URI containing the inputs`;
// const outputUri = '[BIGQUERY_PATH]' e.g., "bq://<project_id>",
// `The destination Big Query URI for storing outputs`;

const automl = require('@google-cloud/automl');

// Create client for prediction service.
const automlClient = new automl.v1beta1.PredictionServiceClient();

// Get the full path of the model.
const modelFullId = automlClient.modelPath(projectId, computeRegion, modelId);

async function batchPredict() {
  // Construct request
  // Get the Big Query input URI.
  const inputConfig = {
    bigquerySource: {
      inputUri: inputUri,
    },
  };

  // Get the Big Query output URI.
  const outputConfig = {
    bigqueryDestination: {
      outputUri: outputUri,
    },
  };

  const [, operation] = await automlClient.batchPredict({
    name: modelFullId,
    inputConfig: inputConfig,
    outputConfig: outputConfig,
  });

  // Get the latest state of long-running operation.
  console.log(`Operation name: ${operation.name}`);
}

batchPredict();

Python

AutoML Tables のクライアント ライブラリには、AutoML Tables API を簡単に使用できるようにする追加の Python メソッドが含まれています。これらのメソッドは、ID ではなく名前でデータセットとモデルを参照します。データセット名とモデル名は一意である必要があります。詳細については、クライアント リファレンスをご覧ください。

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細

# TODO(developer): Uncomment and set the following variables
# project_id = 'PROJECT_ID_HERE'
# compute_region = 'COMPUTE_REGION_HERE'
# model_display_name = 'MODEL_DISPLAY_NAME_HERE'
# bq_input_uri = 'bq://my-project.my-dataset.my-table'
# bq_output_uri = 'bq://my-project'
# params = {}

from google.cloud import automl_v1beta1 as automl

client = automl.TablesClient(project=project_id, region=compute_region)

# Query model
response = client.batch_predict(
    bigquery_input_uri=bq_input_uri,
    bigquery_output_uri=bq_output_uri,
    model_display_name=model_display_name,
    params=params,
)
print("Making batch prediction... ")
# `response` is a async operation descriptor,
# you can register a callback for the operation to complete via `add_done_callback`:
# def callback(operation_future):
#   result = operation_future.result()
# response.add_done_callback(callback)
#
# or block the thread polling for the operation's results:
response.result()
# AutoML puts predictions in a newly generated dataset with a name by a mask "prediction_" + model_id + "_" + timestamp
# here's how to get the dataset name:
dataset_name = (
    response.metadata.batch_predict_details.output_info.bigquery_output_dataset
)

print(
    "Batch prediction complete.\nResults are in '{}' dataset.\n{}".format(
        dataset_name, response.metadata
    )
)

Cloud Storage の CSV ファイルの使用

入力データの列名とデータ型は、トレーニング データで使用したデータと一致する必要があります。列の順序とトレーニング データの順序は異なっていても構いません。

CSV ファイルの要件

  • データソースの最初の行に列名を含める必要があります。
  • 各データソース ファイルは 10 GB 以下でなければなりません。

    最大サイズの 100 GB に達するまで、複数のファイルを含められます。

  • Cloud Storage バケットは、バケットの要件に準拠している必要があります。

  • Cloud Storage バケットが AutoML Tables とは異なるプロジェクトにある場合、そのプロジェクトの AutoML Tables サービス アカウントに Storage Object Creator 役割を指定する必要があります。詳細

Console

  1. Google Cloud Console で [AutoML テーブル] ページに移動します。

    [AutoML テーブル] ページに移動

  2. [モデル] を選択し、使用するモデルを開きます。

  3. [テストと使用] タブを選択します。

  4. [バッチ予測] をクリックします。

  5. [入力データセット] で [Cloud Storage の CSV] を選択し、データソースのバケット URI を入力します。

  6. [結果] で [Cloud Storage バケット] を選択し、転送先バケットのバケット URI を入力します。

  7. 各特徴が予測に及ぼす影響を確認するには、[特徴量の重要度を生成] を選択します。

    特徴量の重要度を生成すると、予測に必要な時間とコンピューティング リソースが増加します。ローカル特徴量の重要度は、Cloud Storage の結果の格納先では使用できません。

  8. [バッチ予測を送信] をクリックし、バッチ予測をリクエストします。

    AutoML Tables の [バッチ予測] ページ

REST

バッチ予測をリクエストするには、models.batchPredict メソッドを使用します。

リクエストのデータを使用する前に、次のように置き換えます。

  • endpoint: グローバル ロケーションの場合は automl.googleapis.com、EU リージョンの場合は eu-automl.googleapis.com
  • project-id: Google Cloud プロジェクト ID
  • location:リソースのロケーション:グローバルの場合はus-central1、EUの場合はeu
  • model-id:モデルの ID。例: TBL543
  • input-bucket-name: 予測データが配置されている Cloud Storage バケットの名前。
  • input-directory-name: 予測データが配置されている Cloud Storage ディレクトリの名前。
  • object-name: 予測データが配置されている Cloud Storage オブジェクトの名前。
  • output-bucket-name: 予測結果の Cloud Storage バケットの名前。
  • output-directory-name: 予測結果の Cloud Storage ディレクトリの名前。

    AutoML Tables は、prediction-<model_name>-<timestamp> という名前の予測結果のサブフォルダを gs://output-bucket-name/output-directory-name に作成します。このパスへの書き込み権限が必要です。

HTTP メソッドと URL:

POST https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict

JSON 本文のリクエスト:

{
  "inputConfig": {
    "gcsSource": {
      "inputUris": [
        "gs://input-bucket-name/input-directory-name/object-name.csv"
      ]
    },
  },
  "outputConfig": {
    "gcsDestination": {
      "outputUriPrefix": "gs://output-bucket-name/output-directory-name"
     },
  },
}

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict"

PowerShell

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://endpoint/v1beta1/projects/project-id/locations/location/models/model-id:batchPredict" | Select-Object -Expand Content
バッチ予測は長時間実行オペレーションです。オペレーションのステータスをポーリングするか、オペレーションが完了するまで待つことができます。詳細

ローカル特徴量の重要度を取得するには、リクエスト データに feature_importance パラメータを追加します。詳しくは、ローカル特徴量の重要度をご覧ください。

Java

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.automl.v1beta1.BatchPredictInputConfig;
import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig;
import com.google.cloud.automl.v1beta1.BatchPredictRequest;
import com.google.cloud.automl.v1beta1.BatchPredictResult;
import com.google.cloud.automl.v1beta1.GcsDestination;
import com.google.cloud.automl.v1beta1.GcsSource;
import com.google.cloud.automl.v1beta1.ModelName;
import com.google.cloud.automl.v1beta1.OperationMetadata;
import com.google.cloud.automl.v1beta1.PredictionServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

abstract class BatchPredict {

  static void batchPredict() throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String inputUri = "gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl";
    String outputUri = "gs://YOUR_BUCKET_ID/path_to_save_results/";
    batchPredict(projectId, modelId, inputUri, outputUri);
  }

  static void batchPredict(String projectId, String modelId, String inputUri, String outputUri)
      throws IOException, ExecutionException, InterruptedException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PredictionServiceClient client = PredictionServiceClient.create()) {
      // Get the full path of the model.
      ModelName name = ModelName.of(projectId, "us-central1", modelId);

      // Configure the source of the file from a GCS bucket
      GcsSource gcsSource = GcsSource.newBuilder().addInputUris(inputUri).build();
      BatchPredictInputConfig inputConfig =
          BatchPredictInputConfig.newBuilder().setGcsSource(gcsSource).build();

      // Configure where to store the output in a GCS bucket
      GcsDestination gcsDestination =
          GcsDestination.newBuilder().setOutputUriPrefix(outputUri).build();
      BatchPredictOutputConfig outputConfig =
          BatchPredictOutputConfig.newBuilder().setGcsDestination(gcsDestination).build();

      // Build the request that will be sent to the API
      BatchPredictRequest request =
          BatchPredictRequest.newBuilder()
              .setName(name.toString())
              .setInputConfig(inputConfig)
              .setOutputConfig(outputConfig)
              .build();

      // Start an asynchronous request
      OperationFuture<BatchPredictResult, OperationMetadata> future =
          client.batchPredictAsync(request);

      System.out.println("Waiting for operation to complete...");
      future.get();
      System.out.println("Batch Prediction results saved to specified Cloud Storage bucket.");
    }
  }
}

Node.js

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細


/**
 * Demonstrates using the AutoML client to request prediction from
 * automl tables using GCS.
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
// const computeRegion = '[REGION_NAME]' e.g., "us-central1";
// const modelId = '[MODEL_ID]' e.g., "TBL4704590352927948800";
// const inputUri = '[GCS_PATH]' e.g., "gs://<bucket-name>/<csv file>",
// `The Google Cloud Storage URI containing the inputs`;
// const outputUriPrefix = '[GCS_PATH]'
// e.g., "gs://<bucket-name>/<folder-name>",
// `The destination Google Cloud Storage URI for storing outputs`;

const automl = require('@google-cloud/automl');

// Create client for prediction service.
const automlClient = new automl.v1beta1.PredictionServiceClient();

// Get the full path of the model.
const modelFullId = automlClient.modelPath(projectId, computeRegion, modelId);

async function batchPredict() {
  // Construct request
  const inputConfig = {
    gcsSource: {
      inputUris: [inputUri],
    },
  };

  // Get the Google Cloud Storage output URI.
  const outputConfig = {
    gcsDestination: {
      outputUriPrefix: outputUriPrefix,
    },
  };

  const [, operation] = await automlClient.batchPredict({
    name: modelFullId,
    inputConfig: inputConfig,
    outputConfig: outputConfig,
  });

  // Get the latest state of long-running operation.
  console.log(`Operation name: ${operation.name}`);
  return operation;
}

batchPredict();

Python

AutoML Tables のクライアント ライブラリには、AutoML Tables API を簡単に使用できるようにする追加の Python メソッドが含まれています。これらのメソッドは、ID ではなく名前でデータセットとモデルを参照します。データセット名とモデル名は一意である必要があります。詳細については、クライアント リファレンスをご覧ください。

リソースが EU リージョンにある場合は、エンドポイントを明示的に設定する必要があります。詳細

# TODO(developer): Uncomment and set the following variables
# project_id = 'PROJECT_ID_HERE'
# compute_region = 'COMPUTE_REGION_HERE'
# model_display_name = 'MODEL_DISPLAY_NAME_HERE'
# gcs_input_uri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv'
# gcs_output_uri = 'gs://YOUR_BUCKET_ID/path_to_save_results/'
# params = {}

from google.cloud import automl_v1beta1 as automl

client = automl.TablesClient(project=project_id, region=compute_region)

# Query model
response = client.batch_predict(
    gcs_input_uris=gcs_input_uri,
    gcs_output_uri_prefix=gcs_output_uri,
    model_display_name=model_display_name,
    params=params,
)
print("Making batch prediction... ")
# `response` is a async operation descriptor,
# you can register a callback for the operation to complete via `add_done_callback`:
# def callback(operation_future):
#   result = operation_future.result()
# response.add_done_callback(callback)
#
# or block the thread polling for the operation's results:
response.result()

print(f"Batch prediction complete.\n{response.metadata}")

結果の取得

BigQuery での予測結果の取得

BigQuery を出力先に指定した場合、バッチ予測リクエストの結果は、指定した BigQuery プロジェクトの新しいデータセットとして返されます。BigQuery データセットは、先頭に「prediction_」が追加され、予測ジョブの開始時のタイムスタンプが付加されたモデルの名前です。BigQuery データセット名は、モデルの [テストと使用] タブの [バッチ予測] ページにある [最近の予測] で確認できます。

BigQuery データセットには、2 つのテーブル predictionserrors があります。errors テーブルには、AutoML Tables が予測を返せなかった予測リクエストの行ごとに 1 行があります(null 値を許容しない特徴が null であった場合など)。predictions テーブルには、返されたすべての予測の行が含まれています。

predictions テーブルでは、AutoML Tables が予測データを返し、予測結果の新しい列を作成します。ターゲット列名の先頭には「predicted_」が追加されます。予測結果列には、予測結果を格納するネストされた BigQuery 構造が含まれます。

予測結果を取得するには、BigQuery コンソールでクエリを使用します。クエリの形式は、モデルタイプによって異なります。

バイナリ分類:

SELECT predicted_<target-column-name>[OFFSET(0)].tables AS value_1,
predicted_<target-column-name>[OFFSET(1)].tables AS value_2
FROM <bq-dataset-name>.predictions

「value_1」と「value_2」はプレイス マーカーで、ターゲット値または同等の値に置き換えることができます。

マルチクラス分類:

SELECT predicted_<target-column-name>[OFFSET(0)].tables AS value_1,
predicted_<target-column-name>[OFFSET(1)].tables AS value_2,
predicted_<target-column-name>[OFFSET(2)].tables AS value_3,
...
predicted_<target-column-name>[OFFSET(4)].tables AS value_5
FROM <bq-dataset-name>.predictions

「value_1」、「value_2」などの値はプレイス マーカーであり、ターゲット値または同等の値に置き換えることができます。

回帰:

SELECT predicted_<target-column-name>[OFFSET(0)].tables.value,
predicted_<target-column-name>[OFFSET(0)].tables.prediction_interval.start,
predicted_<target-column-name>[OFFSET(0)].tables.prediction_interval.end
FROM <bq-dataset-name>.predictions

Cloud Storage での結果の取得

Cloud Storage を出力先に指定した場合、バッチ予測リクエストの結果は、指定したバケット内の新しいフォルダに CSV ファイルとして返されます。フォルダの名前は、先頭に「prediction-」が追加され、予測ジョブの開始時のタイムスタンプが付加されたモデルの名前です。Cloud Storage フォルダ名は、モデルの [テストと使用] タブの [バッチ予測] ページの下部にある [最近の予測] で確認できます。

Cloud Storage フォルダには、エラーファイルと予測ファイルの 2 種類のファイルが格納されます。結果が大きい場合は、追加のファイルが作成されます。

エラーファイルの名前は、errors_1.csverrors_2.csv などです。ヘッダー行と、AutoML Tables が予測を返せなかった予測リクエストの行ごとに 1 行が含まれます。

予測ファイルの名前は、tables_1.csvtables_2.csv などです。予測ファイルには、列名が表示されたヘッダー行と返されたすべての予測の行が含まれています。

予測ファイルでは、AutoML Tables が予測データを返し、モデルタイプに応じて予測結果の新しい列が 1 つ以上作成されます。

分類:

ターゲット列の各潜在値に対して、<target-column-name>_<value>_score という列が結果に追加されます。この列には、その値のスコアまたは信頼度の推定値が含まれます。

回帰:

その行の予測値が、predicted_<target-column-name> という列で返されます。CSV 出力の予測間隔は返されません。

ローカル特長量の重要度は、Cloud Storage の結果には使用できません。

結果の解釈

結果をどのように解釈するかは、解決しているビジネス上の問題とデータの分散方法によって異なります。

分類モデルの結果の解釈

分類モデル(バイナリとマルチクラス)の予測結果は、ターゲット列の潜在値ごとに確率スコアを返します。このスコアの使用方法を決定する必要があります。たとえば、提供されたスコアからバイナリ分類を取得するには、しきい値を指定します。「A」と「B」の 2 つのクラスがある場合、「A」のスコアが選択したしきい値より大きい場合は「A」、そうでない場合は「B」と分類します。不均衡なデータセットの場合、しきい値が 100% または 0% に近づくことがあります。

Google Cloud コンソールのモデルの [評価] ページで適合率 / 再現率曲線チャート、受信者操作曲線チャートなど、関連するラベル別の統計情報を使用して、しきい値の変更による評価指標の変化を確認できます。これは、スコア値を使用して予測結果を解釈する最適な方法を判断するのに役立ちます。

回帰モデルの結果の解釈

回帰モデルでは、期待値が返されます。多くの問題では、この値を直接使用できます。予想間隔が返された場合や、範囲がビジネス上の問題に適している場合は、予測間隔を使用することもできます。

ローカル特徴量の重要度の結果の解釈

ローカル特徴量の重要度の結果の解釈については、ローカル特徴量の重要度をご覧ください。

次のステップ