SkillAgentSearch skills...

Modeltime.ensemble

Time Series Ensemble Forecasting

Install / Use

/learn @business-science/Modeltime.ensemble

README

<!-- README.md is generated from README.Rmd. Please edit that file -->

modeltime.ensemble <a href="https://business-science.github.io/modeltime.ensemble/"><img src="man/figures/logo.png" align="right" height="138" alt="modeltime.ensemble website" /></a>

<!-- badges: start -->

CRAN_Status_Badge R-CMD-check Codecov test
coverage

<!-- badges: end -->

Ensemble Algorithms for Time Series Forecasting with Modeltime

A modeltime extension that implements ensemble forecasting methods including model averaging, weighted averaging, and stacking.

<img src="vignettes/stacking.jpg" width="100%" style="display: block; margin: auto;" />

Installation

Install the CRAN version:

install.packages("modeltime.ensemble")

Or, install the development version:

remotes::install_github("business-science/modeltime.ensemble")

Getting Started

  1. Getting Started with Modeltime: Learn the basics of forecasting with Modeltime.
  2. Getting Started with Modeltime Ensemble: Learn the basics of forecasting with Modeltime ensemble models.

Make Your First Ensemble in Minutes

Load the following libraries.

library(tidymodels)
library(modeltime)
library(modeltime.ensemble)
library(dplyr)
library(timetk)

Step 1 - Create a Modeltime Table

Create a Modeltime Table using the modeltime package.

m750_models
#> # Modeltime Table
#> # A tibble: 3 × 3
#>   .model_id .model     .model_desc            
#>       <int> <list>     <chr>                  
#> 1         1 <workflow> ARIMA(0,1,1)(0,1,1)[12]
#> 2         2 <workflow> PROPHET                
#> 3         3 <workflow> GLMNET

Step 2 - Make a Modeltime Ensemble

Then turn that Modeltime Table into a Modeltime Ensemble.

ensemble_fit <- m750_models %>%
    ensemble_average(type = "mean")

ensemble_fit
#> ── Modeltime Ensemble ───────────────────────────────────────────
#> Ensemble of 3 Models (MEAN)
#> 
#> # Modeltime Table
#> # A tibble: 3 × 3
#>   .model_id .model     .model_desc            
#>       <int> <list>     <chr>                  
#> 1         1 <workflow> ARIMA(0,1,1)(0,1,1)[12]
#> 2         2 <workflow> PROPHET                
#> 3         3 <workflow> GLMNET

Step 3 - Forecast!

To forecast, just follow the Modeltime Workflow.

# Calibration
calibration_tbl <- modeltime_table(
    ensemble_fit
) %>%
    modeltime_calibrate(testing(m750_splits), quiet = FALSE)

# Forecast vs Test Set
calibration_tbl %>%
    modeltime_forecast(
        new_data    = testing(m750_splits),
        actual_data = m750
    ) %>%
    plot_modeltime_forecast(.interactive = FALSE)
<img src="man/figures/README-unnamed-chunk-6-1.png" style="display: block; margin: auto;" />

Meet the modeltime ecosystem

Learn a growing ecosystem of forecasting packages

<div class="figure" style="text-align: center"> <img src="man/figures/modeltime_ecosystem.jpg" alt="The modeltime ecosystem is growing" width="100%" /> <p class="caption"> The modeltime ecosystem is growing </p> </div>

Modeltime is part of a growing ecosystem of Modeltime forecasting packages.

Take the High-Performance Forecasting Course

Become the forecasting expert for your organization

<a href="https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting/" target="_blank"><img src="https://www.filepicker.io/api/file/bKyqVAi5Qi64sS05QYLk" alt="High-Performance Time Series Forecasting Course" width="100%" style="box-shadow: 0 0 5px 2px rgba(0, 0, 0, .5);"/></a>

High-Performance Time Series Course

Time Series is Changing

Time series is changing. Businesses now need 10,000+ time series forecasts every day. This is what I call a High-Performance Time Series Forecasting System (HPTSF) - Accurate, Robust, and Scalable Forecasting.

High-Performance Forecasting Systems will save companies by improving accuracy and scalability. Imagine what will happen to your career if you can provide your organization a “High-Performance Time Series Forecasting System” (HPTSF System).

How to Learn High-Performance Time Series Forecasting

I teach how to build a HPTFS System in my High-Performance Time Series Forecasting Course. You will learn:

  • Time Series Machine Learning (cutting-edge) with Modeltime - 30+ Models (Prophet, ARIMA, XGBoost, Random Forest, & many more)
  • Deep Learning with GluonTS (Competition Winners)
  • Time Series Preprocessing, Noise Reduction, & Anomaly Detection
  • Feature engineering using lagged variables & external regressors
  • Hyperparameter Tuning
  • Time series cross-validation
  • Ensembling Multiple Machine Learning & Univariate Modeling Techniques (Competition Winner)
  • Scalable Forecasting - Forecast 1000+ time series in parallel
  • and more.
<p class="text-center" style="font-size:24px;"> Become the Time Series Expert for your organization. </p> <br> <p class="text-center" style="font-size:30px;"> <a href="https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting">Take the High-Performance Time Series Forecasting Course</a> </p>
View on GitHub
GitHub Stars80
CategoryEducation
Updated3mo ago
Forks21

Languages

R

Security Score

82/100

Audited on Dec 16, 2025

No findings