MCPcopy Create free account
hub / github.com/ddf-project/DDF / predict

Method predict

spark/src/main/java/io/ddf/spark/ml/Model.java:16–32  ·  view source on GitHub ↗
(double[] point)

Source from the content-addressed store, hash-verified

14 }
15
16 @Override
17 public Double predict(double[] point) throws DDFException {
18 MLClassMethods.PredictMethod predictMethod= new MLClassMethods.PredictMethod(this.getRawModel(), MLClassMethods.DEFAULT_PREDICT_METHOD_NAME,
19 new Class<?>[]{Vector.class});
20 if(predictMethod.getMethod() == null) {
21 throw new DDFException(String.format("Cannot locate method specified by %s", MLClassMethods.DEFAULT_PREDICT_METHOD_NAME));
22
23 }
24 Object prediction = predictMethod.instanceInvoke(Vectors.dense(point));
25 if(prediction instanceof Double) {
26 return (Double) prediction;
27 } else if (prediction instanceof Integer) {
28 return ((Integer) prediction).doubleValue();
29 } else {
30 throw new DDFException(String.format("Error getting prediction from model %s", this.getRawModel().getClass().getName()));
31 }
32 }
33}

Callers

nothing calls this directly

Calls 4

getRawModelMethod · 0.95
instanceInvokeMethod · 0.80
getNameMethod · 0.65
getMethodMethod · 0.45

Tested by

no test coverage detected