(double[] point)
| 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() { |
nothing calls this directly
no test coverage detected