コード例 #1
0
ファイル: AzRgfTree.cpp プロジェクト: ZhuZhiMing/RGF_Hadoop
/*--------------------------------------------------------*/
void AzRgfTree::findSplit(AzRgf_FindSplit *fs, 
                          const AzRgf_FindSplit_input &inp, 
                          bool doRefreshAll, 
                          /*---  output  ---*/
                          AzTrTsplit *best_split) const 
{
  const char *eyec = "AzRgfTree::findSplit"; 
  if (nodes_used <= 0) {
    return; 
  }

  AzTrTree::_checkNodes(eyec); /*@check whether there is node, ?nodes_used*/

  /*@ If the tree already has max_leaf_num leaves, then do nothing*/
  int leaf_num = leafNum(); 
  if (max_leaf_num > 0) {
    if (leaf_num >= max_leaf_num) {
      return;   
    }
  }

  /*@ Begin to search*/
  //@ let fs know about tree(and its number in forest(ensemble)) and data, target, min_soze
  _findSplit_begin(fs, inp);
    

  int nx; //@the index of node
  for (nx = 0; nx < nodes_used; ++nx) {
    if (!nodes[nx].isLeaf()) continue; //@if not lead then next node
    /*---@Check the tree construction rules---*/
    if (max_depth > 0 && nodes[nx].depth >= max_depth) {
      continue;
    }
    if (min_size > 0 && nodes[nx].dxs_num < min_size*2) {
      //continue;@????????
    }
    //printf("%s The best split is%d %d %d\n", eyec, nx, best_split->fx,best_split->nx);

    /*@!!!!really find the split on a node*/
    //std::cout<<"@Allreduce"<<std::endl;
    _findSplit(fs, nx, doRefreshAll); 

    //@ if the best spit for this tree found and stored in split[nx]
    if (split[nx]->fx >= 0 && 
        split[nx]->gain > best_split->gain) {
      //@if it is better than best until now, then
      //@reset the best.
      best_split->reset(split[nx], inp.tx, nx); 
    }
  }                              
  _findSplit_end(fs); 
}
コード例 #2
0
ファイル: AzRgfTree.cpp プロジェクト: NavinManaswi/RGF_Hadoop
/*--------------------------------------------------------*/
void AzRgfTree::findSplit(AzRgf_FindSplit *fs, 
                          const AzRgf_FindSplit_input &inp, 
                          bool doRefreshAll, 
                          /*---  output  ---*/
                          AzTrTsplit *best_split) const 
{
  const char *eyec = "AzRgfTree::findSplit"; 
  if (nodes_used <= 0) {
    return; 
  }

  AzTrTree::_checkNodes(eyec); 
  int leaf_num = leafNum(); 
  if (max_leaf_num > 0) {
    if (leaf_num >= max_leaf_num) {
      return;   
    }
  }

  _findSplit_begin(fs, inp); 

  int nx; 
  for (nx = 0; nx < nodes_used; ++nx) {
    if (!nodes[nx].isLeaf()) continue; 

    /*---  ---*/
    if (max_depth > 0 && nodes[nx].depth >= max_depth) {
      continue; 
    }
    if (min_size > 0 && nodes[nx].dxs_num < min_size*2) {
      continue; 
    }

    _findSplit(fs, nx, doRefreshAll); 

    if (split[nx]->fx >= 0 && 
        split[nx]->gain > best_split->gain) {
      best_split->reset(split[nx], inp.tx, nx); 
    }
  }                              
  _findSplit_end(fs); 
}