Skip to content

Commit c96a357

Browse files
committed
updating api signatures
1 parent 0959e90 commit c96a357

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tables/automl/src/main/java/com/google/cloud/automl/tables/samples/PredictionApi.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,20 @@ public static void predict(
109109

110110
PredictResponse response = predictionClient.predict(modelName, examplePayload, params);
111111
System.out.println("Prediction results:");
112-
for (AnnotationPayload annotationPayload : response.getPayloadList()) {
113-
System.out.println("Predicted class name :" + annotationPayload.getDisplayName());
112+
List<AnnotationPayload> annotationPayloadList = response.getPayloadList();
113+
if (response.getPayloadCount() == 1) {
114114
System.out.println(
115-
"Predicted class score :" + annotationPayload.getClassification().getScore());
115+
String.format(
116+
"\tRegression result: %0.3f",
117+
annotationPayloadList.get(0).getTables().getValue().getNumberValue()));
118+
} else {
119+
for (AnnotationPayload annotationPayload : annotationPayloadList) {
120+
System.out.println(
121+
String.format(
122+
"\tClassification label: %s\t\tClassification score: %.3f",
123+
annotationPayload.getTables().getValue().getStringValue(),
124+
annotationPayload.getTables().getScore()));
125+
}
116126
}
117127
}
118128
}

0 commit comments

Comments
 (0)