@@ -55,7 +55,7 @@ LearnAPI.algorithm(model::EnsembleFitted) = model.algorithm
55
55
LearnAPI. obs (algorithm:: Ensemble , data) = LearnAPI. obs (algorithm. atom, data)
56
56
LearnAPI. obs (model:: EnsembleFitted , data) = LearnAPI. obs (first (model. models), data)
57
57
LearnAPI. target (algorithm:: Ensemble , data) = LearnAPI. target (algorithm. atom, data)
58
- LearnAPI. features (algorithm:: Ridge , data) = LearnAPI. features (algorithm. atom, data)
58
+ LearnAPI. features (algorithm:: Ensemble , data) = LearnAPI. features (algorithm. atom, data)
59
59
60
60
function LearnAPI. fit (algorithm:: Ensemble , data; verbosity= 1 )
61
61
97
97
# models. Otherwise, update is equivalent to retraining from scratch, with the provided
98
98
# hyperparameter updates.
99
99
function LearnAPI. update (model:: EnsembleFitted , data; verbosity= 1 , replacements... )
100
- :n in keys (replacements) || return fit (model, data)
101
-
102
100
algorithm_old = LearnAPI. algorithm (model)
103
101
algorithm = LearnAPI. clone (algorithm_old; replacements... )
102
+
103
+ :n in keys (replacements) || return fit (algorithm, data)
104
+
104
105
n = algorithm. n
105
106
Δn = n - algorithm_old. n
106
107
n < 0 && return fit (model, algorithm)
@@ -156,7 +157,6 @@ LearnAPI.minimize(model::EnsembleFitted) = EnsembleFitted(
156
157
:(LearnAPI. target),
157
158
:(LearnAPI. update),
158
159
:(LearnAPI. predict),
159
- :(LearnAPI. feature_importances),
160
160
)
161
161
)
162
162
@@ -190,16 +190,18 @@ Xtest = Tables.subset(X, test)
190
190
@test ŷ4 == predict (model, Xtest)
191
191
192
192
# add 3 atomic models to the ensemble:
193
- # model = @test_logs(
194
- # (:info, r"Trained 3 additional"),
195
- # update(model, Xtrain, y[train]; n=7),
196
- # )
197
193
model = update (model, Xtrain, y[train]; verbosity= 0 , n= 7 );
198
194
ŷ7 = predict (model, Xtest)
199
195
200
196
# compare with cold restart:
201
197
model = fit (LearnAPI. clone (algorithm; n= 7 ), Xtrain, y[train]; verbosity= 0 );
202
198
@test ŷ7 ≈ predict (model, Xtest)
199
+
200
+ # test cold restart if another hyperparameter is changed:
201
+ model2 = update (model, Xtrain, y[train]; atom= Ridge (0.05 ))
202
+ algorithm2 = LearnAPI. clone (LearnAPI. algorithm (model); atom= Ridge (0.05 ))
203
+ @test predict (model, Xtest) ≈ predict (model2, Xtest)
204
+
203
205
end
204
206
205
207
true
0 commit comments