モデル評価の取得を行います。
コードサンプル
Java
AutoML Tables に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.ModelEvaluation;
import com.google.cloud.automl.v1beta1.ModelEvaluationName;
import java.io.IOException;
class GetModelEvaluation {
static void getModelEvaluation() throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR_PROJECT_ID";
String modelId = "YOUR_MODEL_ID";
String modelEvaluationId = "YOUR_MODEL_EVALUATION_ID";
getModelEvaluation(projectId, modelId, modelEvaluationId);
}
// Get a model evaluation
static void getModelEvaluation(String projectId, String modelId, String modelEvaluationId)
throws IOException {
// 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 (AutoMlClient client = AutoMlClient.create()) {
// Get the full path of the model evaluation.
ModelEvaluationName modelEvaluationFullId =
ModelEvaluationName.of(projectId, "us-central1", modelId, modelEvaluationId);
// Get complete detail of the model evaluation.
ModelEvaluation modelEvaluation = client.getModelEvaluation(modelEvaluationFullId);
System.out.format("Model Evaluation Name: %s%n", modelEvaluation.getName());
System.out.format("Model Annotation Spec Id: %s", modelEvaluation.getAnnotationSpecId());
System.out.println("Create Time:");
System.out.format("\tseconds: %s%n", modelEvaluation.getCreateTime().getSeconds());
System.out.format("\tnanos: %s", modelEvaluation.getCreateTime().getNanos() / 1e9);
System.out.format(
"Evalution Example Count: %d%n", modelEvaluation.getEvaluatedExampleCount());
System.out.format(
"Classification Model Evaluation Metrics: %s%n",
modelEvaluation.getClassificationEvaluationMetrics());
System.out.format(
"Video Object Tracking Evaluation Metrics: %s%n",
modelEvaluation.getVideoObjectTrackingEvaluationMetrics());
}
}
}
Python
AutoML Tables に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
# TODO(developer): Uncomment and set the following variables
# project_id = 'PROJECT_ID_HERE'
# compute_region = 'COMPUTE_REGION_HERE'
# model_id = 'MODEL_ID_HERE'
# model_evaluation_id = 'MODEL_EVALUATION_ID_HERE'
from google.cloud import automl_v1beta1 as automl
client = automl.TablesClient()
# Get the full path of the model evaluation.
model_path = client.auto_ml_client.model_path(project_id, compute_region, model_id)
model_evaluation_full_id = f"{model_path}/modelEvaluations/{model_evaluation_id}"
# Get complete detail of the model evaluation.
response = client.get_model_evaluation(
model_evaluation_name=model_evaluation_full_id
)
print(response)
次のステップ
他の Google Cloud プロダクトに関連するコードサンプルの検索およびフィルタ検索を行うには、Google Cloud のサンプルをご覧ください。