use of com.google.cloud.aiplatform.v1.ModelServiceSettings 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());
}
}
}
use of com.google.cloud.aiplatform.v1.ModelServiceSettings 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());
}
}
}
use of com.google.cloud.aiplatform.v1.ModelServiceSettings 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());
}
}
use of com.google.cloud.aiplatform.v1.ModelServiceSettings 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());
}
}
use of com.google.cloud.aiplatform.v1.ModelServiceSettings 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());
}
}
Aggregations