@Test public void testReadTree() throws Exception { Node node1 = new CategoricalNode(rng.nextInt(), new double[] { rng.nextDouble(), rng.nextDouble() }, new Node[] { new Leaf(rng.nextDouble()), new Leaf(rng.nextDouble()) }); Node node2 = new NumericalNode(rng.nextInt(), rng.nextDouble(), new Leaf(rng.nextDouble()), new Leaf(rng.nextDouble())); Node root = new CategoricalNode(rng.nextInt(), new double[] { rng.nextDouble(), rng.nextDouble(), rng.nextDouble() }, new Node[] { node1, node2, new Leaf(rng.nextDouble()) }); root.write(out); assertEquals(root, readNode()); }
@Override public final void write(DataOutput out) throws IOException { out.writeInt(getType().ordinal()); writeNode(out); }
Node implements Writable { @Override public final void write(DataOutput out) throws IOException { out.writeInt(getType().ordinal()); writeNode(out); } }
Node implements Writable { @Override public final void write(DataOutput out) throws IOException { out.writeInt(getType().ordinal()); writeNode(out); }  }
Node implements Writable { @Override public final void write(DataOutput out) throws IOException { out.writeInt(getType().ordinal()); writeNode(out); }  abstract double classify(Instance instance); abstract long nbNodes(); abstract long maxDepth(); static Node read(DataInput in); @Override final String toString(); @Override final void write(DataOutput out); }
Node implements Writable { @Override public final void write(DataOutput out) throws IOException { out.writeInt(getType().ordinal()); writeNode(out); }  abstract double classify(Instance instance); abstract long nbNodes(); abstract long maxDepth(); static Node read(DataInput in); @Override final String toString(); @Override final void write(DataOutput out);  }