]> git.donarmstrong.com Git - mothur.git/blob - forest.h
fixes while testing 1.33.0
[mothur.git] / forest.h
1 //
2 //  forest.h
3 //  Mothur
4 //
5 //  Created by Kathryn Iverson on 10/26/12. Modified abstractrandomforest
6 //  Copyright (c) 2012 Schloss Lab. All rights reserved.
7 //
8
9 #ifndef __Mothur__forest__
10 #define __Mothur__forest__
11
12 #include <iostream>
13 #include "mothurout.h"
14 #include "macros.h"
15 #include "decisiontree.hpp"
16 #include "abstractdecisiontree.hpp"
17 /***********************************************************************/
18 //this is a re-implementation of the abstractrandomforest class
19
20 class Forest{
21 public:
22     // intialization with vectors
23     Forest(const std::vector < std::vector<int> > dataSet,
24            const int numDecisionTrees,
25            const string treeSplitCriterion,
26            const bool doPruning,
27            const float pruneAggressiveness,
28            const bool discardHighErrorTrees,
29            const float highErrorTreeDiscardThreshold,
30            const string optimumFeatureSubsetSelectionCriteria,
31            const float featureStandardDeviationThreshold);
32     virtual ~Forest(){ }
33     virtual int populateDecisionTrees() = 0;
34     virtual int calcForrestErrorRate() = 0;
35     virtual int calcForrestVariableImportance(string) = 0;
36     virtual int updateGlobalOutOfBagEstimates(DecisionTree* decisionTree) = 0;
37     
38     /***********************************************************************/
39     
40 protected:
41     
42     // TODO: create a better way of discarding feature
43     // currently we just set FEATURE_DISCARD_SD_THRESHOLD to 0 to solved this
44     // it can be tuned for better selection
45     // also, there might be other factors like Mean or other stuffs
46     // same would apply for createLocalDiscardedFeatureList in the TreeNode class
47     
48     // TODO: Another idea is getting an aggregated discarded feature indices after the run, from combining
49     // the local discarded feature indices
50     // this would penalize a feature, even if in global space the feature looks quite good
51     // the penalization would be averaged, so this woould unlikely to create a local optmina
52     
53     vector<int> getGlobalDiscardedFeatureIndices();
54     
55     int numDecisionTrees;
56     int numSamples;
57     int numFeatures;
58     vector< vector<int> > dataSet;
59     vector<int> globalDiscardedFeatureIndices;
60     vector<double> globalVariableImportanceList;
61     string treeSplitCriterion;
62   
63     bool doPruning;
64     float pruneAggressiveness;
65     bool discardHighErrorTrees;
66     float highErrorTreeDiscardThreshold;
67     string optimumFeatureSubsetSelectionCriteria;
68     float featureStandardDeviationThreshold;
69   
70     // This is a map of each feature to outcome count of each classes
71     // e.g. 1 => [2 7] means feature 1 has 2 outcome of 0 and 7 outcome of 1
72     map<int, vector<int> > globalOutOfBagEstimates;
73     
74     // TODO: fix this, do we use pointers?
75     vector<AbstractDecisionTree*> decisionTrees;
76     
77     MothurOut* m;
78     
79 private:
80     
81 };
82
83 #endif /* defined(__Mothur__forest__) */