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 )
131 virtual bool print()
const override{
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;
176 node->leftChild = leftChild->
deepCopy();
177 node->leftChild->setParent( node );
182 node->rightChild = rightChild->
deepCopy();
183 node->rightChild->setParent( node );
186 return dynamic_cast<Node*
>(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 <<
"loadParametersFromFile(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 virtual bool clear() override
UINT getClusterLabel() const
UINT getFeatureIndex() const
virtual bool predict_(VectorFloat &x) override
virtual bool predict_(VectorFloat &x) override
Float getThreshold() const
virtual bool resize(const unsigned int size)
virtual bool saveParametersToFile(std::fstream &file) const override
virtual bool loadParametersFromFile(std::fstream &file) override
virtual ~ClusterTreeNode()
virtual bool predict_(VectorFloat &x, VectorFloat &y) override
virtual Node * deepCopy() const override
virtual bool print() const override
virtual bool clear() override
virtual Node * deepCopy() const
virtual bool print() const override