prophet-rb 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/prophet.rb +10 -0
- 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: ec194b65cb4bfd061bac7868cad435fea98df148fc7e129d8562c55ed3c91fcc
|
4
|
+
data.tar.gz: 45b9357d04a6c01a8d4ad6ce7888065b946e39cbfa743b650a41d5b12cf9989e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd67e017dac94994c960a42b59fb55f2c33560d9233bb2764581cef3154bc03bd75ba29283f8e51788fcde356f682e9fe487a5506ccb82ed10ab373b11774989
|
7
|
+
data.tar.gz: a07444bc2d9d6a29b6b09303b5d4cef60709a4a4be0a31d2a4526f79366696875b72a36923747b673f05b686c857a78be803f2475fbbc89ffb3dac4a1c856c07
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -48,6 +48,12 @@ series = User.group_by_day(:created_at).count
|
|
48
48
|
Prophet.forecast(series)
|
49
49
|
```
|
50
50
|
|
51
|
+
Detect anomalies in a time series
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Prophet.anomalies(series)
|
55
|
+
```
|
56
|
+
|
51
57
|
## Advanced API
|
52
58
|
|
53
59
|
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.
|
data/lib/prophet.rb
CHANGED
@@ -83,4 +83,14 @@ module Prophet
|
|
83
83
|
end
|
84
84
|
result.map { |v| [v["ds"], v["yhat"]] }.to_h
|
85
85
|
end
|
86
|
+
|
87
|
+
def self.anomalies(series)
|
88
|
+
df = Rover::DataFrame.new(series.map { |k, v| {"ds" => k, "y" => v} })
|
89
|
+
m = Prophet.new(interval_width: 0.99)
|
90
|
+
m.logger.level = ::Logger::FATAL # no logging
|
91
|
+
m.fit(df)
|
92
|
+
forecast = m.predict(df)
|
93
|
+
# filter df["ds"] to ensure dates/times in same format as input
|
94
|
+
df["ds"][(df["y"] < forecast["yhat_lower"]) | (df["y"] > forecast["yhat_upper"])].to_a
|
95
|
+
end
|
86
96
|
end
|
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.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdstan
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.2.
|
96
|
+
rubygems_version: 3.2.22
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Time series forecasting for Ruby
|