@@ -136,6 +136,11 @@ function MMI.fit(
136136 return (forest, classes_seen, integers_seen), cache, report
137137end
138138
139+ info_recomputing (n) = " Detected a change to hyperparameters " *
140+ " not restricted to `n_trees`. Recomputing all $n trees trees. "
141+ info_dropping (n) = " Dropping $n trees from the ensemble. "
142+ info_adding (n) = " Adding $n trees to the ensemble. "
143+
139144function MMI. update (
140145 model:: RandomForestClassifier ,
141146 verbosity:: Int ,
@@ -150,8 +155,7 @@ function MMI.update(
150155 only_iterations_have_changed = MMI. is_same_except (model, old_model, :n_trees )
151156
152157 if ! only_iterations_have_changed
153- verbosity > 0 && @info " Detected a change to hyperparameters " *
154- " not restricted to `n_trees`. Recomputing $n_trees trees. "
158+ verbosity > 0 && @info info_recomputing (model. n_trees)
155159 return MMI. fit (
156160 model,
157161 verbosity,
@@ -166,10 +170,10 @@ function MMI.update(
166170 Δn_trees = model. n_trees - old_model. n_trees
167171 # if `n_trees` drops, then tuncate, otherwise compute more trees
168172 if Δn_trees < 0
169- verbosity > 0 && @info " Dropping $ (- Δn_trees) trees from the forest. "
173+ verbosity > 0 && @info info_dropping (- Δn_trees)
170174 forest = old_forest[1 : model. n_trees]
171175 else
172- verbosity > 0 && @info " Adding $ Δn_trees trees to the forest. "
176+ verbosity > 0 && @info info_adding ( Δn_trees)
173177 forest = DT. build_forest (
174178 old_forest,
175179 yplain, Xmatrix,
@@ -340,8 +344,7 @@ function MMI.update(
340344 only_iterations_have_changed = MMI. is_same_except (model, old_model, :n_trees )
341345
342346 if ! only_iterations_have_changed
343- verbosity > 0 && @info " Detected a change to hyperparameters " *
344- " not restricted to `n_trees`. Recomputing $n_trees trees. "
347+ verbosity > 0 && @info info_recomputing (model. n_trees)
345348 return MMI. fit (
346349 model,
347350 verbosity,
@@ -355,10 +358,10 @@ function MMI.update(
355358
356359 # if `n_trees` drops, then tuncate, otherwise compute more trees
357360 if Δn_trees < 0
358- verbosity > 0 && @info " Dropping $ (- Δn_trees) trees from the forest. "
361+ verbosity > 0 && @info info_dropping (- Δn_trees)
359362 forest = old_forest[1 : model. n_trees]
360363 else
361- verbosity > 0 && @info " Adding $ Δn_trees trees to the forest. "
364+ verbosity > 0 && @info info_adding ( Δn_trees)
362365 forest = DT. build_forest (
363366 old_forest,
364367 y,
0 commit comments