Last active
December 26, 2015 04:39
-
-
Save Alrecenk/7095311 to your computer and use it in GitHub Desktop.
Bootstrap aggregation for a random forest algorithm.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bootstrap aggregating of training data for a random forest | |
Random rand = new Random(seed); | |
treenode tree[] = new treenode[trees] ; | |
for(int k=0;k<trees;k++){ | |
ArrayList<Datapoint> treedata = new ArrayList<Datapoint>() | |
for (int j = 0; j < datapermodel; j++){ | |
//add a random data point to the training data for this tree | |
int nj = Math.abs(rand.nextInt())%data.size(); | |
treedata.add(alldata.get(nj)) ; | |
} | |
tree[k]=new treenode(treedata,minpoints,maxdepth, featurefraction); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment