Package org.apache.mahout.classifier.df.builder

Examples of org.apache.mahout.classifier.df.builder.DecisionTreeBuilder


    if (ofs.exists(outputPath)) {
      log.error("Output path already exists");
      return;
    }

    DecisionTreeBuilder treeBuilder = new DecisionTreeBuilder();
    if (m != null) {
      treeBuilder.setM(m);
    }
    treeBuilder.setComplemented(complemented);
    if (minSplitNum != null) {
      treeBuilder.setMinSplitNum(minSplitNum);
    }
    if (minVarianceProportion != null) {
      treeBuilder.setMinVarianceProportion(minVarianceProportion);
    }
   
    Builder forestBuilder;
   
    if (isPartial) {
View Full Code Here


 
  private DecisionForest buildForest(Data[] datas) {
    List<Node> trees = Lists.newArrayList();
    for (Data data : datas) {
      // build tree
      DecisionTreeBuilder builder = new DecisionTreeBuilder();
      builder.setM(data.getDataset().nbAttributes() - 1);
      builder.setMinSplitNum(0);
      builder.setComplemented(false);
      trees.add(builder.build(rng, data));
    }
    return new DecisionForest(trees);
  }
View Full Code Here

  }
 
  @Test
  public void testTreeVisualize() throws Exception {
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    builder.setM(data.getDataset().nbAttributes() - 1);
    Node tree = builder.build(rng, data);
   
    assertEquals("\noutlook = rainy\n|   windy = FALSE : yes\n|   windy = TRUE : no\n"
            + "outlook = sunny\n|   humidity < 85 : yes\n|   humidity >= 85 : no\n"
            + "outlook = overcast : yes", TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES));
  }
View Full Code Here

  }
 
  @Test
  public void testPredictTrace() throws Exception {
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    builder.setM(data.getDataset().nbAttributes() - 1);
    Node tree = builder.build(rng, data);
   
    String[] prediction = TreeVisualizer.predictTrace(tree, testData,
        ATTR_NAMES);
    Assert.assertArrayEquals(new String[] {
        "outlook = rainy -> windy = TRUE -> no", "outlook = overcast -> yes",
View Full Code Here

      }
    }
    Data lessData = new Data(data.getDataset(), instances);
   
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    builder.setM(data.getDataset().nbAttributes() - 1);
    builder.setMinSplitNum(0);
    builder.setComplemented(false);
    Node tree = builder.build(rng, lessData);

    assertEquals("\noutlook = sunny\n|   humidity < 85 : yes\n|   humidity >= 85 : no\noutlook = overcast : yes", TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES));
  }
View Full Code Here

  @Test
  public void testEmpty() throws Exception {
    Data emptyData = new Data(data.getDataset());
   
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    Node tree = builder.build(rng, emptyData);

    assertEquals(" : unknown", TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES));
  }
View Full Code Here

    if (ofs.exists(outputPath)) {
      log.error("Output path already exists");
      return;
    }

    DecisionTreeBuilder treeBuilder = new DecisionTreeBuilder();
    if (m != null) {
      treeBuilder.setM(m);
    }
    treeBuilder.setComplemented(complemented);
    if (minSplitNum != null) {
      treeBuilder.setMinSplitNum(minSplitNum);
    }
    if (minVarianceProportion != null) {
      treeBuilder.setMinVarianceProportion(minVarianceProportion);
    }
   
    Builder forestBuilder;
   
    if (isPartial) {
View Full Code Here

    if (ofs.exists(outputPath)) {
      log.error("Output path already exists");
      return;
    }

    DecisionTreeBuilder treeBuilder = new DecisionTreeBuilder();
    if (m != null) {
      treeBuilder.setM(m);
    }
    treeBuilder.setComplemented(complemented);
    if (minSplitNum != null) {
      treeBuilder.setMinSplitNum(minSplitNum);
    }
    if (minVarianceProportion != null) {
      treeBuilder.setMinVarianceProportion(minVarianceProportion);
    }
   
    Builder forestBuilder;
   
    if (isPartial) {
View Full Code Here

  }
 
  @Test
  public void testTreeVisualize() throws Exception {
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    builder.setM(data.getDataset().nbAttributes() - 1);
    Node tree = builder.build(rng, data);
   
    assertEquals(TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES),
      "\noutlook = rainy\n|   windy = FALSE : yes\n|   windy = TRUE : no\n"
        + "outlook = sunny\n|   humidity < 85 : yes\n|   humidity >= 85 : no\n"
        + "outlook = overcast : yes");
View Full Code Here

  }
 
  @Test
  public void testPredictTrace() throws Exception {
    // build tree
    DecisionTreeBuilder builder = new DecisionTreeBuilder();
    builder.setM(data.getDataset().nbAttributes() - 1);
    Node tree = builder.build(rng, data);
   
    String[] prediction = TreeVisualizer.predictTrace(tree, testData, ATTR_NAMES);
    Assert.assertArrayEquals(prediction, new String[] {
      "outlook = rainy -> windy = TRUE -> no", "outlook = overcast -> yes",
      "outlook = sunny -> (humidity = 90) >= 85 -> no"});
View Full Code Here

TOP

Related Classes of org.apache.mahout.classifier.df.builder.DecisionTreeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.