Search in sources :

Example 1 with ModelEvaluationSlice

use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.

the class ListModelEvaluationSliceSample method listModelEvaluationSliceSample.

static void listModelEvaluationSliceSample(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);
        for (ModelEvaluationSlice modelEvaluationSlice : modelServiceClient.listModelEvaluationSlices(modelEvaluationName).iterateAll()) {
            System.out.format("Model Evaluation Slice Name: %s\n", modelEvaluationSlice.getName());
            System.out.format("Metrics Schema Uri: %s\n", modelEvaluationSlice.getMetricsSchemaUri());
            System.out.format("Metrics: %s\n", modelEvaluationSlice.getMetrics());
            System.out.format("Create Time: %s\n", modelEvaluationSlice.getCreateTime());
            Slice slice = modelEvaluationSlice.getSlice();
            System.out.format("Slice Dimensions: %s\n", slice.getDimension());
            System.out.format("Slice Value: %s\n\n", slice.getValue());
        }
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluationSlice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice) Slice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice.Slice) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient) ModelEvaluationSlice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice)

Example 2 with ModelEvaluationSlice

use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.

the class ModelServiceClientTest method listModelEvaluationSlicesTest2.

@Test
public void listModelEvaluationSlicesTest2() throws Exception {
    ModelEvaluationSlice responsesElement = ModelEvaluationSlice.newBuilder().build();
    ListModelEvaluationSlicesResponse expectedResponse = ListModelEvaluationSlicesResponse.newBuilder().setNextPageToken("").addAllModelEvaluationSlices(Arrays.asList(responsesElement)).build();
    mockModelService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    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, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelEvaluationSlicesPagedResponse(com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelEvaluationSlicesPagedResponse) Test(org.junit.Test)

Example 3 with ModelEvaluationSlice

use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice 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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelEvaluationSlicesPagedResponse(com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelEvaluationSlicesPagedResponse) Test(org.junit.Test)

Example 4 with ModelEvaluationSlice

use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.

the class GetModelEvaluationSliceSample method getModelEvaluationSliceSample.

static void getModelEvaluationSliceSample(String project, String modelId, String evaluationId, String sliceId) 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";
        ModelEvaluationSliceName modelEvaluationSliceName = ModelEvaluationSliceName.of(project, location, modelId, evaluationId, sliceId);
        ModelEvaluationSlice modelEvaluationSlice = modelServiceClient.getModelEvaluationSlice(modelEvaluationSliceName);
        System.out.println("Get Model Evaluation Slice Response");
        System.out.format("Model Evaluation Slice Name: %s\n", modelEvaluationSlice.getName());
        System.out.format("Metrics Schema Uri: %s\n", modelEvaluationSlice.getMetricsSchemaUri());
        System.out.format("Metrics: %s\n", modelEvaluationSlice.getMetrics());
        System.out.format("Create Time: %s\n", modelEvaluationSlice.getCreateTime());
        Slice slice = modelEvaluationSlice.getSlice();
        System.out.format("Slice Dimensions: %s\n", slice.getDimension());
        System.out.format("Slice Value: %s\n", slice.getValue());
    }
}
Also used : ModelEvaluationSliceName(com.google.cloud.aiplatform.v1.ModelEvaluationSliceName) ModelEvaluationSlice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice) Slice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice.Slice) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient) ModelEvaluationSlice(com.google.cloud.aiplatform.v1.ModelEvaluationSlice)

Aggregations

ModelEvaluationSlice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice)2 Slice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice.Slice)2 ModelServiceClient (com.google.cloud.aiplatform.v1.ModelServiceClient)2 ListModelEvaluationSlicesPagedResponse (com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelEvaluationSlicesPagedResponse)2 ModelServiceSettings (com.google.cloud.aiplatform.v1.ModelServiceSettings)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ModelEvaluationName (com.google.cloud.aiplatform.v1.ModelEvaluationName)1 ModelEvaluationSliceName (com.google.cloud.aiplatform.v1.ModelEvaluationSliceName)1