File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,7 @@ void APLRRegressor::determine_interactions_to_consider()
422422 if (!(terms[sorted_latest_split_point_errors_indices[i]]==interaction))
423423 {
424424 interaction.given_terms .push_back (terms[sorted_latest_split_point_errors_indices[i]]);
425+ interaction.given_terms [interaction.given_terms .size ()-1 ].coefficient_steps .resize (0 ); // freeing memory
425426 bool already_exists{false };
426427 for (size_t k = 0 ; k < terms_eligible_current.size (); ++k)
427428 {
@@ -836,6 +837,10 @@ void APLRRegressor::cleanup_after_fit()
836837 distributed_terms.clear ();
837838 interactions_to_consider.clear ();
838839 error_index_for_interactions_to_consider.resize (0 );
840+ for (size_t i = 0 ; i < terms.size (); ++i)
841+ {
842+ terms[i].clean_up_after_fit ();
843+ }
839844}
840845
841846VectorXd APLRRegressor::predict (const MatrixXd &X)
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class Term
5454 void calculate_coefficient_and_error_on_discretized_data (bool direction_right, double split_point);
5555 void estimate_coefficient_and_error_on_all_data ();
5656 void clean_up_after_estimate_split_point ();
57+ void clean_up_after_fit ();
5758
5859public:
5960 // fields
@@ -593,6 +594,16 @@ void Term::clean_up_after_estimate_split_point()
593594 errors_initial.resize (0 );
594595}
595596
597+ void Term::clean_up_after_fit ()
598+ {
599+ bins_start_index.clear ();
600+ bins_end_index.clear ();
601+ bins_split_points_left.clear ();
602+ bins_split_points_right.clear ();
603+ values_discretized.resize (0 );
604+ sample_weight_discretized.resize (0 );
605+ }
606+
596607VectorXd Term::calculate_prediction_contribution (const MatrixXd &X)
597608{
598609 VectorXd values{calculate (X)};
You can’t perform that action at this time.
0 commit comments