@Test public void testClassifyData() throws DescriptorException { Data[] datas = generateTrainingDataA(); DecisionForest forest = buildForest(datas); Data testData = DataLoader.loadData(datas[0].getDataset(), TEST_DATA); double[][] predictions = new double[testData.size()][]; forest.classify(testData, predictions); assertArrayEquals(new double[][]{{1.0, Double.NaN, Double.NaN}, {1.0, 0.0, Double.NaN}, {1.0, 1.0, Double.NaN}}, predictions); }
public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index] == null) { predictions[index] = new double[trees.size()]; } predictions[index][treeId] = tree.classify(data.get(index)); } treeId++; } }
DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index] == null) { predictions[index] = new double[trees.size()]; } predictions[index][treeId] = tree.classify(data.get(index)); } treeId++; } } }
DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index] == null) { predictions[index] = new double[trees.size()]; } predictions[index][treeId] = tree.classify(data.get(index)); } treeId++; } } private  DecisionForest();  DecisionForest(List<Node> trees); }
DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index] == null) { predictions[index] = new double[trees.size()]; } predictions[index][treeId] = tree.classify(data.get(index)); } treeId++; } } private  DecisionForest();  DecisionForest(List<Node> trees); void classify(Data data, double[][] predictions); double classify(Dataset dataset, Random rng, Instance instance); long meanNbNodes(); long nbNodes(); long meanMaxDepth(); @Override boolean equals(Object obj); @Override int hashCode(); @Override void write(DataOutput dataOutput); @Override void readFields(DataInput dataInput); static DecisionForest read(DataInput dataInput); static DecisionForest load(Configuration conf, Path forestPath); }
DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index] == null) { predictions[index] = new double[trees.size()]; } predictions[index][treeId] = tree.classify(data.get(index)); } treeId++; } } private  DecisionForest();  DecisionForest(List<Node> trees); void classify(Data data, double[][] predictions); double classify(Dataset dataset, Random rng, Instance instance); long meanNbNodes(); long nbNodes(); long meanMaxDepth(); @Override boolean equals(Object obj); @Override int hashCode(); @Override void write(DataOutput dataOutput); @Override void readFields(DataInput dataInput); static DecisionForest read(DataInput dataInput); static DecisionForest load(Configuration conf, Path forestPath);  }