Skip to content

Instantly share code, notes, and snippets.

@sanity
Created September 19, 2011 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanity/1226649 to your computer and use it in GitHub Desktop.
Save sanity/1226649 to your computer and use it in GitHub Desktop.
final Set<Instance> instances = Sets.newHashSet();
instances.add(Instance.create("sweat", "weight", 165, "height", 5, "sex", "male"));
instances.add(Instance.create("nosweat", "weight", 121, "height", 4, "sex", "female"));
instances.add(Instance.create("sweat", "weight", 172, "height", 7, "sex", "male"));
instances.add(Instance.create("sweat", "weight", 138, "height", 4, "sex", "female"));
instances.add(Instance.create("sweat", "weight", 152, "height", 5, "sex", "male"));
instances.add(Instance.create("nosweat", "weight", 182, "height", 4, "sex", "female"));
instances.add(Instance.create("nosweat", "weight", 151, "height", 5, "sex", "male"));
instances.add(Instance.create("nosweat", "weight", 124, "height", 6, "sex", "female"));
final TreeBuilder tb = new TreeBuilder();
final Node tree = tb.buildTree(instances, 10, 1.0);
System.out.println("Tree size: " + tree.size());
tree.dump(System.out);
Output:
Tree size: 9
sex in [female]
weight > 124.0
weight > 138.0
[output=nosweat, depth=0, probability=1.0]
weight < 138.0
[output=sweat, depth=0, probability=1.0]
weight < 124.0
[output=nosweat, depth=0, probability=1.0]
sex not in [female]
weight > 151.0
[output=sweat, depth=0, probability=1.0]
weight < 151.0
[output=nosweat, depth=0, probability=1.0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment