mitchelloharawild / fable.prophet

fable extension for the prophet forecasting procedure
https://pkg.mitchelloharawild.com/fable.prophet
55 stars 8 forks source link

Error: Can't convert <distribution> to <character> #23

Closed edgBR closed 4 years ago

edgBR commented 4 years ago

Hi,

When trying to forecast on new data:


Brief description of the problem


model <- testing_data  %>% filter(a==70, b!=3) %>% filter(year(snsr_dt)<2019) %>% 
    model(prophet3 = fable.prophet::prophet(snsr_val_clean ~ season("month", 3, type = "multiplicative")),
          prophet4 = fable.prophet::prophet(snsr_val_clean ~ growth("linear") + season("week", 2, type = "multiplicative") + season("month", 2, type = "multiplicative")),
          prophet5 = fable.prophet::prophet(snsr_val_clean ~ growth("linear") + season("week", 2, type = "multiplicative") + season("year", 2, type = "multiplicative")),
          prophet6 = fable.prophet::prophet(snsr_val_clean ~ growth("linear") + season("week", 2, type = "multiplicative") + season("month", 2, type = "multiplicative") + season("year", 2, type = "multiplicative")))
fc <- model %>% forecast(h=52, testing_data  %>% filter(a==70, b!=3) %>% filter(year(snsr_dt)>2019)) 

And I open the forecast in the viewer of RStudio:

fableerror

rlang::last_error() <error/vctrs_error_incompatible_type> 
Can't convert <distribution> to <character>. 
Backtrace:  1. (function (x, start, len, ...) ...  
5. vctrs::vec_default_cast(...)  
6. vctrs::stop_incompatible_cast(...)  
7. vctrs::stop_incompatible_type(...)  
8. vctrs:::stop_incompatible(...)  
9. vctrs:::stop_vctrs(...) 
Run `rlang::last_trace()` to see the full context.
rlang::last_trace() <error/vctrs_error_incompatible_type> Can't convert <distribution> to <character>. 
Backtrace:     █  1. ├─(function (x, start, len, ...) ...  
2. │ ├─base::as.character(col)  
3. │ └─vctrs:::as.character.vctrs_vctr(col)  
4. │   └─vctrs::vec_cast(x, character())  
5. └─vctrs::vec_default_cast(...)  
6.   └─vctrs::stop_incompatible_cast(...)  
7.     └─vctrs::stop_incompatible_type(...)  
8.       └─vctrs:::stop_incompatible(...)  
9.         └─vctrs:::stop_vctrs(...)
sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] feather_0.3.5         xts_0.12-0            zoo_1.8-8             DescTools_0.99.35     data.table_1.12.8     optparse_1.6.6        furrr_0.1.0          
 [8] future_1.17.0         imputeTS_3.0          timetk_2.0.0          feasts_0.1.3          fable_0.2.1.9000      fabletools_0.2.0.9000 tsibble_0.9.1        
[15] forcats_0.5.0         stringr_1.4.0         dplyr_1.0.0           purrr_0.3.4           readr_1.3.1           tidyr_1.1.0           tibble_3.0.1         
[22] ggplot2_3.3.2         tidyverse_1.3.0       aws.s3_0.3.21         drake_7.12.2          tictoc_1.0            ConfigParser_1.0.0    R6_2.4.1             
[29] ini_0.3.1             DBI_1.1.0             odbc_1.2.2            lubridate_1.7.9      

loaded via a namespace (and not attached):
  [1] readxl_1.3.1          backports_1.1.8       igraph_1.2.5          splines_4.0.0         storr_1.2.1           listenv_0.8.0         inline_0.3.15        
  [8] digest_0.6.25         fansi_0.4.1           magrittr_1.5          base64url_1.4         aws.signature_0.5.2   recipes_0.1.12        globals_0.12.5       
 [15] modelr_0.1.7          gower_0.2.1           matrixStats_0.56.0    RcppParallel_5.0.2    anytime_0.3.7         forecast_8.12         tseries_0.10-47      
 [22] prettyunits_1.1.1     colorspace_1.4-1      blob_1.2.1            rvest_0.3.5           haven_2.2.0           callr_3.4.3           crayon_1.3.4         
 [29] jsonlite_1.7.0        progressr_0.6.0       survival_3.1-12       glue_1.4.1            gtable_0.3.0          ipred_0.9-9           distributional_0.1.0 
 [36] pkgbuild_1.0.8        rstan_2.19.3          future.apply_1.5.0    quantmod_0.4.17       scales_1.1.1          stinepack_1.4         mvtnorm_1.1-0        
 [43] Rcpp_1.0.4.6          progress_1.2.2        bit_1.1-15.2          txtq_0.2.0            StanHeaders_2.21.0-5  stats4_4.0.0          lava_1.6.7           
 [50] prodlim_2019.11.13    httr_1.4.1            getopt_1.20.3         ellipsis_0.3.1        loo_2.2.0             pkgconfig_2.0.3       farver_2.0.3         
 [57] nnet_7.3-14           dbplyr_1.4.3          utf8_1.1.4            labeling_0.3          tidyselect_1.1.0      rlang_0.4.6           munsell_0.5.0        
 [64] cellranger_1.1.0      tools_4.0.0           cli_2.0.2             generics_0.0.2        broom_0.5.6           processx_3.4.2        bit64_0.9-7          
 [71] fs_1.4.1              packrat_0.5.0         nlme_3.1-147          fable.prophet_0.1.0   xml2_1.3.2            compiler_4.0.0        rstudioapi_0.11      
 [78] filelock_1.0.2        curl_4.3              reprex_0.3.0          stringi_1.4.6         ps_1.3.3              lattice_0.20-41       Matrix_1.2-18        
 [85] urca_1.3-0            vctrs_0.3.1           pillar_1.4.4          aws.ec2metadata_0.2.0 lifecycle_0.2.0       lmtest_0.9-37         extraDistr_1.8.11    
 [92] gridExtra_2.3         codetools_0.2-16      boot_1.3-25           MASS_7.3-51.6         assertthat_0.2.1      withr_2.2.0           fracdiff_1.5-1       
 [99] expm_0.999-4          parallel_4.0.0        hms_0.5.3             quadprog_1.5-8        grid_4.0.0            rpart_4.1-15          timeDate_3043.102    
[106] class_7.3-17          prophet_0.6.1         TTR_0.23-6            base64enc_0.1-3   

Similar error to the one having in fabletools last week.

BR /Edgar

mitchelloharawild commented 4 years ago

Update the distributional package with: remotes::install_github("mitchelloharawild/distributional")

edgBR commented 4 years ago

Hi Mitchell,

Do you know when all of this small bugs will be fixed in CRAN?

BR /Edgar

mitchelloharawild commented 4 years ago

As far as I'm aware, using View() never worked before, and so this is new functionality. fabletools will likely get a patch release early the next week as there was a functionality degradation bug with combination forecasts. distributional doesn't need a patch, and so the next release will be when new functionality is added.

mitchelloharawild commented 4 years ago

Closing as this has been fixed in {distributional} which will be submitted to CRAN shortly.