本文整理汇总了Java中com.google.api.services.prediction.model.Input类的典型用法代码示例。如果您正苦于以下问题:Java Input类的具体用法?Java Input怎么用?Java Input使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Input类属于com.google.api.services.prediction.model包,在下文中一共展示了Input类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processPrediction
import com.google.api.services.prediction.model.Input; //导入依赖的package包/类
public String processPrediction(String modelId) throws IOException, GeneralSecurityException {
if (!processStatusCheck(modelId).equals("DONE")) {
System.out.println("Prediction Model not ready.... ");
return null;
}
InputStream is = readStorageFile(Constants.GCP_STORAGE_TESTING_FILENAME);
Input input = new Input();
InputInput inputInput = new InputInput();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
String partitionToken = ",";
String tokens[];
String results = "";
while ((line = br.readLine()) != null) {
tokens = line.split(partitionToken);
List<Object> features = new ArrayList<Object>();
for (int i = 1; i < tokens.length; i++ ) {
features.add(tokens[i]);
}
inputInput.setCsvInstance(features);
input.setInput(inputInput);
Output output = client.trainedmodels().predict(Constants.PROJECT_NAME, modelId, input).execute();
String outputStr = output.getOutputLabel();
System.out.println("Input : " + line);
System.out.println("Output : " + outputStr);
results += "Input : " + line + " Output :" + outputStr + "<br>";
}
return results;
}
示例2: getGoogleOutput
import com.google.api.services.prediction.model.Input; //导入依赖的package包/类
private Output getGoogleOutput(String text) throws IOException {
Input input = new Input();
InputInput inputInput = new InputInput();
List<Object> params = Arrays.asList(new Object[]{text});
inputInput.setCsvInstance(params);
input.setInput(inputInput);
Output output =
client.hostedmodels().predict("414649711441", "sample.sentiment", input).execute();
//client.trainedmodels().predict("109973074802", "sentiment", input).execute();
return output;
}