Пример #1
0
// to classify only down to a certain depth level (for evaluation)
std::vector< float >& Tree::Classify(std::vector< float >& point, int depth)
{
  // get root node and traverse through tree until leaf node is reached
  Node* curNode = GetRootNode();

  for(int d=0; d <= depth && curNode->IsSplitNode(); ++d)
     curNode = &nodes[curNode->EvaluateNode(point)];

  return curNode->GetLabelDistribution();
}
Пример #2
0
int Tree::GetResultingLeafNode(std::vector< float > point)
{
  // get root node and traverse through tree until leaf node is reached
  Node* curNode = GetRootNode();
  
  int idx = rootNodeIdx;
  
  while(curNode->IsSplitNode())
  {
	idx = curNode->EvaluateNode(point);
	curNode = &nodes[idx];      
  }
  
  // return index of leaf node
  return idx;
}