5 // Created by Abu Zaher Faridee on 5/29/12.
6 // Copyright (c) 2012 Schloss Lab. All rights reserved.
9 #ifndef rrf_fs_prototype_treenode_hpp
10 #define rrf_fs_prototype_treenode_hpp
12 #include "mothurout.h"
19 RFTreeNode(vector< vector<int> > bootstrappedTrainingSamples, vector<int> globalDiscardedFeatureIndices, int numFeatures, int numSamples, int numOutputClasses, int generation);
21 virtual ~RFTreeNode(){}
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; }
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; }
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;
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;
75 int splitFeatureIndex;
76 int splitFeatureValue;
77 double splitFeatureEntropy;
80 RFTreeNode* leftChildNode;
81 RFTreeNode* rightChildNode;
82 RFTreeNode* parentNode;
86 int createLocalDiscardedFeatureList();
87 int updateNodeEntropy();