5 // Created by Abu Zaher Faridee on 5/29/12.
6 // Copyright (c) 2012 Schloss Lab. All rights reserved.
9 #ifndef RF_RFTREENODE_HPP
10 #define RF_RFTREENODE_HPP
12 #include "mothurout.h"
19 RFTreeNode(vector< vector<int> > bootstrappedTrainingSamples,
20 vector<int> globalDiscardedFeatureIndices,
26 float featureStandardDeviationThreshold = 0.0);
28 virtual ~RFTreeNode(){}
31 // we need to return const reference so that we have the actual value and not a copy,
32 // plus we do not modify the value as well
33 const int getSplitFeatureIndex() { return splitFeatureIndex; }
34 // TODO: check if this works properly or returs a shallow copy of the data
35 const vector< vector<int> >& getBootstrappedTrainingSamples() { return bootstrappedTrainingSamples; }
36 const int getSplitFeatureValue() { return splitFeatureValue; }
37 const int getGeneration() { return generation; }
38 const bool checkIsLeaf() { return isLeaf; }
39 // TODO: fix this const pointer dillema
40 // we do not want to modify the data pointer by getLeftChildNode
41 RFTreeNode* getLeftChildNode() { return leftChildNode; }
42 RFTreeNode* getRightChildNode() { return rightChildNode; }
43 const int getOutputClass() { return outputClass; }
44 const int getNumSamples() { return numSamples; }
45 const int getNumFeatures() { return numFeatures; }
46 const vector<int>& getLocalDiscardedFeatureIndices() { return localDiscardedFeatureIndices; }
47 const vector< vector<int> >& getBootstrappedFeatureVectors() { return bootstrappedFeatureVectors; }
48 const vector<int>& getBootstrappedOutputVector() { return bootstrappedOutputVector; }
49 const vector<int>& getFeatureSubsetIndices() { return featureSubsetIndices; }
50 const double getOwnEntropy() { return ownEntropy; }
51 const int getTestSampleMisclassificationCount() { return testSampleMisclassificationCount; }
54 void setIsLeaf(bool isLeaf) { this->isLeaf = isLeaf; }
55 void setOutputClass(int outputClass) { this->outputClass = outputClass; }
56 void setFeatureSubsetIndices(vector<int> featureSubsetIndices) { this->featureSubsetIndices = featureSubsetIndices; }
57 void setLeftChildNode(RFTreeNode* leftChildNode) { this->leftChildNode = leftChildNode; }
58 void setRightChildNode(RFTreeNode* rightChildNode) { this->rightChildNode = rightChildNode; }
59 void setParentNode(RFTreeNode* parentNode) { this->parentNode = parentNode; }
60 void setSplitFeatureIndex(int splitFeatureIndex) { this->splitFeatureIndex = splitFeatureIndex; }
61 void setSplitFeatureValue(int splitFeatureValue) { this->splitFeatureValue = splitFeatureValue; }
62 void setSplitFeatureEntropy(double splitFeatureEntropy) { this->splitFeatureEntropy = splitFeatureEntropy; }
64 // TODO: need to remove this mechanism of friend class
65 //NOTE: friend classes can be useful for testing purposes, but I would avoid using them otherwise.
66 friend class DecisionTree;
67 friend class AbstractDecisionTree;
70 vector<vector<int> > bootstrappedTrainingSamples;
71 vector<int> globalDiscardedFeatureIndices;
72 vector<int> localDiscardedFeatureIndices;
73 vector<vector<int> > bootstrappedFeatureVectors;
74 vector<int> bootstrappedOutputVector;
75 vector<int> featureSubsetIndices;
83 int splitFeatureIndex;
84 int splitFeatureValue;
85 double splitFeatureEntropy;
89 float featureStandardDeviationThreshold;
90 int testSampleMisclassificationCount;
92 RFTreeNode* leftChildNode;
93 RFTreeNode* rightChildNode;
94 RFTreeNode* parentNode;
98 int createLocalDiscardedFeatureList();
99 int updateNodeEntropy();