Examples of RandomForest


Examples of edu.uci.jforestsx.learning.trees.decision.RandomForest

    } else if (name.equals("RegressionTree")) {
      RegressionTreeLearner learner = new RegressionTreeLearner();
      learner.init(trainDataset, configHolder, maxNumTrainInstances);
      return learner;
    } else if (name.equals("RandomForest")) {
      RandomForest learner = new RandomForest();
      learner.init(trainDataset, configHolder, maxNumTrainInstances, maxNumValidInstances, evaluationMetric);
      return learner;
    } else {
      throw new Exception("Unknown algorithm: " + name);
    }
  }
View Full Code Here

Examples of quickml.supervised.classifier.randomForest.RandomForest

       
            TreeBuilder treeBuilder = new TreeBuilder()
                .ignoreAttributeAtNodeProbability(0.7);
            RandomForestBuilder randomForestBuilder = new RandomForestBuilder(treeBuilder)
                .numTrees(50);
            RandomForest randomForest = randomForestBuilder.buildPredictiveModel(instances);

            attributes = AttributesMap.newHashMap() ;
            attributes.put("height",62);
            attributes.put("weight", 201);
            attributes.put("gender", "female");
            Serializable classification = randomForest.getClassificationByMaxProb(attributes);
            System.out.println("Assigned class: " + classification);
       
        }
       
    }
View Full Code Here

Examples of quickml.supervised.classifier.randomForest.RandomForest

        final long startTime = System.currentTimeMillis();
        final DownsamplingClassifier downsamplingClassifier = wb.buildPredictiveModel(instances);

        TreeBuilderTestUtils.serializeDeserialize(downsamplingClassifier);

        RandomForest randomForest = (RandomForest) downsamplingClassifier.wrappedClassifier;
        final List<Tree> trees = randomForest.trees;
        final int treeSize = trees.size();
        final int firstTreeNodeSize = trees.get(0).node.size();
        org.testng.Assert.assertTrue(treeSize < 400, "Forest size should be less than 400");
        org.testng.Assert.assertTrue((System.currentTimeMillis() - startTime) < 20000, "Building this node should take far less than 20 seconds");

        final List<Instance<AttributesMap>> newInstances = TreeBuilderTestUtils.getIntegerInstances(1000);
        final DownsamplingClassifier downsamplingClassifier1 = wb.buildPredictiveModel(newInstances);
        final RandomForest newRandomForest = (RandomForest) downsamplingClassifier1.wrappedClassifier;
        org.testng.Assert.assertTrue(downsamplingClassifier == downsamplingClassifier1, "Expect same tree to be updated");
        org.testng.Assert.assertEquals(treeSize, newRandomForest.trees.size(), "Expected same number of trees");
        org.testng.Assert.assertEquals(firstTreeNodeSize, newRandomForest.trees.get(0).node.size(), "Expected same nodes");
    }
View Full Code Here

Examples of quickml.supervised.classifier.randomForest.RandomForest

        final TreeBuilder tb = new TreeBuilder(new SplitDiffScorer()).splitPredictiveModel("gender", whiteList);
        final RandomForestBuilder rfb = new RandomForestBuilder(tb);
        final SplitOnAttributeClassifierBuilder cpmb = new SplitOnAttributeClassifierBuilder("gender", rfb, 10, 0.1, whiteList, 1);
        final long startTime = System.currentTimeMillis();
        final SplitOnAttributeClassifier splitOnAttributeClassifier = cpmb.buildPredictiveModel(instances);
        final RandomForest randomForest = (RandomForest) splitOnAttributeClassifier.getDefaultPM();

        TreeBuilderTestUtils.serializeDeserialize(randomForest);
        final List<Tree> trees = randomForest.trees;
        final int treeSize = trees.size();
        Assert.assertTrue(treeSize < 400, "Forest size should be less than 400");
View Full Code Here

Examples of quickml.supervised.classifier.randomForest.RandomForest

        final List<Instance<AttributesMap>> instances = TreeBuilderTestUtils.getInstances(1000);
        final PredictiveModelWithDataBuilder<AttributesMap ,SplitOnAttributeClassifier> wb = getWrappedUpdatablePredictiveModelBuilder();
        wb.splitNodeThreshold(1);
        final long startTime = System.currentTimeMillis();
        final SplitOnAttributeClassifier splitOnAttributeClassifier = wb.buildPredictiveModel(instances);
        final RandomForest randomForest = (RandomForest) splitOnAttributeClassifier.getDefaultPM();

        TreeBuilderTestUtils.serializeDeserialize(randomForest);

        final List<Tree> trees = randomForest.trees;
        final int treeSize = trees.size();
        final int firstTreeNodeSize = trees.get(0).node.size();
        Assert.assertTrue(treeSize < 400, "Forest size should be less than 400");
        Assert.assertTrue((System.currentTimeMillis() - startTime) < 20000,"Building this node should take far less than 20 seconds");

        final List<Instance<AttributesMap>> newInstances = TreeBuilderTestUtils.getInstances(1000);
        final SplitOnAttributeClassifier splitOnAttributeClassifier1 = wb.buildPredictiveModel(newInstances);
        final RandomForest newRandomForest = (RandomForest) splitOnAttributeClassifier1.getDefaultPM();
        Assert.assertTrue(splitOnAttributeClassifier == splitOnAttributeClassifier1, "Expect same tree to be updated");
        Assert.assertEquals(treeSize, newRandomForest.trees.size(), "Expected same number of trees");
        Assert.assertNotEquals(firstTreeNodeSize, newRandomForest.trees.get(0).node.size(), "Expected new nodes");
    }
View Full Code Here

Examples of quickml.supervised.classifier.randomForest.RandomForest

    public void simpleBmiTestNoSplit() throws Exception {
        final List<Instance<AttributesMap>> instances = TreeBuilderTestUtils.getInstances(1000);
        final PredictiveModelWithDataBuilder<AttributesMap ,SplitOnAttributeClassifier> wb = getWrappedUpdatablePredictiveModelBuilder();
        final long startTime = System.currentTimeMillis();
        final SplitOnAttributeClassifier splitOnAttributeClassifier = wb.buildPredictiveModel(instances);
        final RandomForest randomForest = (RandomForest) splitOnAttributeClassifier.getDefaultPM();

        TreeBuilderTestUtils.serializeDeserialize(randomForest);

        final List<Tree> trees = randomForest.trees;
        final int treeSize = trees.size();
        final int firstTreeNodeSize = trees.get(0).node.size();
        Assert.assertTrue(treeSize < 400, "Forest size should be less than 400");
        Assert.assertTrue((System.currentTimeMillis() - startTime) < 20000,"Building this node should take far less than 20 seconds");

        final List<Instance<AttributesMap>> newInstances = TreeBuilderTestUtils.getInstances(1000);
        final SplitOnAttributeClassifier splitOnAttributeClassifier1 = wb.buildPredictiveModel(newInstances);
        final RandomForest newRandomForest = (RandomForest) splitOnAttributeClassifier1.getDefaultPM();
        Assert.assertTrue(splitOnAttributeClassifier == splitOnAttributeClassifier1, "Expect same tree to be updated");
        Assert.assertEquals(treeSize, newRandomForest.trees.size(), "Expected same number of trees");
        Assert.assertEquals(firstTreeNodeSize, newRandomForest.trees.get(0).node.size(), "Expected same nodes");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.