Skip to content

Commit

Permalink
updates for olivroy
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/business-science/modeltime.resample

# Conflicts:
#	.github/workflows/R-CMD-check.yaml
#	.github/workflows/pkgdown.yaml
#	.github/workflows/test-coverage.yaml
  • Loading branch information
mdancho84 committed Jan 4, 2024
2 parents a7f8dd7 + ce6abd0 commit 0e93edd
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 98 deletions.
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
pull_request:
branches: [main, master]


name: R-CMD-check

jobs:
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.8'

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- uses: vemonet/setup-spark@v1
with:
spark-version: '3.1.2'
hadoop-version: '3.2'

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
Expand All @@ -53,6 +39,7 @@ jobs:
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}


- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
Expand Down
4 changes: 2 additions & 2 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.2.2
Date: 2022-10-16 15:28:21 UTC
SHA: 4c5bb0660261c3b0a543d44ffa25008488277a6b
Date: 2022-10-18 00:28:29 UTC
SHA: f1034b5de71bd1177110566d67b5f7687c136114
21 changes: 6 additions & 15 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: modeltime.resample
Title: Resampling Tools for Time Series Forecasting
Version: 0.2.2.9000
Version: 0.2.3.9000
Authors@R: c(
person("Matt", "Dancho", email = "mdancho@business-science.io", role = c("aut", "cre")),
person("Business Science", role = "cph")
Expand All @@ -12,7 +12,7 @@ Description:
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://github.com/business-science/modeltime.resample
URL: https://business-science.github.io/modeltime.resample/, https://github.com/business-science/modeltime.resample
BugReports: https://github.com/business-science/modeltime.resample/issues
Depends:
modeltime (>= 0.3.0),
Expand All @@ -27,35 +27,26 @@ Imports:
yardstick,
timetk (>= 2.5.0),
tibble,
dplyr,
dplyr (>= 1.0.0),
tidyr,
purrr,
forcats,
glue,
stringr,
ggplot2,
ggplot2 (>= 3.4.0),
plotly,
cli,
crayon,
magrittr,
rlang (>= 0.1.2),
progressr,
tictoc,
hardhat
Suggests:
roxygen2,
testthat,
tidymodels,
tidyverse,
tidyquant,
glmnet,
lubridate,
knitr,
rmarkdown,
covr,
remotes
rmarkdown
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
VignetteBuilder: knitr


10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# modeltime.resample 0.2.2.9000 (Development Version)
# modeltime.resample (development version)

- Update for better compatibility with dplyr 1.1.0 and ggplot2 3.4.4 (@olivroy, #16)

- Remove dependency on tidyverse (@olivroy, #16)

# modeltime.resample 0.2.3

- Resubmit to CRAN (timetk issue)

# modeltime.resample 0.2.2

Expand Down
4 changes: 3 additions & 1 deletion R/modeltime_fit_resamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' library(tidymodels)
#' library(modeltime)
#' library(timetk)
#' library(tidyverse)
#' library(magrittr)
#'
#' # Make resamples
#' resamples_tscv <- training(m750_splits) %>%
Expand Down Expand Up @@ -93,6 +93,8 @@ modeltime_fit_resamples.mdl_time_tbl <- function(object, resamples, control = co

if (!control$save_pred) control$save_pred <- TRUE

# TODO Consider removing tictoc and progressr dep in favor
# of cli::cli_progress_step()
if (control$verbose) {
tictoc::tic()
print(cli::rule("Fitting Resamples", width = 65))
Expand Down
5 changes: 2 additions & 3 deletions R/modeltime_resample_accuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ modeltime_resample_accuracy <- function(object, summary_fns = mean, metric_set =
dplyr::mutate(n = dplyr::n()) %>%
dplyr::group_by(.model_id, .model_desc, .type, n) %>%
dplyr::summarise(
dplyr::across(.fns = summary_fns, ...),
dplyr::across(.cols = dplyr::everything(), .fns = summary_fns, ...),
.groups = "drop"
) %>%
dplyr::ungroup()
)

}

Expand Down
18 changes: 9 additions & 9 deletions R/plot_modeltime_resamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#' @param .point_shape Controls the point shape. Default: 16.
#' @param .point_alpha Controls the opacity of the points. Default: 1 (full opacity).
#' @param .summary_line_show Whether or not to show the summary lines. Default: `TRUE`.
#' @param .summary_line_size Controls the summary line size. Default: 0.5.
#' @param .summary_line_size Controls the summary line width. Default: 0.5.
#' @param .summary_line_type Controls the summary line type. Default: 1.
#' @param .summary_line_alpha Controls the summary line opacity. Default: 1 (full opacity).
#' @param .x_intercept Numeric. Adds an x-intercept at a location (e.g. 0). Default: NULL.
#' @param .x_intercept_color Controls the x-intercept color. Default: "red".
#' @param .x_intercept_size Controls the x-intercept size. Default: 0.5.
#' @param .x_intercept_size Controls the x-intercept linewidth. Default: 0.5.
#'
#' @details
#'
Expand Down Expand Up @@ -110,17 +110,17 @@ plot_modeltime_resamples <- function(.data,

# Prepare Data for Plot
data_prepared <- resample_results_tbl %>%
dplyr::rename(.value = !! target_var) %>%
dplyr::rename(.value = !!target_var) %>%

dplyr::mutate(.model_desc = ifelse(!is.na(.model_id), stringr::str_c(.model_id, "_", .model_desc), .model_desc)) %>%
dplyr::mutate(.model_desc = .model_desc %>% stringr::str_trunc(width = .legend_max_width)) %>%
dplyr::mutate(.model_desc = forcats::as_factor(.model_desc)) %>%
dplyr::mutate(.model_desc = as.factor(.model_desc)) %>%

dplyr::group_by(.resample_id, .model_desc) %>%
.metric_set(.value, .pred) %>%
dplyr::ungroup() %>%

dplyr::mutate(.metric = forcats::as_factor(.metric)) %>%
dplyr::mutate(.metric = as.factor(.metric)) %>%

dplyr::group_by(.model_desc, .metric) %>%
dplyr::mutate(..summary_fn = summary_fn_partial(.estimate)) %>%
Expand All @@ -147,17 +147,17 @@ plot_modeltime_resamples <- function(.data,
if (.summary_line_show) {
g <- g +
ggplot2::geom_vline(ggplot2::aes(xintercept = ..summary_fn, color = .model_desc),
size = .summary_line_size,
alpha = .summary_line_alpha,
linetype = .summary_line_type)
linewidth = .summary_line_size,
alpha = .summary_line_alpha,
linetype = .summary_line_type)
}

# Add a X-Intercept if desired
if (!is.null(.x_intercept)) {
g <- g +
ggplot2::geom_vline(xintercept = .x_intercept,
color = .x_intercept_color,
size = .x_intercept_size)
linewidth = .x_intercept_size)
}

# Add theme & labs
Expand Down
24 changes: 12 additions & 12 deletions R/tidyquant-theme-compat.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ theme_tq <- function(base_size = 11, base_family = "") {
ggplot2::theme(

# Base Inherited Elements
line = ggplot2::element_line(colour = blue, size = 0.5, linetype = 1,
line = ggplot2::element_line(colour = blue, linewidth = 0.5, linetype = 1,
lineend = "butt"),
rect = ggplot2::element_rect(fill = white, colour = blue,
size = 0.5, linetype = 1),
linewidth = 0.5, linetype = 1),
text = ggplot2::element_text(family = base_family, face = "plain",
colour = blue, size = base_size,
lineheight = 0.9, hjust = 0.5, vjust = 0.5, angle = 0,
Expand All @@ -27,14 +27,14 @@ theme_tq <- function(base_size = 11, base_family = "") {
# Axes
axis.line = ggplot2::element_blank(),
axis.text = ggplot2::element_text(size = ggplot2::rel(0.8)),
axis.ticks = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)),
axis.ticks = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)),
axis.title = ggplot2::element_text(size = ggplot2::rel(1.0)),

# Panel
panel.background = ggplot2::element_rect(fill = white, color = NA),
panel.border = ggplot2::element_rect(fill = NA, size = ggplot2::rel(1/2), color = blue),
panel.grid.major = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)),
panel.border = ggplot2::element_rect(fill = NA, linewidth = ggplot2::rel(1/2), color = blue),
panel.grid.major = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)),
panel.grid.minor.x = ggplot2::element_blank(),
panel.spacing = ggplot2::unit(.75, "cm"),

Expand Down Expand Up @@ -70,12 +70,12 @@ theme_tq_dark <- function(base_size = 11, base_family = "") {
ggplot2::theme(

# Axes
axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)),
axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)),

# Panel
panel.background = ggplot2::element_rect(fill = grey, color = NA),
panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)),
panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)),

# Complete theme
complete = TRUE
Expand All @@ -95,12 +95,12 @@ theme_tq_green <- function(base_size = 11, base_family = "") {
ggplot2::theme(

# Axes
axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)),
axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)),

# Panel
panel.background = ggplot2::element_rect(fill = green, color = NA),
panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)),
panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)),
panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)),

# Complete theme
complete = TRUE
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library(modeltime.resample)
[![CRAN status](https://www.r-pkg.org/badges/version/modeltime.resample)](https://CRAN.R-project.org/package=modeltime.resample)
![](http://cranlogs.r-pkg.org/badges/modeltime.resample?color=brightgreen)
![](http://cranlogs.r-pkg.org/badges/grand-total/modeltime.resample?color=brightgreen)
[![R-CMD-check](https://github.com/business-science/modeltime.resample/workflows/R-CMD-check/badge.svg)](https://github.com/business-science/modeltime.resample/actions)
[![R-CMD-check](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/business-science/modeltime.resample/branch/master/graph/badge.svg)](https://app.codecov.io/gh/business-science/modeltime.resample?branch=master)
<!-- badges: end -->

Expand Down
75 changes: 48 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
status](https://www.r-pkg.org/badges/version/modeltime.resample)](https://CRAN.R-project.org/package=modeltime.resample)
![](http://cranlogs.r-pkg.org/badges/modeltime.resample?color=brightgreen)
![](http://cranlogs.r-pkg.org/badges/grand-total/modeltime.resample?color=brightgreen)
[![R-CMD-check](https://github.com/business-science/modeltime.resample/workflows/R-CMD-check/badge.svg)](https://github.com/business-science/modeltime.resample/actions)
[![R-CMD-check](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/business-science/modeltime.resample/branch/master/graph/badge.svg)](https://app.codecov.io/gh/business-science/modeltime.resample?branch=master)
<!-- badges: end -->
Expand Down Expand Up @@ -58,9 +58,23 @@ where we can see that Prophet Boost and XGBoost Models outperform
Prophet with Regressors for the Walmart Time Series Panel Dataset using
the 6-Slice Time Series Cross Validation plan shown above.

<img src="man/figures/plotly_resample_error_plot.jpg" title="Model Accuracy for 6 Time Series Resamples" alt="Model Accuracy for 6 Time Series Resamples" width="100%" style="display: block; margin: auto;" />
<div class="figure" style="text-align: center">

<img src="man/figures/gt_accuracy_table.jpg" title="Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups)" alt="Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups)" width="80%" style="display: block; margin: auto;" />
<img src="man/figures/plotly_resample_error_plot.jpg" alt="Model Accuracy for 6 Time Series Resamples" width="100%" />
<p class="caption">
Model Accuracy for 6 Time Series Resamples
</p>

</div>

<div class="figure" style="text-align: center">

<img src="man/figures/gt_accuracy_table.jpg" alt="Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups)" width="80%" />
<p class="caption">
Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups)
</p>

</div>

## Getting Started

Expand All @@ -79,28 +93,35 @@ the 6-Slice Time Series Cross Validation plan shown above.

> Learn a growing ecosystem of forecasting packages
<img src="man/figures/modeltime_ecosystem.jpg" title="The modeltime ecosystem is growing" alt="The modeltime ecosystem is growing" width="100%" style="display: block; margin: auto;" />
<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.

- [Modeltime (Machine
Learning)](https://business-science.github.io/modeltime/)
- [Modeltime (Machine
Learning)](https://business-science.github.io/modeltime/)

- [Modeltime H2O
(AutoML)](https://business-science.github.io/modeltime.h2o/)
- [Modeltime H2O
(AutoML)](https://business-science.github.io/modeltime.h2o/)

- [Modeltime GluonTS (Deep
Learning)](https://business-science.github.io/modeltime.gluonts/)
- [Modeltime GluonTS (Deep
Learning)](https://business-science.github.io/modeltime.gluonts/)

- [Modeltime Ensemble (Blending
Forecasts)](https://business-science.github.io/modeltime.ensemble/)
- [Modeltime Ensemble (Blending
Forecasts)](https://business-science.github.io/modeltime.ensemble/)

- [Modeltime Resample
(Backtesting)](https://business-science.github.io/modeltime.resample/)
- [Modeltime Resample
(Backtesting)](https://business-science.github.io/modeltime.resample/)

- [Timetk (Feature Engineering, Data Wrangling, Time Series
Visualization)](https://business-science.github.io/timetk/)
- [Timetk (Feature Engineering, Data Wrangling, Time Series
Visualization)](https://business-science.github.io/timetk/)

## Take the High-Performance Forecasting Course

Expand Down Expand Up @@ -130,17 +151,17 @@ Series Forecasting
Course**](https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting).
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.
- **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.
Expand Down
2 changes: 1 addition & 1 deletion man/modeltime_fit_resamples.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0e93edd

Please sign in to comment.