@@ -31,7 +31,10 @@ class node
3131    node* left;
3232    node* right;
3333
34-     node* createLeaf (double  node_prediction, double  node_tr_loss, double  local_optimism, double  CRt,
34+     // node(double node_prediction, double node_tr_loss, double local_optimism, double CRt,
35+     //      int obs_in_node, int obs_in_parent, int obs_tot);
36+     
37+     void  createLeaf (double  node_prediction, double  node_tr_loss, double  local_optimism, double  CRt,
3538                     int  obs_in_node, int  obs_in_parent, int  obs_tot);
3639
3740    node* getLeft ();
@@ -55,6 +58,22 @@ class node
5558    bool  deSerialize (node *nptr, std::ifstream& f, int & lineNum);
5659};
5760
61+ /* 
62+ // Constructor 
63+ node::node(double node_prediction, double node_tr_loss, double local_optimism, double CRt, 
64+                        int obs_in_node, int obs_in_parent, int obs_tot) 
65+ { 
66+     this->node_prediction = node_prediction; 
67+     this->node_tr_loss = node_tr_loss; 
68+     this->local_optimism = local_optimism; 
69+     this->prob_node = (double)obs_in_node / obs_tot; // prob_node; 
70+     double prob_split_complement = 1.0 - (double)obs_in_node / obs_in_parent; // if left: p(right, not left), oposite for right 
71+     this->p_split_CRt = prob_split_complement * CRt; 
72+     this->obs_in_node = obs_in_node; 
73+     this->left = NULL; 
74+     this->right = NULL; 
75+ } 
76+ */ 
5877
5978//  METHODS
6079
@@ -151,21 +170,21 @@ bool node::deSerialize(node *nptr, std::ifstream& f, int& lineNum)
151170    return  true ;
152171}
153172
154- node*  node::createLeaf (double  node_prediction, double  node_tr_loss, double  local_optimism, double  CRt,
173+ void  node::createLeaf (double  node_prediction, double  node_tr_loss, double  local_optimism, double  CRt,
155174                       int  obs_in_node, int  obs_in_parent, int  obs_tot)
156175{
157-     node* n = new  node;
158-     n ->node_prediction  = node_prediction;
159-     n ->node_tr_loss  = node_tr_loss;
160-     n ->local_optimism  = local_optimism;
161-     n ->prob_node  = (double )obs_in_node / obs_tot; //  prob_node;
176+     // node* n = new node;
177+     this ->node_prediction  = node_prediction;
178+     this ->node_tr_loss  = node_tr_loss;
179+     this ->local_optimism  = local_optimism;
180+     this ->prob_node  = (double )obs_in_node / obs_tot; //  prob_node;
162181    double  prob_split_complement = 1.0  - (double )obs_in_node / obs_in_parent; //  if left: p(right, not left), oposite for right
163-     n ->p_split_CRt  = prob_split_complement * CRt;
164-     n ->obs_in_node  = obs_in_node;
165-     n ->left  = NULL ;
166-     n ->right  = NULL ;
182+     this ->p_split_CRt  = prob_split_complement * CRt;
183+     this ->obs_in_node  = obs_in_node;
184+     this ->left  = NULL ;
185+     this ->right  = NULL ;
167186
168-     return  n;
187+     // return n;
169188}
170189
171190
@@ -387,8 +406,8 @@ bool node::split_information(const Tvec<double> &g, const Tvec<double> &h, const
387406
388407
389408        //  6. Update split information in child nodes
390-         left =  createLeaf (w_l, tr_loss_l, local_opt_l, this ->CRt , n_left, n_left+n_right, n); //  Update createLeaf()
391-         right =  createLeaf (w_r, tr_loss_r, local_opt_r, this ->CRt , n_right, n_left+n_right, n);
409+         left-> createLeaf (w_l, tr_loss_l, local_opt_l, this ->CRt , n_left, n_left+n_right, n); //  Update createLeaf()
410+         right-> createLeaf (w_r, tr_loss_r, local_opt_r, this ->CRt , n_right, n_left+n_right, n);
392411        // Rcpp::Rcout << "p_left_CRt: " << left->p_split_CRt << "\n" <<  "p_right_CRt:"  << right->p_split_CRt << std::endl;
393412
394413        //  7. update childs to left right
0 commit comments