File tree 1 file changed +13
-3
lines changed
tables/automl/src/main/java/com/google/cloud/automl/tables/samples 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -109,10 +109,20 @@ public static void predict(
109
109
110
110
PredictResponse response = predictionClient .predict (modelName , examplePayload , params );
111
111
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 ) {
114
114
System .out .println (
115
- "Predicted class score :" + annotationPayload .getClassification ().getScore ());
115
+ String .format (
116
+ "\t Regression 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
+ "\t Classification label: %s\t \t Classification score: %.3f" ,
123
+ annotationPayload .getTables ().getValue ().getStringValue (),
124
+ annotationPayload .getTables ().getScore ()));
125
+ }
116
126
}
117
127
}
118
128
}
You can’t perform that action at this time.
0 commit comments