@@ -159,7 +159,17 @@ Tvec<double> ENSEMBLE::dloss(Tvec<double> &y, Tvec<double> &pred){
159159Tvec<double > ENSEMBLE::ddloss (Tvec<double > &y, Tvec<double > &pred){
160160    return  loss_functions::ddloss (y, pred, loss_function, extra_param);
161161}
162-                 
162+ 
163+ 
164+ double  ENSEMBLE::link_function (double  pred_observed){
165+     return  loss_functions::link_function (pred_observed, loss_function);
166+ }
167+ 
168+ 
169+ double  ENSEMBLE::inverse_link_function (double  pred){
170+     return  loss_functions::inverse_link_function (pred, loss_function);
171+ }
172+ 
163173
164174void  ENSEMBLE::train (
165175        Tvec<double > &y, 
@@ -170,6 +180,8 @@ void ENSEMBLE::train(
170180        Tvec<double > &w, Tvec<double > &offset, //  Defaults to a zero-vector
171181        bool  has_offset //  Should be removed
172182    ){
183+     using  namespace  std ::placeholders; 
184+     
173185    //  Set initials and declare variables
174186    int  MAXITER = nrounds;
175187    int  n = y.size (); 
@@ -182,11 +194,15 @@ void ENSEMBLE::train(
182194    Tmat<double > cir_sim = cir_sim_mat (100 , 100 ); //  nsim=100, nobs=100
183195
184196    //  Initial constant prediction: arg min l(y,constant)
185-     if (has_offset){
186-         this ->initialPred  = 0.0 ;
187-     }else {
188-         this ->initialPred  = this ->initial_prediction (y, loss_function, w); // y.sum()/n;
189-     }
197+     this ->initialPred  = learn_initial_prediction (
198+         y, 
199+         offset, 
200+         std::bind (&ENSEMBLE::dloss, this , _1, _2),
201+         std::bind (&ENSEMBLE::ddloss, this , _1, _2),
202+         std::bind (&ENSEMBLE::link_function, this , _1),
203+         std::bind (&ENSEMBLE::inverse_link_function, this , _1),
204+         verbose
205+         );
190206    pred.setConstant (this ->initialPred );
191207    pred += offset;
192208    this ->initial_score  = loss_functions::loss (y, pred, loss_function, w, extra_param);
0 commit comments