Skip to content

Commit f490a37

Browse files
committed
Deploying to gh-pages from @ 8b30d48 🚀
1 parent b9fe355 commit f490a37

22 files changed

+344
-189
lines changed

index.html

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ prediction$score(msr("regr.rmse"))
7070
#> regr.rmse
7171
#> 13.85518
7272

73-
# add a target log transformation
74-
learner = as_learner(ppl(
75-
"targettrafo",
76-
graph = lrn("fcst.auto_arima"),
77-
targetmutate.trafo = function(x) log(x),
78-
targetmutate.inverter = function(x) list(response = exp(x$response))
79-
))
80-
prediction = learner$train(task)$predict(task, 140:144)
81-
prediction$score(msr("regr.rmse"))
82-
#> regr.rmse
83-
#> 12.29896
84-
8573
# generate new data to forecast unseen data
8674
newdata = generate_newdata(task, 12L)
8775
newdata
@@ -102,14 +90,26 @@ prediction = learner$predict_newdata(newdata, task)
10290
prediction
10391
#>
10492
#> ── <PredictionRegr> for 12 observations: ───────────────────────────────────────
105-
#> row_ids truth response
106-
#> 1 NA 450.4224
107-
#> 2 NA 425.7172
108-
#> 3 NA 479.0068
109-
#> --- --- ---
110-
#> 10 NA 497.2078
111-
#> 11 NA 429.8720
112-
#> 12 NA 477.2426
93+
#> row_ids truth response month
94+
#> 1 NA 445.6351 1961-01-01
95+
#> 2 NA 420.3953 1961-02-01
96+
#> 3 NA 449.1988 1961-03-01
97+
#> --- --- --- ---
98+
#> 10 NA 494.1275 1961-10-01
99+
#> 11 NA 423.3336 1961-11-01
100+
#> 12 NA 465.5085 1961-12-01
101+
102+
# add a target log transformation
103+
learner = as_learner(ppl(
104+
"targettrafo",
105+
graph = lrn("fcst.auto_arima"),
106+
targetmutate.trafo = function(x) log(x),
107+
targetmutate.inverter = function(x) list(response = exp(x$response))
108+
))
109+
prediction = learner$train(task)$predict(task, 140:144)
110+
prediction$score(msr("regr.rmse"))
111+
#> regr.rmse
112+
#> 12.29896
113113

114114
# works with quantile response
115115
learner = lrn(
@@ -145,39 +145,39 @@ prediction
145145
#>
146146
#> ── <PredictionRegr> for 12 observations: ───────────────────────────────────────
147147
#> row_ids truth response month
148-
#> 1 NA 435.4356 1961-01-01
149-
#> 2 NA 436.3505 1961-02-01
150-
#> 3 NA 457.6370 1961-03-01
148+
#> 1 NA 436.3897 1961-01-01
149+
#> 2 NA 435.7855 1961-02-01
150+
#> 3 NA 457.3597 1961-03-01
151151
#> --- --- --- ---
152-
#> 10 NA 478.0104 1961-10-01
153-
#> 11 NA 441.8672 1961-11-01
154-
#> 12 NA 440.7932 1961-12-01
152+
#> 10 NA 474.5674 1961-10-01
153+
#> 11 NA 438.2343 1961-11-01
154+
#> 12 NA 440.4972 1961-12-01
155155
prediction = flrn$predict(task, 140:144)
156156
prediction
157157
#>
158158
#> ── <PredictionRegr> for 5 observations: ────────────────────────────────────────
159159
#> row_ids truth response month
160-
#> 140 606 579.3439 1960-08-01
161-
#> 141 508 504.7630 1960-09-01
162-
#> 142 461 457.5243 1960-10-01
163-
#> 143 390 411.0244 1960-11-01
164-
#> 144 432 431.5973 1960-12-01
160+
#> 140 606 573.4641 1960-08-01
161+
#> 141 508 503.7301 1960-09-01
162+
#> 142 461 456.3900 1960-10-01
163+
#> 143 390 415.1462 1960-11-01
164+
#> 144 432 433.3205 1960-12-01
165165
prediction$score(msr("regr.rmse"))
166166
#> regr.rmse
167-
#> 15.33164
167+
#> 18.61261
168168

169169
flrn = as_learner_fcst(learner, lags = 1:12)
170170
resampling = rsmp("fcst.holdout", ratio = 0.9)
171171
rr = resample(task, flrn, resampling)
172172
rr$aggregate(msr("regr.rmse"))
173173
#> regr.rmse
174-
#> 47.48679
174+
#> 46.53581
175175

176176
resampling = rsmp("fcst.cv")
177177
rr = resample(task, flrn, resampling)
178178
rr$aggregate(msr("regr.rmse"))
179179
#> regr.rmse
180-
#> 24.69529
180+
#> 26.69851
181181
```
182182

183183
Or with some feature engineering using mlr3pipelines:
@@ -201,7 +201,7 @@ glrn = as_learner(graph %>>% flrn)$train(task)
201201
prediction = glrn$predict(task, 142:144)
202202
prediction$score(msr("regr.rmse"))
203203
#> regr.rmse
204-
#> 15.26907
204+
#> 14.59454
205205
```
206206

207207
### Example: forecasting electricity demand
@@ -228,13 +228,13 @@ prediction
228228
#>
229229
#> ── <PredictionRegr> for 14 observations: ───────────────────────────────────────
230230
#> row_ids truth response date
231-
#> 1 NA 188057.4 2015-01-01
232-
#> 2 NA 197409.8 2015-01-02
233-
#> 3 NA 188775.1 2015-01-03
231+
#> 1 NA 186121.6 2015-01-01
232+
#> 2 NA 196014.4 2015-01-02
233+
#> 3 NA 189591.3 2015-01-03
234234
#> --- --- --- ---
235-
#> 12 NA 223271.8 2015-01-12
236-
#> 13 NA 227054.7 2015-01-13
237-
#> 14 NA 227190.4 2015-01-14
235+
#> 12 NA 221422.6 2015-01-12
236+
#> 13 NA 225356.3 2015-01-13
237+
#> 14 NA 226671.8 2015-01-14
238238
```
239239

240240
### Example: global forecasting (longitudinal data)
@@ -267,14 +267,14 @@ flrn = as_learner_fcst(lrn("regr.ranger"), 1:3)$train(task)
267267
prediction = flrn$predict(task, 4460:4464)
268268
prediction$score(msr("regr.rmse"))
269269
#> regr.rmse
270-
#> 20921.31
270+
#> 21157.43
271271

272272
flrn = as_learner_fcst(lrn("regr.ranger"), 1:3)
273273
resampling = rsmp("fcst.holdout", ratio = 0.9)
274274
rr = resample(task, flrn, resampling)
275275
rr$aggregate(msr("regr.rmse"))
276276
#> regr.rmse
277-
#> 91727.97
277+
#> 91069.37
278278
```
279279

280280
### Example: global vs local forecasting

llms.txt

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ prediction$score(msr("regr.rmse"))
7070
#> regr.rmse
7171
#> 13.85518
7272

73-
# add a target log transformation
74-
learner = as_learner(ppl(
75-
"targettrafo",
76-
graph = lrn("fcst.auto_arima"),
77-
targetmutate.trafo = function(x) log(x),
78-
targetmutate.inverter = function(x) list(response = exp(x$response))
79-
))
80-
prediction = learner$train(task)$predict(task, 140:144)
81-
prediction$score(msr("regr.rmse"))
82-
#> regr.rmse
83-
#> 12.29896
84-
8573
# generate new data to forecast unseen data
8674
newdata = generate_newdata(task, 12L)
8775
newdata
@@ -102,14 +90,26 @@ prediction = learner$predict_newdata(newdata, task)
10290
prediction
10391
#>
10492
#> ── <PredictionRegr> for 12 observations: ───────────────────────────────────────
105-
#> row_ids truth response
106-
#> 1 NA 450.4224
107-
#> 2 NA 425.7172
108-
#> 3 NA 479.0068
109-
#> --- --- ---
110-
#> 10 NA 497.2078
111-
#> 11 NA 429.8720
112-
#> 12 NA 477.2426
93+
#> row_ids truth response month
94+
#> 1 NA 445.6351 1961-01-01
95+
#> 2 NA 420.3953 1961-02-01
96+
#> 3 NA 449.1988 1961-03-01
97+
#> --- --- --- ---
98+
#> 10 NA 494.1275 1961-10-01
99+
#> 11 NA 423.3336 1961-11-01
100+
#> 12 NA 465.5085 1961-12-01
101+
102+
# add a target log transformation
103+
learner = as_learner(ppl(
104+
"targettrafo",
105+
graph = lrn("fcst.auto_arima"),
106+
targetmutate.trafo = function(x) log(x),
107+
targetmutate.inverter = function(x) list(response = exp(x$response))
108+
))
109+
prediction = learner$train(task)$predict(task, 140:144)
110+
prediction$score(msr("regr.rmse"))
111+
#> regr.rmse
112+
#> 12.29896
113113

114114
# works with quantile response
115115
learner = lrn(
@@ -145,39 +145,39 @@ prediction
145145
#>
146146
#> ── <PredictionRegr> for 12 observations: ───────────────────────────────────────
147147
#> row_ids truth response month
148-
#> 1 NA 435.4356 1961-01-01
149-
#> 2 NA 436.3505 1961-02-01
150-
#> 3 NA 457.6370 1961-03-01
148+
#> 1 NA 436.3897 1961-01-01
149+
#> 2 NA 435.7855 1961-02-01
150+
#> 3 NA 457.3597 1961-03-01
151151
#> --- --- --- ---
152-
#> 10 NA 478.0104 1961-10-01
153-
#> 11 NA 441.8672 1961-11-01
154-
#> 12 NA 440.7932 1961-12-01
152+
#> 10 NA 474.5674 1961-10-01
153+
#> 11 NA 438.2343 1961-11-01
154+
#> 12 NA 440.4972 1961-12-01
155155
prediction = flrn$predict(task, 140:144)
156156
prediction
157157
#>
158158
#> ── <PredictionRegr> for 5 observations: ────────────────────────────────────────
159159
#> row_ids truth response month
160-
#> 140 606 579.3439 1960-08-01
161-
#> 141 508 504.7630 1960-09-01
162-
#> 142 461 457.5243 1960-10-01
163-
#> 143 390 411.0244 1960-11-01
164-
#> 144 432 431.5973 1960-12-01
160+
#> 140 606 573.4641 1960-08-01
161+
#> 141 508 503.7301 1960-09-01
162+
#> 142 461 456.3900 1960-10-01
163+
#> 143 390 415.1462 1960-11-01
164+
#> 144 432 433.3205 1960-12-01
165165
prediction$score(msr("regr.rmse"))
166166
#> regr.rmse
167-
#> 15.33164
167+
#> 18.61261
168168

169169
flrn = as_learner_fcst(learner, lags = 1:12)
170170
resampling = rsmp("fcst.holdout", ratio = 0.9)
171171
rr = resample(task, flrn, resampling)
172172
rr$aggregate(msr("regr.rmse"))
173173
#> regr.rmse
174-
#> 47.48679
174+
#> 46.53581
175175

176176
resampling = rsmp("fcst.cv")
177177
rr = resample(task, flrn, resampling)
178178
rr$aggregate(msr("regr.rmse"))
179179
#> regr.rmse
180-
#> 24.69529
180+
#> 26.69851
181181
```
182182

183183
Or with some feature engineering using mlr3pipelines:
@@ -201,7 +201,7 @@ glrn = as_learner(graph %>>% flrn)$train(task)
201201
prediction = glrn$predict(task, 142:144)
202202
prediction$score(msr("regr.rmse"))
203203
#> regr.rmse
204-
#> 15.26907
204+
#> 14.59454
205205
```
206206

207207
### Example: forecasting electricity demand
@@ -228,13 +228,13 @@ prediction
228228
#>
229229
#> ── <PredictionRegr> for 14 observations: ───────────────────────────────────────
230230
#> row_ids truth response date
231-
#> 1 NA 188057.4 2015-01-01
232-
#> 2 NA 197409.8 2015-01-02
233-
#> 3 NA 188775.1 2015-01-03
231+
#> 1 NA 186121.6 2015-01-01
232+
#> 2 NA 196014.4 2015-01-02
233+
#> 3 NA 189591.3 2015-01-03
234234
#> --- --- --- ---
235-
#> 12 NA 223271.8 2015-01-12
236-
#> 13 NA 227054.7 2015-01-13
237-
#> 14 NA 227190.4 2015-01-14
235+
#> 12 NA 221422.6 2015-01-12
236+
#> 13 NA 225356.3 2015-01-13
237+
#> 14 NA 226671.8 2015-01-14
238238
```
239239

240240
### Example: global forecasting (longitudinal data)
@@ -267,14 +267,14 @@ flrn = as_learner_fcst(lrn("regr.ranger"), 1:3)$train(task)
267267
prediction = flrn$predict(task, 4460:4464)
268268
prediction$score(msr("regr.rmse"))
269269
#> regr.rmse
270-
#> 20921.31
270+
#> 21157.43
271271

272272
flrn = as_learner_fcst(lrn("regr.ranger"), 1:3)
273273
resampling = rsmp("fcst.holdout", ratio = 0.9)
274274
rr = resample(task, flrn, resampling)
275275
rr$aggregate(msr("regr.rmse"))
276276
#> regr.rmse
277-
#> 91727.97
277+
#> 91069.37
278278
```
279279

280280
### Example: global vs local forecasting
@@ -483,6 +483,8 @@ prediction$score(msr("regr.rmse"))
483483

484484
## Helper
485485

486+
- [`as_learner_fcst()`](https://mlr3forecast.mlr-org.com/reference/as_learner_fcst.md)
487+
: Convert to a Forecast Learner
486488
- [`as_task_fcst()`](https://mlr3forecast.mlr-org.com/reference/as_task_fcst.md)
487489
[`as_tasks_fcst()`](https://mlr3forecast.mlr-org.com/reference/as_task_fcst.md)
488490
: Convert to a Forecast Task

pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pandoc: 3.1.11
22
pkgdown: 2.2.0
33
pkgdown_sha: ~
44
articles: {}
5-
last_built: 2025-12-01T21:35Z
5+
last_built: 2025-12-03T15:32Z
66
urls:
77
reference: https://mlr3forecast.mlr-org.com/reference
88
article: https://mlr3forecast.mlr-org.com/articles

reference/ForecastLearner.html

Lines changed: 22 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)