/** * Evaluate the regression tree over an instance. */ public int predict(double[] x, double[] posteriori) { if (trueChild == null && falseChild == null) { System.arraycopy(this.posteriori, 0, posteriori, 0, k); return output; } else { if (attributes[splitFeature].getType() == Attribute.Type.NOMINAL) { if (x[splitFeature] == splitValue) { return trueChild.predict(x, posteriori); } else { return falseChild.predict(x, posteriori); } } else if (attributes[splitFeature].getType() == Attribute.Type.NUMERIC) { if (x[splitFeature] <= splitValue) { return trueChild.predict(x, posteriori); } else { return falseChild.predict(x, posteriori); } } else { throw new IllegalStateException("Unsupported attribute type: " + attributes[splitFeature].getType()); } } } }
/** * Evaluate the regression tree over an instance. */ public int predict(double[] x) { if (trueChild == null && falseChild == null) { return output; } else { if (attributes[splitFeature].getType() == Attribute.Type.NOMINAL) { if (x[splitFeature] == splitValue) { return trueChild.predict(x); } else { return falseChild.predict(x); } } else if (attributes[splitFeature].getType() == Attribute.Type.NUMERIC) { if (x[splitFeature] <= splitValue) { return trueChild.predict(x); } else { return falseChild.predict(x); } } else { throw new IllegalStateException("Unsupported attribute type: " + attributes[splitFeature].getType()); } } }
/** * Predicts the class label of an instance and also calculate a posteriori * probabilities. The posteriori estimation is based on sample distribution * in the leaf node. It is not accurate at all when be used in a single tree. * It is mainly used by RandomForest in an ensemble way. */ @Override public int predict(double[] x, double[] posteriori) { return root.predict(x, posteriori); }
@Override public int predict(double[] x) { return root.predict(x); }