@@ -237,15 +237,57 @@ scatter!(t_forecast, data_forecast[1][2][2])
237
237
```
238
238
239
239
``` @example ensemble
240
- ensem_prediction = sum(stack([ensem_weights[i] * sol[i][I] for i in 1:length(forecast_probs)]), dims = 2)
240
+ ensem_prediction = sum(stack(ensem_weights .* sol[:,I]), dims = 2)
241
+ plot(sol; idxs = I, color = :blue)
242
+ plot!(t_forecast, ensem_prediction, lw = 3, color = :red)
243
+ scatter!(t_forecast, data_forecast[2][2][2])
244
+ ```
245
+
246
+ ``` @example ensemble
247
+ ensem_prediction = sum(stack(ensem_weights .* sol[:,R]), dims = 2)
248
+ plot(sol; idxs = R, color = :blue)
249
+ plot!(t_forecast, ensem_prediction, lw = 3, color = :red)
250
+ scatter!(t_forecast, data_forecast[3][2][2])
251
+ ```
252
+
253
+ ## Training the "Super Ensemble" Model
254
+
255
+ The standard ensemble model first calibrates each model in an ensemble and then uses the calibrated models
256
+ as the basis for a prediction via a linear combination. The super ensemble performs the Bayesian estimation
257
+ on the full combination of models, including the weights vector, as a single Bayesian posterior calculation.
258
+ While this has the downside that the prediction of any single model is not necessarily predictive of the
259
+ whole, in some cases this ensemble model may be more effective.
260
+
261
+ To train this model, simply use ` bayesian_datafit ` on the ensemble. This looks like:
262
+
263
+ ``` @example ensemble
264
+ probs = [prob, prob2, prob3]
265
+ ps = [[β => Uniform(0.01, 10.0), γ => Uniform(0.01, 10.0)] for i in 1:3]
266
+ datas = [data_ensem,data_ensem,data_ensem]
267
+ super_enprob, ensem_weights = bayesian_datafit(probs, ps, datas)
268
+ ```
269
+
270
+ And now we can forecast with this model:
271
+
272
+ ``` @example ensemble
273
+ sol = solve(super_enprob; saveat = t_forecast);
274
+ ensem_prediction = sum(stack(ensem_weights .* sol[:,S]), dims = 2)
275
+ plot(sol; idxs = S, color = :blue)
276
+ plot!(t_forecast, ensem_prediction, lw = 3, color = :red)
277
+ scatter!(t_forecast, data_forecast[1][2][2])
278
+ ```
279
+
280
+ ``` @example ensemble
281
+ ensem_prediction = sum(stack(ensem_weights .* sol[:,I]), dims = 2)
241
282
plot(sol; idxs = I, color = :blue)
242
283
plot!(t_forecast, ensem_prediction, lw = 3, color = :red)
243
284
scatter!(t_forecast, data_forecast[2][2][2])
244
285
```
245
286
246
287
``` @example ensemble
247
- ensem_prediction = sum(stack([ ensem_weights[i] * sol[i][R] for i in 1:length(forecast_probs) ]), dims = 2)
288
+ ensem_prediction = sum(stack(ensem_weights . * sol[:,R ]), dims = 2)
248
289
plot(sol; idxs = R, color = :blue)
249
290
plot!(t_forecast, ensem_prediction, lw = 3, color = :red)
250
291
scatter!(t_forecast, data_forecast[3][2][2])
251
- ```
292
+ ```
293
+
0 commit comments