Search in sources :

Example 6 with ModelServiceClient

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

the class GetModelSample method getModelSample.

static void getModelSample(String project, String modelId) 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";
        ModelName modelName = ModelName.of(project, location, modelId);
        Model modelResponse = modelServiceClient.getModel(modelName);
        System.out.println("Get Model response");
        System.out.format("\tName: %s\n", modelResponse.getName());
        System.out.format("\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\tPredict Schemata");
        System.out.format("\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\tSupported Export Format");
            System.out.format("\t\tId: %s\n", exportFormat.getId());
        }
        ModelContainerSpec containerSpec = modelResponse.getContainerSpec();
        System.out.println("\tContainer Spec");
        System.out.format("\t\tImage Uri: %s\n", containerSpec.getImageUri());
        System.out.format("\t\tCommand: %s\n", containerSpec.getCommandList());
        System.out.format("\t\tArgs: %s\n", containerSpec.getArgsList());
        System.out.format("\t\tPredict Route: %s\n", containerSpec.getPredictRoute());
        System.out.format("\t\tHealth Route: %s\n", containerSpec.getHealthRoute());
        for (EnvVar envVar : containerSpec.getEnvList()) {
            System.out.println("\t\tEnv");
            System.out.format("\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : containerSpec.getPortsList()) {
            System.out.println("\t\tPort");
            System.out.format("\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\tDeployed Model");
            System.out.format("\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
    }
}
Also used : PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) ModelName(com.google.cloud.aiplatform.v1.ModelName) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) Port(com.google.cloud.aiplatform.v1.Port) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 7 with ModelServiceClient

use of com.google.cloud.aiplatform.v1.ModelServiceClient 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 8 with ModelServiceClient

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

the class GetModelEvaluationImageClassificationSample method getModelEvaluationImageClassificationSample.

static void getModelEvaluationImageClassificationSample(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 Classification 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 9 with ModelServiceClient

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

the class GetModelEvaluationTabularClassificationSample method getModelEvaluationTabularClassification.

static void getModelEvaluationTabularClassification(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 Tabular Classification 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 10 with ModelServiceClient

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

the class GetModelEvaluationTabularRegressionSample method getModelEvaluationTabularRegression.

static void getModelEvaluationTabularRegression(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 Tabular Regression 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)

Aggregations

ModelServiceClient (com.google.cloud.aiplatform.v1.ModelServiceClient)19 ModelServiceSettings (com.google.cloud.aiplatform.v1.ModelServiceSettings)19 ModelEvaluationName (com.google.cloud.aiplatform.v1.ModelEvaluationName)12 ModelEvaluation (com.google.cloud.aiplatform.v1.ModelEvaluation)11 ModelName (com.google.cloud.aiplatform.v1.ModelName)5 ExportModelOperationMetadata (com.google.cloud.aiplatform.v1.ExportModelOperationMetadata)3 ExportModelRequest (com.google.cloud.aiplatform.v1.ExportModelRequest)3 ExportModelResponse (com.google.cloud.aiplatform.v1.ExportModelResponse)3 GcsDestination (com.google.cloud.aiplatform.v1.GcsDestination)3 Model (com.google.cloud.aiplatform.v1.Model)2 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)2 ModelEvaluationSlice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice)2 Slice (com.google.cloud.aiplatform.v1.ModelEvaluationSlice.Slice)2 DeleteOperationMetadata (com.google.cloud.aiplatform.v1.DeleteOperationMetadata)1 DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)1 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)1 LocationName (com.google.cloud.aiplatform.v1.LocationName)1 ExportFormat (com.google.cloud.aiplatform.v1.Model.ExportFormat)1 ModelEvaluationSliceName (com.google.cloud.aiplatform.v1.ModelEvaluationSliceName)1 Port (com.google.cloud.aiplatform.v1.Port)1