-1
有人可以幫助我提供實時預測模型的api名稱。請注意,我沒有請求RealtimeEndpointRequest對象。我已經瀏覽了AWS Machine Learning SDK的整個文檔,但沒有發現任何內容。JAVA AWS機器學習API支持實時預測
編輯1: 這是我使用的代碼 -
CreateRealTimePrediction createRealTimePrediction ;
CreateRealtimeEndpointRequest createRealtimeEndPointReq;
CreateRealtimeEndpointResult createRealtimeEndPointRes;
PredictRequest predReq;
String mlModelId="ml-Lkqmcs8cM2W";
createRealtimeEndPointReq.setMLModelId(mlModelId);
PredictResult predRes = null;
Map<String,String> record=null;
// assume i have set a record in the Map.
createRealtimeEndPointRes = amlClient.createRealtimeEndpoint(createRealtimeEndPointReq);
String predictEndpoint=createRealtimeEndPointRes.getRealtimeEndpointInfo().getEndpointUrl();
predReq= new PredictRequest();
predReq.setMLModelId(mlModelId);
for (int i=0;i<recordKeys.length;i++){
record.put(recordKeys[i],recordValues[i]);
}
predReq.setRecord(record);
predReq.setPredictEndpoint(predictEndpoint);
predRes=amlClient.predict(predReq);
return predRes;
}
現在正在發生的事情是 - 如果我通過手動使用AWS管理控制檯啓用實時預測,然後運行該段的代碼,然後將結果產生如預期,但是當我實時預測被禁止,則我得到這個錯誤 -
Exception in thread "main" com.amazonaws.services.machinelearning.model.PredictorNotMountedException: Either ML Model with id ml-Lkqmcs8
cM2W is not enabled for real-time predictions or the MLModelId is invalid. (Service: AmazonMachineLearning; Status Code: 400; Error Code
: PredictorNotMountedException; Request ID: 2dc70e58-07d0-11e5-a0c7-bb93f17d1b2e)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1160)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:748)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:467)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:302)
at com.amazonaws.services.machinelearning.AmazonMachineLearningClient.invoke(AmazonMachineLearningClient.java:1995)
at com.amazonaws.services.machinelearning.AmazonMachineLearningClient.predict(AmazonMachineLearningClient.java:637)
at com.nrift.aml.prediction.realtime.CreateRealTimePrediction.createRealTimePrediction(CreateRealTimePrediction.java:61)
at RealTimePrediction.main(RealTimePrediction.java:53)
這實際上意味着這個代碼段是不啓用實時預測,雖然我已經使用
CreateRealtimeEndpoint
api在裏面。
P.s-我發佈的代碼段是不完整的,完整的代碼工作正常,因此您可以對代碼的正確性做出假設。
請參閱編輯1中的問題,我已經添加了一些更多的細節。 –