Search in sources :

Example 11 with ModelEvaluationName

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]
    }
}
Also used : ModelEvaluationName(com.google.cloud.automl.v1beta1.ModelEvaluationName) ModelEvaluation(com.google.cloud.automl.v1beta1.ModelEvaluation) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient)

Example 12 with ModelEvaluationName

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

Example 13 with ModelEvaluationName

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());
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluation(com.google.cloud.aiplatform.v1.ModelEvaluation) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 14 with ModelEvaluationName

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());
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluation(com.google.cloud.aiplatform.v1.ModelEvaluation) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 15 with ModelEvaluationName

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());
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluation(com.google.cloud.aiplatform.v1.ModelEvaluation) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Aggregations

ModelEvaluationName (com.google.cloud.aiplatform.v1.ModelEvaluationName)12 ModelServiceClient (com.google.cloud.aiplatform.v1.ModelServiceClient)12 ModelServiceSettings (com.google.cloud.aiplatform.v1.ModelServiceSettings)12 ModelEvaluation (com.google.cloud.aiplatform.v1.ModelEvaluation)11 ModelEvaluationSlice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice)1 Slice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice.Slice)1 ListModelEvaluationSlicesPagedResponse (com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelEvaluationSlicesPagedResponse)1 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)1 ModelEvaluation (com.google.cloud.automl.v1.ModelEvaluation)1 ModelEvaluationName (com.google.cloud.automl.v1.ModelEvaluationName)1 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)1 ModelEvaluation (com.google.cloud.automl.v1beta1.ModelEvaluation)1 ModelEvaluationName (com.google.cloud.automl.v1beta1.ModelEvaluationName)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 Test (org.junit.Test)1