void reset() {
   a_dense.free(&arrd); 
   a_sparse.free(&arrs); 
   f_num = 0; 
   ia_isActive.reset(); 
   active_num = 0;   
 }
 inline void _release() {
   a_tree.free(&t); t_num = 0; 
   s_config.reset(); 
   s_sign.reset(); 
   const_val = 0; 
   org_dim = -1; 
 }
 inline void reset() {
   a_tree.free(&t); t_num = 0; 
   const_val = 0; 
   org_dim = -1; 
   s_param.reset(); 
   dt_param = ""; 
   temp_files.reset(); 
 }
  void warm_start(const AzTreeEnsemble *inp_ens, 
              const AzDataForTrTree *data, 
              AzParam &param,              
              const AzBytArr *s_temp_prefix, 
              const AzOut &out,           
              int max_t_num, 
              int search_t_num, 
              AzDvect *v_p, /* inout */
              const AzIntArr *inp_ia_tr_dx=NULL)
  {
    const char *eyec = "AzTrTreeEnsemble::warmup"; 
    if (max_t_num < inp_ens->size()) {
      throw new AzException(eyec, "maximum #tree is less than the #tree we already have"); 
    }

    reset(); 
    a_tree.alloc(&t, max_t_num, "AzTrTreeEnsemble::warmup"); 
    t_num = inp_ens->size(); 
    const_val = inp_ens->constant(); 
    org_dim = inp_ens->orgdim(); 
    if (org_dim > 0 && org_dim != data->featNum()) {
      throw new AzException(AzInputError, eyec, "feature dimensionality mismatch"); 
    }

    const AzIntArr *ia_tr_dx = inp_ia_tr_dx; 
    AzIntArr ia_temp; 
    if (ia_tr_dx == NULL) {
      ia_temp.range(0, data->dataNum()); 
      ia_tr_dx = &ia_temp; 
    }
    v_p->reform(data->dataNum()); 
    v_p->add(const_val, ia_tr_dx); 

    T dummy_tree(param); 
    if (dummy_tree.usingInternalNodes()) {
      throw new AzException(AzInputError, eyec, 
                "warm start is not allowed with use of internal nodes"); 
    }
    dummy_tree.printParam(out); 

    temp_files.reset(&dummy_tree, data->dataNum(), s_temp_prefix); 

    s_param.reset(param.c_str());   
    dt_param = s_param.c_str(); 
    AzParam p(dt_param, false); 
 
    int tx; 
    for (tx = 0; tx < t_num; ++tx) {
      t[tx] = new T(p); 
      t[tx]->forStoringDataIndexes(temp_files.point_file()); 
      if (search_t_num > 0 && tx < t_num-search_t_num) {
        t[tx]->quick_warmup(inp_ens->tree(tx), data, v_p, ia_tr_dx); 
      }
      else {
        t[tx]->warmup(inp_ens->tree(tx), data, v_p, ia_tr_dx); 
      }
    }    
  }
示例#5
0
  //! copy nodes only; not split
  void copy_nodes_from(const AzTrTreeEnsemble_ReadOnly *inp) {
    reset(); 
    const_val = inp->constant(); 
    org_dim = inp->orgdim(); 
    t_num = inp->size(); 

    s_param.reset(inp->param_c_str()); 
    dt_param = s_param.c_str(); 
    AzParam p(dt_param, false); 
    a_tree.alloc(&t, t_num, "AzTrTreeEnsemble::copy_nodes_from"); 
    for (int tx = 0; tx < t_num; ++tx) {
      t[tx] = new T(p);
      t[tx]->copy_nodes_from(inp->tree(tx)); 
    }
  }
 virtual 
 T *new_tree(int *out_tx=NULL) {
   if (t_num >= a_tree.size()) {
     throw new AzException("AzTrTreeEnsemble::new_tree", "no more empty slot"); 
   }
   int tx = t_num; 
   if (t[tx] != NULL) {
     throw new AzException("AzTrTreeEnsemble::new_tree", "something is wrong"); 
   }
   AzParam p(dt_param, false); 
   t[tx] = new T(p); 
   t[tx]->forStoringDataIndexes(temp_files.point_file()); 
   ++t_num; 
   if (out_tx != NULL) {
     *out_tx = tx; 
   }
   return t[tx]; 
 }
 /** @ alloc the Tree pointer array*/
 inline void alloc(int num, const char *msg="") {
   a_tree.alloc(&t, num, "AzTrTreeEnsemble::alloc", msg); 
 }
 inline bool isFull() const {
   if (t_num >= a_tree.size()) {
     return true; 
   }
   return false; 
 }
 inline int max_size() const { return a_tree.size(); }
 void _release() {
   a.free(&column); col_num = 0; 
   row_num = 0; 
 }
示例#11
0
 void _release() {
   checkLock("_release"); 
   a.free(&column); col_num = 0; 
   row_num = 0; 
   dummy_zero.reform(0); 
 }