prophet-rb 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -1
  3. data/LICENSE.txt +1 -1
  4. data/README.md +51 -1
  5. data/data-raw/LICENSE-holidays.txt +20 -0
  6. data/data-raw/README.md +3 -0
  7. data/data-raw/generated_holidays.csv +29302 -61443
  8. data/lib/prophet/forecaster.rb +200 -0
  9. data/lib/prophet/holidays.rb +6 -10
  10. data/lib/prophet/stan_backend.rb +5 -5
  11. data/lib/prophet/version.rb +1 -1
  12. data/lib/prophet.rb +22 -7
  13. data/stan/{unix/prophet.stan → prophet.stan} +8 -7
  14. data/vendor/aarch64-linux/bin/prophet +0 -0
  15. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbb.so +0 -0
  16. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbb.so.2 +0 -0
  17. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbbmalloc.so +0 -0
  18. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbbmalloc.so.2 +0 -0
  19. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbbmalloc_proxy.so +0 -0
  20. data/vendor/{prophet-linux-arm → aarch64-linux}/lib/libtbbmalloc_proxy.so.2 +0 -0
  21. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/boost-license.txt +0 -0
  22. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/cli11-license.txt +0 -0
  23. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/cmdstan-license.txt +0 -0
  24. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/eigen-bsd-license.txt +0 -0
  25. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/eigen-mpl2-license.txt +0 -0
  26. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/prophet-license.txt +0 -0
  27. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/rapidjson-license.txt +0 -0
  28. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/stan-license.txt +0 -0
  29. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/stan-math-license.txt +0 -0
  30. data/vendor/aarch64-linux/licenses/sundials-license.txt +29 -0
  31. data/vendor/aarch64-linux/licenses/sundials-notice.txt +21 -0
  32. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/tbb-license.txt +0 -0
  33. data/vendor/{prophet-linux-arm → aarch64-linux}/licenses/tbb-third-party-programs.txt +0 -0
  34. data/vendor/arm64-darwin/bin/prophet +0 -0
  35. data/vendor/arm64-darwin/lib/libtbb.dylib +0 -0
  36. data/vendor/{prophet-mac-arm → arm64-darwin}/lib/libtbbmalloc.dylib +0 -0
  37. data/vendor/{prophet-mac-arm → arm64-darwin}/lib/libtbbmalloc_proxy.dylib +0 -0
  38. data/vendor/{prophet-linux → arm64-darwin}/licenses/boost-license.txt +0 -0
  39. data/vendor/{prophet-linux → arm64-darwin}/licenses/cli11-license.txt +0 -0
  40. data/vendor/{prophet-linux → arm64-darwin}/licenses/cmdstan-license.txt +0 -0
  41. data/vendor/{prophet-linux → arm64-darwin}/licenses/eigen-bsd-license.txt +0 -0
  42. data/vendor/{prophet-linux → arm64-darwin}/licenses/eigen-mpl2-license.txt +0 -0
  43. data/vendor/{prophet-linux → arm64-darwin}/licenses/prophet-license.txt +0 -0
  44. data/vendor/{prophet-linux → arm64-darwin}/licenses/rapidjson-license.txt +0 -0
  45. data/vendor/{prophet-linux → arm64-darwin}/licenses/stan-license.txt +0 -0
  46. data/vendor/{prophet-linux → arm64-darwin}/licenses/stan-math-license.txt +0 -0
  47. data/vendor/arm64-darwin/licenses/sundials-license.txt +29 -0
  48. data/vendor/arm64-darwin/licenses/sundials-notice.txt +21 -0
  49. data/vendor/{prophet-linux → arm64-darwin}/licenses/tbb-license.txt +0 -0
  50. data/vendor/{prophet-linux → arm64-darwin}/licenses/tbb-third-party-programs.txt +0 -0
  51. data/vendor/x86_64-darwin/bin/prophet +0 -0
  52. data/vendor/x86_64-darwin/lib/libtbb.dylib +0 -0
  53. data/vendor/{prophet-mac → x86_64-darwin}/lib/libtbbmalloc.dylib +0 -0
  54. data/vendor/{prophet-mac → x86_64-darwin}/lib/libtbbmalloc_proxy.dylib +0 -0
  55. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/boost-license.txt +0 -0
  56. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/cli11-license.txt +0 -0
  57. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/cmdstan-license.txt +0 -0
  58. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/eigen-bsd-license.txt +0 -0
  59. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/eigen-mpl2-license.txt +0 -0
  60. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/prophet-license.txt +0 -0
  61. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/rapidjson-license.txt +0 -0
  62. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/stan-license.txt +0 -0
  63. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/stan-math-license.txt +0 -0
  64. data/vendor/x86_64-darwin/licenses/sundials-license.txt +29 -0
  65. data/vendor/x86_64-darwin/licenses/sundials-notice.txt +21 -0
  66. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/tbb-license.txt +0 -0
  67. data/vendor/{prophet-mac-arm → x86_64-darwin}/licenses/tbb-third-party-programs.txt +0 -0
  68. data/vendor/x86_64-linux/bin/prophet +0 -0
  69. data/vendor/{prophet-linux → x86_64-linux}/lib/libtbb.so +0 -0
  70. data/vendor/x86_64-linux/lib/libtbb.so.2 +0 -0
  71. data/vendor/{prophet-linux → x86_64-linux}/lib/libtbbmalloc.so +0 -0
  72. data/vendor/x86_64-linux/lib/libtbbmalloc.so.2 +0 -0
  73. data/vendor/{prophet-linux → x86_64-linux}/lib/libtbbmalloc_proxy.so +0 -0
  74. data/vendor/{prophet-linux → x86_64-linux}/lib/libtbbmalloc_proxy.so.2 +0 -0
  75. data/vendor/{prophet-mac → x86_64-linux}/licenses/boost-license.txt +0 -0
  76. data/vendor/{prophet-mac → x86_64-linux}/licenses/cli11-license.txt +0 -0
  77. data/vendor/{prophet-mac → x86_64-linux}/licenses/cmdstan-license.txt +0 -0
  78. data/vendor/{prophet-mac → x86_64-linux}/licenses/eigen-bsd-license.txt +0 -0
  79. data/vendor/{prophet-mac → x86_64-linux}/licenses/eigen-mpl2-license.txt +0 -0
  80. data/vendor/{prophet-mac → x86_64-linux}/licenses/prophet-license.txt +0 -0
  81. data/vendor/{prophet-mac → x86_64-linux}/licenses/rapidjson-license.txt +0 -0
  82. data/vendor/{prophet-mac → x86_64-linux}/licenses/stan-license.txt +0 -0
  83. data/vendor/{prophet-mac → x86_64-linux}/licenses/stan-math-license.txt +0 -0
  84. data/vendor/x86_64-linux/licenses/sundials-license.txt +29 -0
  85. data/vendor/x86_64-linux/licenses/sundials-notice.txt +21 -0
  86. data/vendor/{prophet-mac → x86_64-linux}/licenses/tbb-license.txt +0 -0
  87. data/vendor/{prophet-mac → x86_64-linux}/licenses/tbb-third-party-programs.txt +0 -0
  88. metadata +79 -74
  89. data/stan/win/prophet.stan +0 -175
  90. data/vendor/prophet-linux/bin/prophet +0 -0
  91. data/vendor/prophet-linux/lib/libtbb.so.2 +0 -0
  92. data/vendor/prophet-linux/lib/libtbbmalloc.so.2 +0 -0
  93. data/vendor/prophet-linux/licenses/sundials-license.txt +0 -67
  94. data/vendor/prophet-linux-arm/bin/prophet +0 -0
  95. data/vendor/prophet-linux-arm/licenses/sundials-license.txt +0 -67
  96. data/vendor/prophet-mac/bin/prophet +0 -0
  97. data/vendor/prophet-mac/lib/libtbb.dylib +0 -0
  98. data/vendor/prophet-mac/licenses/sundials-license.txt +0 -67
  99. data/vendor/prophet-mac-arm/bin/prophet +0 -0
  100. data/vendor/prophet-mac-arm/lib/libtbb.dylib +0 -0
  101. data/vendor/prophet-mac-arm/licenses/sundials-license.txt +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf304cc6aa3af6ec1165de157a38b92ca32f1423c0ac9807d69407c566ccb72b
4
- data.tar.gz: 8e86c3b881113af71d5636e221b1bc3d5692fda0245946be19b6bd32151a9205
3
+ metadata.gz: 2bcbd43f3750bc8c70fe28f2b0b42e88464724601daa754a9d60d8e8e354c701
4
+ data.tar.gz: c16f1ab7f2d48419543b54f326fc98ac1261c7e5ceaf7d3b0fd352b87a2fdcb3
5
5
  SHA512:
6
- metadata.gz: 123be484141a21957e8e137eeba5c316e773f7e0e8049ad2db719ddafb97d0455d5c8d414452ff46a97f910c0f082a3b38a613e0635061c073a1b81270cf38b5
7
- data.tar.gz: 958f8774ef5fce334645ff8fa42124e7535d7d69d344b929a53462a0e9296ec68e82465980bdb8b9f08bc62ddb7e6e3876d9371f85ff0cbbca8c36238375759d
6
+ metadata.gz: e8b3cf363a665f063d7045b3c34c124021281e063e61ff99e7bd98ba774a0e40a2d379aeb53f521833724b11d5ff1c7934820b73095ad5384b70066fc20e5e36
7
+ data.tar.gz: 177f8eab90b9be0e5112c3d158ef9b522309143c559a97ffa206b7cc63a83f0eb70e75d7e1f8ab9640e57e403bd85d1469ecdb9137b0be8acc03c7ff09a91447
data/CHANGELOG.md CHANGED
@@ -1,4 +1,17 @@
1
- ## 0.3.0 (2021-04-24)
1
+ ## 0.4.0 (2022-07-07)
2
+
3
+ - Added support for saving and loading models
4
+ - Updated holidays
5
+
6
+ ## 0.3.2 (2022-05-15)
7
+
8
+ - Added advanced API options to `forecast` and `anomalies` methods
9
+
10
+ ## 0.3.1 (2022-04-28)
11
+
12
+ - Improved error message for missing columns
13
+
14
+ ## 0.3.0 (2022-04-24)
2
15
 
3
16
  - Switched to precompiled models
4
17
  - Dropped support for Ruby < 2.7
data/LICENSE.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) Facebook, Inc. and its affiliates.
4
- Copyright (c) 2020 Andrew Kane
4
+ Copyright (c) 2020-2022 Andrew Kane
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining
7
7
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -22,6 +22,8 @@ gem "prophet-rb"
22
22
 
23
23
  ## Simple API
24
24
 
25
+ ### Forecasting
26
+
25
27
  Get future predictions for a time series
26
28
 
27
29
  ```ruby
@@ -48,16 +50,46 @@ series = User.group_by_day(:created_at).count
48
50
  Prophet.forecast(series)
49
51
  ```
50
52
 
53
+ And supports [advanced API](#advanced-api) options
54
+
55
+ ```ruby
56
+ Prophet.forecast(series, growth: "logistic", weekly_seasonality: false)
57
+ ```
58
+
59
+ ### Anomaly Detection
60
+
51
61
  Detect anomalies in a time series
52
62
 
53
63
  ```ruby
54
64
  Prophet.anomalies(series)
55
65
  ```
56
66
 
67
+ Specify the width of uncertainty intervals (decrease for more anomalies)
68
+
69
+ ```ruby
70
+ Prophet.anomalies(series, interval_width: 0.99)
71
+ ```
72
+
73
+ Also supports [advanced API](#advanced-api) options
74
+
75
+ ```ruby
76
+ Prophet.anomalies(series, growth: "logistic", weekly_seasonality: false)
77
+ ```
78
+
57
79
  ## Advanced API
58
80
 
59
81
  Check out the [Prophet documentation](https://facebook.github.io/prophet/docs/quick_start.html) for a great explanation of all of the features. The advanced API follows the Python API and supports the same features. It uses [Rover](https://github.com/ankane/rover) for data frames.
60
82
 
83
+ - [Quick Start](#advanced-quick-start)
84
+ - [Plots](#plots)
85
+ - [Saturating Forecasts](#saturating-forecasts)
86
+ - [Trend Changepoints](#trend-changepoints)
87
+ - [Holidays and Special Events](#holidays-and-special-events)
88
+ - [Multiplicative Seasonality](#multiplicative-seasonality)
89
+ - [Uncertainty Intervals](#uncertainty-intervals)
90
+ - [Non-Daily Data](#non-daily-data)
91
+ - [Saving Models](#saving-models)
92
+
61
93
  ## Advanced Quick Start
62
94
 
63
95
  [Explanation](https://facebook.github.io/prophet/docs/quick_start.html)
@@ -206,7 +238,7 @@ Add country-specific holidays
206
238
 
207
239
  ```ruby
208
240
  m = Prophet.new
209
- m.add_country_holidays(country_name: "US")
241
+ m.add_country_holidays("US")
210
242
  m.fit(df)
211
243
  ```
212
244
 
@@ -276,6 +308,24 @@ future = m.make_future_dataframe(periods: 300, freq: "H")
276
308
  forecast = m.predict(future)
277
309
  ```
278
310
 
311
+ ## Saving Models
312
+
313
+ [Explanation](https://facebook.github.io/prophet/docs/additional_topics.html#saving-models)
314
+
315
+ Save a model
316
+
317
+ ```ruby
318
+ File.write("model.json", m.to_json)
319
+ ```
320
+
321
+ Load a model
322
+
323
+ ```ruby
324
+ m = Prophet.from_json(File.read("model.json"))
325
+ ```
326
+
327
+ Uses the same format as Python, so models can be saved and loaded in either language
328
+
279
329
  ## Resources
280
330
 
281
331
  - [Forecasting at Scale](https://peerj.com/preprints/3190.pdf)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017-2022 <maurizio.montel@gmail.com>
2
+ Copyright (c) 2014-2017 <ryanssdev@icloud.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ Holidays from 1995 through 2044 are generated from [this script](https://github.com/facebook/prophet/blob/main/python/scripts/generate_holidays_file.py).
2
+
3
+ The data is primarily based on the Python [holidays](https://pypi.org/project/holidays/) package.