use of com.google.cloud.aiplatform.v1.ModelEvaluationName in project java-automl by googleapis.
the class GetModelEvaluation method getModelEvaluation.
// Get a model evaluation
static void getModelEvaluation(String projectId, String modelId, String modelEvaluationId) throws IOException {
// 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());
// [END automl_video_object_tracking_get_model_evaluation_beta]
System.out.format("Classification Model Evaluation Metrics: %s%n", modelEvaluation.getClassificationEvaluationMetrics());
// [END automl_video_classification_get_model_evaluation_beta]
// [START automl_video_object_tracking_get_model_evaluation_beta]
System.out.format("Video Object Tracking Evaluation Metrics: %s%n", modelEvaluation.getVideoObjectTrackingEvaluationMetrics());
// [START automl_video_classification_get_model_evaluation_beta]
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationName in project java-aiplatform by googleapis.
the class ModelServiceClientTest method listModelEvaluationSlicesTest.
@Test
public void listModelEvaluationSlicesTest() throws Exception {
ModelEvaluationSlice responsesElement = ModelEvaluationSlice.newBuilder().build();
ListModelEvaluationSlicesResponse expectedResponse = ListModelEvaluationSlicesResponse.newBuilder().setNextPageToken("").addAllModelEvaluationSlices(Arrays.asList(responsesElement)).build();
mockModelService.addResponse(expectedResponse);
ModelEvaluationName parent = ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]");
ListModelEvaluationSlicesPagedResponse pagedListResponse = client.listModelEvaluationSlices(parent);
List<ModelEvaluationSlice> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getModelEvaluationSlicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockModelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListModelEvaluationSlicesRequest actualRequest = ((ListModelEvaluationSlicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationName in project java-aiplatform by googleapis.
the class GetModelEvaluationImageObjectDetectionSample method getModelEvaluationImageObjectDetectionSample.
static void getModelEvaluationImageObjectDetectionSample(String project, String modelId, String evaluationId) throws IOException {
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
String location = "us-central1";
ModelEvaluationName modelEvaluationName = ModelEvaluationName.of(project, location, modelId, evaluationId);
ModelEvaluation modelEvaluation = modelServiceClient.getModelEvaluation(modelEvaluationName);
System.out.println("Get Model Evaluation Image Object Detection Response");
System.out.format("\tName: %s\n", modelEvaluation.getName());
System.out.format("\tMetrics Schema Uri: %s\n", modelEvaluation.getMetricsSchemaUri());
System.out.format("\tMetrics: %s\n", modelEvaluation.getMetrics());
System.out.format("\tCreate Time: %s\n", modelEvaluation.getCreateTime());
System.out.format("\tSlice Dimensions: %s\n", modelEvaluation.getSliceDimensionsList());
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationName in project java-aiplatform by googleapis.
the class GetModelEvaluationSample method getModelEvaluationSample.
static void getModelEvaluationSample(String project, String modelId, String evaluationId) throws IOException {
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
String location = "us-central1";
ModelEvaluationName modelEvaluationName = ModelEvaluationName.of(project, location, modelId, evaluationId);
ModelEvaluation modelEvaluation = modelServiceClient.getModelEvaluation(modelEvaluationName);
System.out.println("Get Model Evaluation Response");
System.out.format("Model Name: %s\n", modelEvaluation.getName());
System.out.format("Metrics Schema Uri: %s\n", modelEvaluation.getMetricsSchemaUri());
System.out.format("Metrics: %s\n", modelEvaluation.getMetrics());
System.out.format("Create Time: %s\n", modelEvaluation.getCreateTime());
System.out.format("Slice Dimensions: %s\n", modelEvaluation.getSliceDimensionsList());
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationName in project java-aiplatform by googleapis.
the class GetModelEvaluationTextClassificationSample method getModelEvaluationTextClassificationSample.
static void getModelEvaluationTextClassificationSample(String project, String modelId, String evaluationId) throws IOException {
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
String location = "us-central1";
ModelEvaluationName modelEvaluationName = ModelEvaluationName.of(project, location, modelId, evaluationId);
ModelEvaluation modelEvaluation = modelServiceClient.getModelEvaluation(modelEvaluationName);
System.out.println("Get Model Evaluation Text Classification Response");
System.out.format("\tModel Name: %s\n", modelEvaluation.getName());
System.out.format("\tMetrics Schema Uri: %s\n", modelEvaluation.getMetricsSchemaUri());
System.out.format("\tMetrics: %s\n", modelEvaluation.getMetrics());
System.out.format("\tCreate Time: %s\n", modelEvaluation.getCreateTime());
System.out.format("\tSlice Dimensions: %s\n", modelEvaluation.getSliceDimensionsList());
}
}
Aggregations