29 #ifndef GRT_CLUSTER_TREE_NODE_HEADER
30 #define GRT_CLUSTER_TREE_NODE_HEADER
32 #include "../../CoreAlgorithms/Tree/Node.h"
42 nodeType =
"ClusterTreeNode";
67 if( x[ featureIndex ] >= threshold )
return true;
87 if( y.size() != 1 ) y.
resize( 1 );
92 if( leftChild == NULL && rightChild == NULL )
97 return rightChild->
predict( x, y );
100 return leftChild->
predict( x, y );
133 std::string tab =
"";
134 for(UINT i=0; i<depth; i++) tab +=
"\t";
136 std::cout << tab <<
"depth: " << depth <<
" nodeSize: " << nodeSize <<
" featureIndex: " << featureIndex <<
" threshold " << threshold <<
" isLeafNode: " << isLeafNode << std::endl;
137 std::cout << tab <<
"ClusterLabel: " << clusterLabel << std::endl;
139 if( leftChild != NULL ){
140 std::cout << tab <<
"LeftChild: " << std::endl;
144 if( rightChild != NULL ){
145 std::cout << tab <<
"RightChild: " << std::endl;
168 node->isLeafNode = isLeafNode;
169 node->nodeSize = nodeSize;
170 node->featureIndex = featureIndex;
171 node->threshold = threshold;
172 node->clusterLabel = clusterLabel;
177 node->leftChild->setParent( node );
183 node->rightChild->setParent( node );
239 bool set(
const UINT nodeSize,
const UINT featureIndex,
const Float threshold,
const UINT clusterLabel){
240 this->nodeSize = nodeSize;
241 this->featureIndex = featureIndex;
242 this->threshold = threshold;
243 this->clusterLabel = clusterLabel;
259 errorLog <<
"saveParametersToFile(fstream &file) - File is not open!" << std::endl;
264 file <<
"NodeSize: " << nodeSize << std::endl;
265 file <<
"FeatureIndex: " << featureIndex << std::endl;
266 file <<
"Threshold: " << threshold << std::endl;
267 file <<
"ClusterLabel: " << clusterLabel << std::endl;
282 errorLog <<
"loadFromFile(fstream &file) - File is not open!" << std::endl;
290 if( word !=
"NodeSize:" ){
291 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find NodeSize header!" << std::endl;
297 if( word !=
"FeatureIndex:" ){
298 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find FeatureIndex header!" << std::endl;
301 file >> featureIndex;
304 if( word !=
"Threshold:" ){
305 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find Threshold header!" << std::endl;
311 if( word !=
"ClusterLabel:" ){
312 errorLog <<
"loadParametersFromFile(fstream &file) - Failed to find ClusterLabel header!" << std::endl;
315 file >> clusterLabel;
330 #endif //GRT_CLUSTER_TREE_NODE_HEADER
UINT getClusterLabel() const
UINT getFeatureIndex() const
virtual bool predict(const VectorFloat &x, VectorFloat &y)
virtual bool print() const
Float getThreshold() const
virtual bool resize(const unsigned int size)
virtual bool predict(const VectorFloat &x)
virtual Node * deepCopyNode() const
bool set(const UINT nodeSize, const UINT featureIndex, const Float threshold, const UINT clusterLabel)
virtual ~ClusterTreeNode()
virtual Node * deepCopyNode() const
virtual bool print() const
virtual bool loadParametersFromFile(std::fstream &file)
virtual bool predict(const VectorFloat &x)
virtual bool saveParametersToFile(std::fstream &file) const