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

Method predict

core/src/main/java/io/ddf/ml/Model.java:78–101  ·  view source on GitHub ↗
(double[] point)

Source from the content-addressed store, hash-verified

76 }
77
78 @Override
79 public Double predict(double[] point) throws DDFException {
80
81 PredictMethod predictMethod = new PredictMethod(this.getRawModel(), MLClassMethods.DEFAULT_PREDICT_METHOD_NAME,
82 new Class<?>[] { point.getClass() });
83
84 if (predictMethod.getMethod() == null) {
85 throw new DDFException(String.format("Cannot locate method specified by %s",
86 MLClassMethods.DEFAULT_PREDICT_METHOD_NAME));
87 }
88
89 Object prediction = predictMethod.instanceInvoke(point);
90
91 if (prediction instanceof Double) {
92 return (Double) prediction;
93
94 } else if (prediction instanceof Integer) {
95 return ((Integer) prediction).doubleValue();
96
97 } else {
98 throw new DDFException(String.format("Error getting prediction from model %s", this.getRawModel().getClass()
99 .getName()));
100 }
101 }
102
103 @Override
104 public String toString() {

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