Example usage for org.apache.mahout.classifier.df.builder DecisionTreeBuilder setComplemented

List of usage examples for org.apache.mahout.classifier.df.builder DecisionTreeBuilder setComplemented

Introduction

In this page you can find the example usage for org.apache.mahout.classifier.df.builder DecisionTreeBuilder setComplemented.

Prototype

public void setComplemented(boolean complemented) 

Source Link

Usage

From source file:bigimp.BuildForest.java

License:Apache License

private void buildForest() throws IOException, ClassNotFoundException, InterruptedException {
    // make sure the output path does not exist
    FileSystem ofs = outputPath.getFileSystem(getConf());
    if (ofs.exists(outputPath)) {
        log.error("Output path already exists");
        return;//  ww  w .  j a v a  2s  . c  o m
    }

    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) {
        log.info("Partial Mapred implementation");
        forestBuilder = new PartialBuilder(treeBuilder, dataPath, datasetPath, seed, getConf());
    } else {
        log.info("InMem Mapred implementation");
        forestBuilder = new InMemBuilder(treeBuilder, dataPath, datasetPath, seed, getConf());
    }

    forestBuilder.setOutputDirName(outputPath.getName());

    log.info("Building the forest...");
    long time = System.currentTimeMillis();

    DecisionForest forest = forestBuilder.build(nbTrees);

    time = System.currentTimeMillis() - time;
    log.info("Build Time: {}", DFUtils.elapsedTime(time));
    log.info("Forest num Nodes: {}", forest.nbNodes());
    log.info("Forest mean num Nodes: {}", forest.meanNbNodes());
    log.info("Forest mean max Depth: {}", forest.meanMaxDepth());

    // store the decision forest in the output path
    Path forestPath = new Path(outputPath, "forest.seq");
    log.info("Storing the forest in: {}", forestPath);
    DFUtils.storeWritable(getConf(), forestPath, forest);
}

From source file:com.wsc.myexample.decisionForest.MyBuildForest.java

License:Apache License

private void buildForest() throws IOException, ClassNotFoundException, InterruptedException {

    DecisionTreeBuilder treeBuilder = new DecisionTreeBuilder();
    if (m != null) {
        treeBuilder.setM(m);/*from ww w  . j a v  a 2s.c o  m*/
    }
    treeBuilder.setComplemented(complemented);
    if (minSplitNum != null) {
        treeBuilder.setMinSplitNum(minSplitNum);
    }
    if (minVarianceProportion != null) {
        treeBuilder.setMinVarianceProportion(minVarianceProportion);
    }

    MyTreeBuilder forestBuilder;

    //    Dataset dataset,int numTrees,String i_data

    forestBuilder = new MyTreeBuilder(seed, treeBuilder, dataPath, datasetPath, nbTrees);

    //    if (isPartial) {
    //      log.info("Partial Mapred implementation");
    //      forestBuilder = new forestBuilder(treeBuilder, dataPath, datasetPath, seed, getConf());
    //    } else {
    //      log.info("InMem Mapred implementation");
    //      forestBuilder = new InMemBuilder(treeBuilder, dataPath, datasetPath, seed, getConf());
    //    }

    log.info("Building the forest...");
    long time = System.currentTimeMillis();

    //    int splitNum = 1;
    MyDecisionForest forest = forestBuilder.buildTree(outputPath);

    time = System.currentTimeMillis() - time;
    log.info("Build Time: {}", MyDFUtils.elapsedTime(time));
    log.info("Forest num Nodes: {}", forest.nbNodes());
    log.info("Forest mean num Nodes: {}", forest.meanNbNodes());
    log.info("Forest mean max Depth: {}", forest.meanMaxDepth());

    // store the decision forest in the output path
    //    Path forestPath = new Path(outputPath, "forest.seq");
    //    log.info("Storing the forest in: {}", forestPath);
    //    DFUtils.storeWritable(getConf(), forestPath, forest);
}