Closed nergiszaim closed 4 years ago
Perhaps your looking for n_changepoints
instead of changepoints
?
This confusing error is coming from the prophet package, so improving the error should happen there.
library(tsibble)
library(fable.prophet)
#> Loading required package: Rcpp
#> Loading required package: fabletools
x1 <- as_tsibble(AirPassengers)
md <- x1 %>% model(mdl_prophet = fable.prophet::prophet(value ~ growth("linear", n_changepoints = 3)))
#> Warning in .local(object, ...): non-zero return code in optimizing
#> Optimization terminated abnormally. Falling back to Newton optimizer.
md
#> # A mable: 1 x 1
#> mdl_prophet
#> <model>
#> 1 <prophet>
Created on 2019-12-11 by the reprex package (v0.3.0)
Seems like that is not the issue... As you can see the fit and residuals provide NA's
md <- x1 %>% model(mdl_prophet = fable.prophet::prophet(value ~ growth("linear", n_changepoints = 3)))
Optimization terminated abnormally. Falling back to Newton optimizer.
Warning messages:
1: In .local(object, ...) : non-zero return code in optimizing
2: 1 error encountered for mdl_prophet
[1] c++ exception (unknown reason)
> md %>%
augment()
# A tsibble: 144 x 5 [1M]
# Key: .model [1]
.model index value .fitted .resid
<chr> <mth> <dbl> <dbl> <dbl>
1 mdl_prophet 1949 Jan 112 NA NA
2 mdl_prophet 1949 Feb 118 NA NA
3 mdl_prophet 1949 Mar 132 NA NA
4 mdl_prophet 1949 Apr 129 NA NA
5 mdl_prophet 1949 May 121 NA NA
6 mdl_prophet 1949 Jun 135 NA NA
7 mdl_prophet 1949 Jul 148 NA NA
8 mdl_prophet 1949 Aug 148 NA NA
9 mdl_prophet 1949 Sep 136 NA NA
10 mdl_prophet 1949 Oct 119 NA NA
11 mdl_prophet 1949 Nov 104 NA NA
12 mdl_prophet 1949 Dec 118 NA NA
13 mdl_prophet 1950 Jan 115 NA NA
14 mdl_prophet 1950 Feb 126 NA NA
15 mdl_prophet 1950 Mar 141 NA NA
16 mdl_prophet 1950 Apr 135 NA NA
17 mdl_prophet 1950 May 125 NA NA
18 mdl_prophet 1950 Jun 149 NA NA
19 mdl_prophet 1950 Jul 170 NA NA
20 mdl_prophet 1950 Aug 170 NA NA
21 mdl_prophet 1950 Sep 158 NA NA
22 mdl_prophet 1950 Oct 133 NA NA
23 mdl_prophet 1950 Nov 114 NA NA
24 mdl_prophet 1950 Dec 140 NA NA
25 mdl_prophet 1951 Jan 145 NA NA
26 mdl_prophet 1951 Feb 150 NA NA
I am unable to reproduce this issue, could you provide your sessionInfo()
?
library(tsibble)
library(fable.prophet)
#> Loading required package: Rcpp
#> Loading required package: fabletools
x1 <- as_tsibble(AirPassengers)
md <- x1 %>% model(mdl_prophet = fable.prophet::prophet(value ~ growth("linear", n_changepoints = 3)))
#> Warning in .local(object, ...): non-zero return code in optimizing
#> Optimization terminated abnormally. Falling back to Newton optimizer.
augment(md)
#> # A tsibble: 144 x 5 [1M]
#> # Key: .model [1]
#> .model index value .fitted .resid
#> <chr> <mth> <dbl> <dbl> <dbl>
#> 1 mdl_prophet 1949 Jan 112 97.2 14.8
#> 2 mdl_prophet 1949 Feb 118 99.7 18.3
#> 3 mdl_prophet 1949 Mar 132 102. 30.0
#> 4 mdl_prophet 1949 Apr 129 104. 24.5
#> 5 mdl_prophet 1949 May 121 107. 14.1
#> 6 mdl_prophet 1949 Jun 135 109. 25.6
#> 7 mdl_prophet 1949 Jul 148 112. 36.1
#> 8 mdl_prophet 1949 Aug 148 114. 33.6
#> 9 mdl_prophet 1949 Sep 136 117. 19.1
#> 10 mdl_prophet 1949 Oct 119 119. -0.334
#> # … with 134 more rows
Created on 2019-12-12 by the reprex package (v0.3.0)
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] prophet_0.5 rlang_0.4.2 lubridate_1.7.4 tsibbledata_0.1.0
[5] fable.prophet_0.1.0 Rcpp_1.0.3 dplyr_0.8.3 tsibble_0.8.5
[9] fable_0.1.0 fabletools_0.1.1
loaded via a namespace (and not attached):
[1] matrixStats_0.55.0 xts_0.11-2 httr_1.4.0 rprojroot_1.3-2 rstan_2.19.2
[6] tools_3.6.1 backports_1.1.5 utf8_1.1.4 R6_2.4.1 lazyeval_0.2.2
[11] colorspace_1.4-1 withr_2.1.2 tidyselect_0.2.5 gridExtra_2.3 prettyunits_1.0.2
[16] processx_3.4.1 curl_3.3 compiler_3.6.1 cli_2.0.0 users_0.0.0.9000
[21] desc_1.2.0 plotly_4.9.0 labeling_0.3 scales_1.1.0 readr_1.3.1
[26] callr_3.4.0 stringr_1.4.0 digest_0.6.23 StanHeaders_2.19.0 extraDistr_1.8.11
[31] pkgconfig_2.0.3 htmltools_0.4.0 htmlwidgets_1.5.1 rstudioapi_0.10 shiny_1.3.2
[36] farver_2.0.1 generics_0.0.2 zoo_1.8-6 jsonlite_1.6 crosstalk_1.0.0
[41] inline_0.3.15 magrittr_1.5 loo_2.1.0 munsell_0.5.0 fansi_0.4.0
[46] lifecycle_0.1.0 stringi_1.4.3 yaml_2.2.0 pkgbuild_1.0.6 plyr_1.8.5
[51] grid_3.6.1 parallel_3.6.1 promises_1.0.1 crayon_1.3.4 lattice_0.20-38
[56] hms_0.5.0 zeallot_0.1.0 anytime_0.3.6 ps_1.3.0 pillar_1.4.2
[61] TSstudio_0.1.5 codetools_0.2-16 stats4_3.6.1 pkgload_1.0.2 glue_1.3.1
[66] packrat_0.5.0 data.table_1.12.2 remotes_2.1.0 vctrs_0.2.0 httpuv_1.5.1
[71] testthat_2.1.1 gtable_0.3.0 purrr_0.3.3 tidyr_1.0.0 assertthat_0.2.1
[76] ggplot2_3.2.1 mime_0.7 xtable_1.8-4 later_0.8.0 viridisLite_0.3.0
[81] tibble_2.1.3 ellipsis_0.3.0
This feels like an issue with prophet, could you try:
library(tsibble)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:tsibble':
#>
#> id
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
x1 <- as_tsibble(AirPassengers)
x2 <- rename(x1, ds = index, y = value)
mdl <- prophet::prophet(x2, n.changepoints = 3, yearly.seasonality = FALSE)
#> Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
#> Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
#> Warning in .local(object, ...): non-zero return code in optimizing
#> Optimization terminated abnormally. Falling back to Newton optimizer.
predict(mdl, x2)$yhat
#> [1] 97.16361 99.68116 101.95508 104.47263 106.90897 109.42653 111.86287
#> [8] 114.38042 116.89797 119.33431 121.85186 124.28820 126.80576 129.32331
#> [15] 131.59723 134.11478 136.55112 139.06867 141.50501 144.02256 146.54012
#> [22] 148.97646 151.49401 153.93035 156.44790 158.96545 161.23937 163.75692
#> [29] 166.19326 168.71082 171.14716 173.66471 176.18226 178.61860 181.13615
#> [36] 183.57250 186.09005 188.60760 190.96273 193.48269 195.92136 198.44132
#> [43] 200.87999 203.39995 205.91991 208.35858 210.87854 213.31721 215.83717
#> [50] 218.35713 220.63322 223.15318 225.59185 228.11181 230.55048 233.07044
#> [57] 235.59040 238.02907 240.54903 242.98770 245.50766 248.02762 250.30371
#> [64] 252.82367 255.26234 257.78230 260.22097 262.74093 265.26089 267.69956
#> [71] 270.21952 272.65819 275.17815 277.69811 279.97420 282.49416 284.93283
#> [78] 287.86383 290.70028 293.63128 296.56228 299.39873 302.32973 305.16618
#> [85] 308.09718 311.02818 313.77008 316.70108 319.53753 322.46853 325.30498
#> [92] 328.23598 331.16698 334.00343 336.93443 339.77088 342.70188 345.63288
#> [99] 348.28023 351.21123 354.04768 356.97868 359.81513 362.74613 365.67713
#> [106] 368.51358 371.44458 374.28103 377.21203 380.14303 382.79038 385.72138
#> [113] 388.55783 391.48883 394.32528 397.25628 400.18728 403.02373 405.95473
#> [120] 408.79118 411.72218 414.65318 417.30053 420.23153 423.06798 425.99898
#> [127] 428.83543 431.76643 434.69743 437.53388 440.46488 443.30133 446.23233
#> [134] 449.16333 451.90523 454.83623 457.67268 460.60368 463.44013 466.37113
#> [141] 469.30212 472.13858 475.06957 477.90602
Created on 2019-12-16 by the reprex package (v0.2.1)
yes... seems like it is...
> library(tsibble)
> library(dplyr)
> x1 <- as_tsibble(AirPassengers)
> x2 <- rename(x1, ds = index, y = value)
> mdl <- prophet::prophet(x2, n.changepoints = 3, yearly.seasonality = FALSE)
Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
Optimization terminated abnormally. Falling back to Newton optimizer.
Error in sampler$call_sampler(c(args, dotlist)) :
c++ exception (unknown reason)
In addition: Warning message:
In .local(object, ...) : non-zero return code in optimizing
> predict(mdl, x2)$yhat
Error in predict(mdl, x2) : object 'mdl' not found
> ```
Okay, closing this one as it is not an issue with this package. You can open up another issue in the prophet repository and reference this one.
Monthly prophet model produces 'origin' must supplied when change points are inputted: