Skip to content

Commit

Permalink
docs: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Dec 28, 2024
1 parent dd33d4f commit af695fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Extending mlr3 to time series forecasting.
```{=gfm}
> [!IMPORTANT]
> This package is in an early stage of development and should be considered experimental.
> If you are interested in experimenting with it, we welcome your feedback!
```

## Installation
Expand Down
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ status](https://www.r-pkg.org/badges/version/mlr3forecast)](https://CRAN.R-proje

> [!IMPORTANT]
> This package is in an early stage of development and should be considered experimental.
> If you are interested in experimenting with it, we welcome your feedback!
## Installation

Expand Down Expand Up @@ -44,32 +45,32 @@ prediction = ff$predict_newdata(newdata, task)
prediction
#> <PredictionRegr> for 3 observations:
#> row_ids truth response
#> 1 NA 444.7671
#> 2 NA 473.9790
#> 3 NA 480.9669
#> 1 NA 445.1830
#> 2 NA 478.2606
#> 3 NA 484.7871
prediction = ff$predict(task, 142:144)
prediction
#> <PredictionRegr> for 3 observations:
#> row_ids truth response
#> 1 461 462.5280
#> 2 390 410.8195
#> 3 432 388.3864
#> 1 461 458.0830
#> 2 390 412.4142
#> 3 432 398.7917
prediction$score(measure)
#> regr.rmse
#> 27.91612
#> 23.19263

ff = Forecaster$new(lrn("regr.ranger"), 1:3)
resampling = rsmp("forecast_holdout", ratio = 0.8)
rr = resample(task, ff, resampling)
rr$aggregate(measure)
#> regr.rmse
#> 115.1751
#> 113.1917

resampling = rsmp("forecast_cv")
rr = resample(task, ff, resampling)
rr$aggregate(measure)
#> regr.rmse
#> 51.15563
#> 50.52313
```

### Multivariate
Expand All @@ -88,39 +89,39 @@ prediction = ff$predict(new_task, 142:144)
ff$predict(new_task, 142:144)
#> <PredictionRegr> for 3 observations:
#> row_ids truth response
#> 1 461 450.8882
#> 2 390 405.8591
#> 3 432 405.1108
#> 1 461 454.2787
#> 2 390 402.9731
#> 3 432 404.8773
prediction$score(measure)
#> regr.rmse
#> 18.94544
#> 17.78686

row_ids = new_task$nrow - 0:2
ff$predict_newdata(new_task$data(rows = row_ids), new_task)
#> <PredictionRegr> for 3 observations:
#> row_ids truth response
#> 1 432 407.3052
#> 2 390 386.6901
#> 3 461 390.5332
#> 1 432 402.6563
#> 2 390 389.9071
#> 3 461 384.1679
newdata = new_task$data(rows = row_ids, cols = new_task$feature_names)
ff$predict_newdata(newdata, new_task)
#> <PredictionRegr> for 3 observations:
#> row_ids truth response
#> 1 NA 407.3052
#> 2 NA 386.6901
#> 3 NA 390.5332
#> 1 NA 402.6563
#> 2 NA 389.9071
#> 3 NA 384.1679

resampling = rsmp("forecast_holdout", ratio = 0.8)
rr = resample(new_task, ff, resampling)
rr$aggregate(measure)
#> regr.rmse
#> 80.58328
#> 84.17676

resampling = rsmp("forecast_cv")
rr = resample(new_task, ff, resampling)
rr$aggregate(measure)
#> regr.rmse
#> 44.15569
#> 45.40293
```

### mlr3pipelines integration
Expand All @@ -130,5 +131,5 @@ glrn = as_learner(pop %>>% ff)$train(task)
prediction = glrn$predict(task, 142:144)
prediction$score(measure)
#> regr.rmse
#> 19.22717
#> 19.75408
```

0 comments on commit af695fa

Please sign in to comment.