prophet-rb 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/prophet/forecaster.rb +34 -8
- data/lib/prophet/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6bcb7718fabc1b3eb85bfac7e772f4e792b190acb7147f533c105bb67ce7c2
|
4
|
+
data.tar.gz: 43446f1d8923d712e4c7856b3529f0c36b5c32c3dbfec59ca2124b901e8a8b0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6c0802652ee69eeef122356743c7ea7b86d3e6252a78852dc8b5ab88e3bd1cb1aa88cb4193fe1de6581a2034b3827f5ccb4a8a0cb4f53af5cc7d5439bb8b3e
|
7
|
+
data.tar.gz: 77d16680eac6f21e60c2e46d4f87f55fa9b8a0778ade2d3d7b244e90ce3978063b6f845ddcaa63d8f38982dcd665ef3b6a1993b394cf280698e4ac1793350a23
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.5.1 (2024-05-06)
|
2
|
+
|
3
|
+
- Added `scaling` option
|
4
|
+
- Fixed issue with yearly seasonality being enabled without enough data
|
5
|
+
- Fixed issue with internal columns in `predict` output (`col`, `col_lower`, and `col_upper`)
|
6
|
+
|
1
7
|
## 0.5.0 (2023-09-05)
|
2
8
|
|
3
9
|
- Added support for Polars
|
data/lib/prophet/forecaster.rb
CHANGED
@@ -27,7 +27,8 @@ module Prophet
|
|
27
27
|
changepoint_prior_scale: 0.05,
|
28
28
|
mcmc_samples: 0,
|
29
29
|
interval_width: 0.80,
|
30
|
-
uncertainty_samples: 1000
|
30
|
+
uncertainty_samples: 1000,
|
31
|
+
scaling: "absmax"
|
31
32
|
)
|
32
33
|
@growth = growth
|
33
34
|
|
@@ -54,6 +55,10 @@ module Prophet
|
|
54
55
|
@mcmc_samples = mcmc_samples
|
55
56
|
@interval_width = interval_width
|
56
57
|
@uncertainty_samples = uncertainty_samples
|
58
|
+
if !["absmax", "minmax"].include?(scaling)
|
59
|
+
raise ArgumentError, "scaling must be one of \"absmax\" or \"minmax\""
|
60
|
+
end
|
61
|
+
@scaling = scaling
|
57
62
|
|
58
63
|
# Set during fitting or by other methods
|
59
64
|
@start = nil
|
@@ -189,7 +194,11 @@ module Prophet
|
|
189
194
|
raise ArgumentError, "Expected column \"floor\"."
|
190
195
|
end
|
191
196
|
else
|
192
|
-
|
197
|
+
if @scaling == "absmax"
|
198
|
+
df["floor"] = 0
|
199
|
+
elsif @scaling == "minmax"
|
200
|
+
df["floor"] = @y_min
|
201
|
+
end
|
193
202
|
end
|
194
203
|
|
195
204
|
if @growth == "logistic"
|
@@ -219,11 +228,22 @@ module Prophet
|
|
219
228
|
|
220
229
|
if @growth == "logistic" && df.include?("floor")
|
221
230
|
@logistic_floor = true
|
222
|
-
|
231
|
+
if @scaling == "absmax"
|
232
|
+
@y_min = (df["y"] - df["floor"]).abs.min.to_f
|
233
|
+
@y_scale = (df["y"] - df["floor"]).abs.max.to_f
|
234
|
+
elsif @scaling == "minmax"
|
235
|
+
@y_min = df["floor"].min
|
236
|
+
@y_scale = (df["cap"].max - @y_min).to_f
|
237
|
+
end
|
223
238
|
else
|
224
|
-
|
239
|
+
if @scaling == "absmax"
|
240
|
+
@y_min = 0.0
|
241
|
+
@y_scale = df["y"].abs.max.to_f
|
242
|
+
elsif @scaling == "minmax"
|
243
|
+
@y_min = df["y"].min
|
244
|
+
@y_scale = (df["y"].max - @y_min).to_f
|
245
|
+
end
|
225
246
|
end
|
226
|
-
@y_scale = (df["y"] - floor).abs.max
|
227
247
|
@y_scale = 1 if @y_scale == 0
|
228
248
|
@start = df["ds"].min
|
229
249
|
@t_scale = df["ds"].max - @start
|
@@ -547,7 +567,7 @@ module Prophet
|
|
547
567
|
days = 86400
|
548
568
|
|
549
569
|
# Yearly seasonality
|
550
|
-
yearly_disable = last - first <
|
570
|
+
yearly_disable = last - first < 730 * days
|
551
571
|
fourier_order = parse_seasonality_args("yearly", @yearly_seasonality, yearly_disable, 10)
|
552
572
|
if fourier_order > 0
|
553
573
|
@seasonalities["yearly"] = {
|
@@ -807,7 +827,7 @@ module Prophet
|
|
807
827
|
|
808
828
|
x = seasonal_features.to_numo
|
809
829
|
data = {}
|
810
|
-
component_cols.vector_names.each do |component|
|
830
|
+
(component_cols.vector_names - ["col"]).each do |component|
|
811
831
|
beta_c = @params["beta"] * component_cols[component].to_numo
|
812
832
|
|
813
833
|
comp = x.dot(beta_c.transpose)
|
@@ -1052,7 +1072,7 @@ module Prophet
|
|
1052
1072
|
"yearly_seasonality", "weekly_seasonality", "daily_seasonality",
|
1053
1073
|
"seasonality_mode", "seasonality_prior_scale", "changepoint_prior_scale",
|
1054
1074
|
"holidays_prior_scale", "mcmc_samples", "interval_width", "uncertainty_samples",
|
1055
|
-
"y_scale", "logistic_floor", "country_holidays", "component_modes"
|
1075
|
+
"y_scale", "y_min", "scaling", "logistic_floor", "country_holidays", "component_modes"
|
1056
1076
|
]
|
1057
1077
|
|
1058
1078
|
PD_SERIES = ["changepoints", "history_dates", "train_holiday_names"]
|
@@ -1169,6 +1189,12 @@ module Prophet
|
|
1169
1189
|
|
1170
1190
|
model_dict = JSON.parse(model_json)
|
1171
1191
|
|
1192
|
+
# handle_simple_attributes_backwards_compat
|
1193
|
+
if !model_dict["scaling"]
|
1194
|
+
model_dict["scaling"] = "absmax"
|
1195
|
+
model_dict["y_min"] = 0.0
|
1196
|
+
end
|
1197
|
+
|
1172
1198
|
# We will overwrite all attributes set in init anyway
|
1173
1199
|
model = Prophet.new
|
1174
1200
|
# Simple types
|
data/lib/prophet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prophet-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdstan
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.5.9
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Time series forecasting for Ruby
|