diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f30b572..eed2a89 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -8,7 +8,6 @@ on: pull_request: branches: [main, master] - name: R-CMD-check jobs: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 9407c7e..86f6370 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -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 @@ -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 diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 14d69e4..b93facc 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -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 diff --git a/DESCRIPTION b/DESCRIPTION index b5bdd45..a979a3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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") @@ -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), @@ -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 - - diff --git a/NEWS.md b/NEWS.md index a174549..0c9a696 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/modeltime_fit_resamples.R b/R/modeltime_fit_resamples.R index 7a31332..32d56fd 100644 --- a/R/modeltime_fit_resamples.R +++ b/R/modeltime_fit_resamples.R @@ -45,7 +45,7 @@ #' library(tidymodels) #' library(modeltime) #' library(timetk) -#' library(tidyverse) +#' library(magrittr) #' #' # Make resamples #' resamples_tscv <- training(m750_splits) %>% @@ -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)) diff --git a/R/modeltime_resample_accuracy.R b/R/modeltime_resample_accuracy.R index 118049c..ef39d6f 100644 --- a/R/modeltime_resample_accuracy.R +++ b/R/modeltime_resample_accuracy.R @@ -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() + ) } diff --git a/R/plot_modeltime_resamples.R b/R/plot_modeltime_resamples.R index ad88e26..5164436 100644 --- a/R/plot_modeltime_resamples.R +++ b/R/plot_modeltime_resamples.R @@ -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 #' @@ -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)) %>% @@ -147,9 +147,9 @@ 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 @@ -157,7 +157,7 @@ plot_modeltime_resamples <- function(.data, g <- g + ggplot2::geom_vline(xintercept = .x_intercept, color = .x_intercept_color, - size = .x_intercept_size) + linewidth = .x_intercept_size) } # Add theme & labs diff --git a/R/tidyquant-theme-compat.R b/R/tidyquant-theme-compat.R index 2fb917f..a1973a6 100644 --- a/R/tidyquant-theme-compat.R +++ b/R/tidyquant-theme-compat.R @@ -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, @@ -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"), @@ -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 @@ -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 diff --git a/README.Rmd b/README.Rmd index a153c97..15365f0 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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) diff --git a/README.md b/README.md index 3a788aa..99adc25 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. - +
Become the Time Series Expert for your organization. diff --git a/man/modeltime_fit_resamples.Rd b/man/modeltime_fit_resamples.Rd index b099134..3cba8fb 100644 --- a/man/modeltime_fit_resamples.Rd +++ b/man/modeltime_fit_resamples.Rd @@ -52,7 +52,7 @@ The sub-model cross-validation predictions are used as the input to the meta-lea library(tidymodels) library(modeltime) library(timetk) -library(tidyverse) +library(magrittr) # Make resamples resamples_tscv <- training(m750_splits) \%>\% diff --git a/man/plot_modeltime_resamples.Rd b/man/plot_modeltime_resamples.Rd index 0f500eb..372de68 100644 --- a/man/plot_modeltime_resamples.Rd +++ b/man/plot_modeltime_resamples.Rd @@ -58,7 +58,7 @@ of models and metrics. Default: \code{TRUE}.} \item{.summary_line_show}{Whether or not to show the summary lines. Default: \code{TRUE}.} -\item{.summary_line_size}{Controls the summary line size. Default: 0.5.} +\item{.summary_line_size}{Controls the summary line width. Default: 0.5.} \item{.summary_line_type}{Controls the summary line type. Default: 1.} @@ -68,7 +68,7 @@ of models and metrics. Default: \code{TRUE}.} \item{.x_intercept_color}{Controls the x-intercept color. Default: "red".} -\item{.x_intercept_size}{Controls the x-intercept size. Default: 0.5.} +\item{.x_intercept_size}{Controls the x-intercept linewidth. Default: 0.5.} \item{.legend_show}{Logical. Whether or not to show the legend. Can save space with long model descriptions.} diff --git a/tests/testthat.R b/tests/testthat.R index e272955..a74093b 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -8,7 +8,6 @@ library(modeltime.resample) library(glmnet) # Core Packages -library(tidyverse) library(timetk) library(lubridate) diff --git a/tests/testthat/test-modeltime_fit_resamples.R b/tests/testthat/test-modeltime_fit_resamples.R index 926f556..d7edb90 100644 --- a/tests/testthat/test-modeltime_fit_resamples.R +++ b/tests/testthat/test-modeltime_fit_resamples.R @@ -1,14 +1,11 @@ context("TEST: modeltime_fit_resamples()") -library(testthat) - # Machine Learning library(tidymodels) library(modeltime) library(modeltime.resample) # Core Packages -library(tidyverse) library(timetk) library(lubridate) diff --git a/vignettes/getting-started.Rmd b/vignettes/getting-started.Rmd index 3b88015..f154b44 100644 --- a/vignettes/getting-started.Rmd +++ b/vignettes/getting-started.Rmd @@ -37,7 +37,7 @@ In this tutorial, we'll get you up to speed by evaluating multiple models using Load the following R packages. -```{r} +```r library(tidymodels) library(modeltime) library(modeltime.resample) @@ -45,6 +45,15 @@ library(tidyverse) library(timetk) ``` +```{r, echo=FALSE,include=FALSE} +library(tidymodels) +library(modeltime) +library(modeltime.resample) +library(dplyr) +library(timetk) +``` + + We'll work with the `m750` data set. ```{r} diff --git a/vignettes/panel-data.Rmd b/vignettes/panel-data.Rmd index a2985d8..268d198 100644 --- a/vignettes/panel-data.Rmd +++ b/vignettes/panel-data.Rmd @@ -34,7 +34,7 @@ __This is an advanced tutorial.__ Working with Panel Data requires working with Load the following R packages. -```{r setup} +```r library(tidymodels) library(modeltime) library(modeltime.resample) @@ -43,6 +43,15 @@ library(tidyverse) library(tidyquant) ``` +```{r setup,echo=FALSE,include=FALSE} +library(tidymodels) +library(modeltime) +library(modeltime.resample) +library(timetk) +library(dplyr) +library(tidyquant) +``` + ## Data We'll use the `walmart_sales_weekly` dataset from `timetk`. This contains 7 time series groups, which correspond to the revenue over time for seven departments in one Walmart Store. @@ -76,7 +85,7 @@ full_data_tbl <- walmart_sales_weekly %>% ungroup() %>% # Consolidate IDs - mutate(id = fct_drop(id)) + mutate(id = droplevels(id)) # Training Data data_prepared_tbl <- full_data_tbl %>% @@ -250,8 +259,8 @@ resample_results <- model_tbl %>% ``` ```{r, echo=FALSE} -# write_rds(resample_results, "resample_results.rds") -resample_results <- read_rds("resample_results.rds") +# saveRDS(resample_results, "resample_results.rds") +resample_results <- readRDS("resample_results.rds") ``` A new column (".resample_results") containing the resample predictions has been added to the original `model_tbl`.