]> git.donarmstrong.com Git - mothur.git/blob - rftreenode.hpp
changes while testing
[mothur.git] / rftreenode.hpp
1 //
2 //  rftreenode.hpp
3 //  rrf-fs-prototype
4 //
5 //  Created by Abu Zaher Faridee on 5/29/12.
6 //  Copyright (c) 2012 Schloss Lab. All rights reserved.
7 //
8
9 #ifndef rrf_fs_prototype_treenode_hpp
10 #define rrf_fs_prototype_treenode_hpp
11
12 #include "mothurout.h"
13 #include "macros.h"
14
15 class RFTreeNode{
16     
17 public:
18     
19     RFTreeNode(vector< vector<int> > bootstrappedTrainingSamples, vector<int> globalDiscardedFeatureIndices, int numFeatures, int numSamples, int numOutputClasses, int generation);
20     
21     virtual ~RFTreeNode(){}
22     
23     // getters
24     // we need to return const reference so that we have the actual value and not a copy, 
25     // plus we do not modify the value as well
26     const int getSplitFeatureIndex() { return splitFeatureIndex; }
27     // TODO: check if this works properly or returs a shallow copy of the data
28     const vector< vector<int> >& getBootstrappedTrainingSamples() { return bootstrappedTrainingSamples; }
29     const int getSplitFeatureValue() { return splitFeatureValue; }
30     const int getGeneration() { return generation; }
31     const bool checkIsLeaf() { return isLeaf; }
32     // TODO: fix this const pointer dillema
33     // we do not want to modify the data pointer by getLeftChildNode
34     RFTreeNode* getLeftChildNode() { return leftChildNode; }
35     RFTreeNode* getRightChildNode() { return rightChildNode; }
36     const int getOutputClass() { return outputClass; }
37     const int getNumSamples() { return numSamples; }
38     const int getNumFeatures() { return numFeatures; }
39     const vector<int>& getLocalDiscardedFeatureIndices() { return localDiscardedFeatureIndices; }
40     const vector< vector<int> >& getBootstrappedFeatureVectors() { return bootstrappedFeatureVectors; }
41     const vector<int>& getBootstrappedOutputVector() { return bootstrappedOutputVector; }
42     const vector<int>& getFeatureSubsetIndices() { return featureSubsetIndices; }
43     const double getOwnEntropy() { return ownEntropy; }
44     
45     // setters
46     void setIsLeaf(bool isLeaf) { this->isLeaf = isLeaf; }
47     void setOutputClass(int outputClass) { this->outputClass = outputClass; }
48     void setFeatureSubsetIndices(vector<int> featureSubsetIndices) { this->featureSubsetIndices = featureSubsetIndices; }
49     void setLeftChildNode(RFTreeNode* leftChildNode) { this->leftChildNode = leftChildNode; }
50     void setRightChildNode(RFTreeNode* rightChildNode) { this->rightChildNode = rightChildNode; }
51     void setParentNode(RFTreeNode* parentNode) { this->parentNode = parentNode; }
52     void setSplitFeatureIndex(int splitFeatureIndex) { this->splitFeatureIndex = splitFeatureIndex; }
53     void setSplitFeatureValue(int splitFeatureValue) { this->splitFeatureValue = splitFeatureValue; }
54     void setSplitFeatureEntropy(double splitFeatureEntropy) { this->splitFeatureEntropy = splitFeatureEntropy; }
55     
56     // TODO: need to remove this mechanism of friend class
57     //NOTE: friend classes can be useful for testing purposes, but I would avoid using them otherwise.
58     friend class DecisionTree;
59     friend class AbstractDecisionTree;
60     
61 private:
62     vector<vector<int> > bootstrappedTrainingSamples;
63     vector<int> globalDiscardedFeatureIndices;
64     vector<int> localDiscardedFeatureIndices;
65     vector<vector<int> > bootstrappedFeatureVectors;
66     vector<int> bootstrappedOutputVector;
67     vector<int> featureSubsetIndices;
68
69     int numFeatures;
70     int numSamples;
71     int numOutputClasses;
72     int generation;
73     bool isLeaf;
74     int outputClass;
75     int splitFeatureIndex;
76     int splitFeatureValue;
77     double splitFeatureEntropy;
78     double ownEntropy;
79     
80     RFTreeNode* leftChildNode;
81     RFTreeNode* rightChildNode;
82     RFTreeNode* parentNode;
83     
84     MothurOut* m;
85     
86     int createLocalDiscardedFeatureList();
87     int updateNodeEntropy();
88     
89 };
90
91 #endif