31 #ifndef GRT_DECISION_TREE_NODE_HEADER
32 #define GRT_DECISION_TREE_NODE_HEADER
34 #include "../../CoreAlgorithms/Tree/Node.h"
35 #include "../../CoreAlgorithms/Tree/Tree.h"
36 #include "../../DataStructures/ClassificationData.h"
81 virtual bool computeBestSpilt(
const UINT &trainingMode,
const UINT &numSplittingSteps,
const ClassificationData &trainingData,
const Vector< UINT > &features,
const Vector< UINT > &classLabels, UINT &featureIndex, Float &minError );
98 virtual bool getModel( std::ostream &stream )
const;
121 UINT getNodeSize()
const;
128 UINT getNumClasses()
const;
144 bool setLeafNode(
const UINT nodeSize,
const VectorFloat &classProbabilities );
152 bool setNodeSize(
const UINT nodeSize);
160 bool setClassProbabilities(
const VectorFloat &classProbabilities);
162 static UINT getClassLabelIndexValue(UINT classLabel,
const Vector< UINT > &classLabels);
169 errorLog <<
"computeBestSpiltBestIterativeSpilt(...) - Base class not overwritten!" << std::endl;
176 errorLog <<
"computeBestSpiltBestRandomSpilt(...) - Base class not overwritten!" << std::endl;
190 if( !file.is_open() )
192 errorLog <<
"saveParametersToFile(fstream &file) - File is not open!" << std::endl;
197 file <<
"NodeSize: " << nodeSize << std::endl;
198 file <<
"NumClasses: " << classProbabilities.size() << std::endl;
199 file <<
"ClassProbabilities: ";
200 if( classProbabilities.size() > 0 ){
201 for(UINT i=0; i<classProbabilities.size(); i++){
202 file << classProbabilities[i];
203 if( i < classProbabilities.size()-1 ) file <<
"\t";
204 else file << std::endl;
219 if( !file.is_open() )
221 errorLog <<
"loadParametersFromFile(fstream &file) - File is not open!" << std::endl;
225 classProbabilities.clear();
232 if( word !=
"NodeSize:" ){
233 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find NodeSize header!" << std::endl;
239 if( word !=
"NumClasses:" ){
240 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find NumClasses header!" << std::endl;
245 classProbabilities.
resize( numClasses );
248 if( word !=
"ClassProbabilities:" ){
249 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find ClassProbabilities header!" << std::endl;
252 if( numClasses > 0 ){
253 for(UINT i=0; i<numClasses; i++){
254 file >> classProbabilities[i];
269 #endif //GRT_DECISION_TREE_NODE_HEADER
virtual bool resize(const unsigned int size)
virtual bool getModel(std::ostream &stream) const
virtual Node * deepCopyNode() const
virtual bool saveParametersToFile(std::fstream &file) const
virtual bool loadParametersFromFile(std::fstream &file)
virtual bool predict(const VectorFloat &x)