use of com.google.cloud.aiplatform.v1.ModelEvaluation in project java-aiplatform by googleapis.
the class ModelServiceClientTest method listModelEvaluationsTest2.
@Test
public void listModelEvaluationsTest2() throws Exception {
ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build();
ListModelEvaluationsResponse expectedResponse = ListModelEvaluationsResponse.newBuilder().setNextPageToken("").addAllModelEvaluations(Arrays.asList(responsesElement)).build();
mockModelService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListModelEvaluationsPagedResponse pagedListResponse = client.listModelEvaluations(parent);
List<ModelEvaluation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getModelEvaluationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockModelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListModelEvaluationsRequest actualRequest = ((ListModelEvaluationsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.ModelEvaluation in project java-aiplatform by googleapis.
the class ModelServiceClientTest method listModelEvaluationsTest.
@Test
public void listModelEvaluationsTest() throws Exception {
ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build();
ListModelEvaluationsResponse expectedResponse = ListModelEvaluationsResponse.newBuilder().setNextPageToken("").addAllModelEvaluations(Arrays.asList(responsesElement)).build();
mockModelService.addResponse(expectedResponse);
ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
ListModelEvaluationsPagedResponse pagedListResponse = client.listModelEvaluations(parent);
List<ModelEvaluation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getModelEvaluationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockModelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListModelEvaluationsRequest actualRequest = ((ListModelEvaluationsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.ModelEvaluation in project java-aiplatform by googleapis.
the class GetModelEvaluationTextEntityExtractionSample method getModelEvaluationTextEntityExtractionSample.
static void getModelEvaluationTextEntityExtractionSample(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 Entity Extraction 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());
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluation in project java-aiplatform by googleapis.
the class GetModelEvaluationTextSentimentAnalysisSample method getModelEvaluationTextSentimentAnalysisSample.
static void getModelEvaluationTextSentimentAnalysisSample(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 Sentiment Analysis 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());
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluation in project java-aiplatform by googleapis.
the class GetModelEvaluationVideoActionRecognitionSample method getModelEvaluationVideoActionRecognitionSample.
static void getModelEvaluationVideoActionRecognitionSample(String project, String modelId, String evaluationId) throws IOException {
ModelServiceSettings settings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
String location = "us-central1";
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient client = ModelServiceClient.create(settings)) {
ModelEvaluationName name = ModelEvaluationName.of(project, location, modelId, evaluationId);
ModelEvaluation response = client.getModelEvaluation(name);
System.out.format("response: %s\n", response);
}
}
Aggregations