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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 506ab7cfb738d7f7289db812134b2fb64d6371da66e7586a1bcc254b26c6fa1c
4
- data.tar.gz: ed97303bb3563bdebe86cf9865ec04142e9b3fa0e3f7bfdea8ae6a8a2ff8570f
3
+ metadata.gz: ec194b65cb4bfd061bac7868cad435fea98df148fc7e129d8562c55ed3c91fcc
4
+ data.tar.gz: 45b9357d04a6c01a8d4ad6ce7888065b946e39cbfa743b650a41d5b12cf9989e
5
5
  SHA512:
6
- metadata.gz: 5339ac3f8e7f26539137dc23b40d481013bc1ec082a008221edff00ea574ab08617956849e7cd221af40e9b12105630cbe294f8b5e2cfa1a33670d9c1fcd970c
7
- data.tar.gz: 63b64fbef8414f65dfb39b7c266e780790f28b42cc6f2a0da415885b293c57ba309d50243e9d9ad2d61d93fe034017a31871cef26eed5e33b01cc651816eed3c
6
+ metadata.gz: cd67e017dac94994c960a42b59fb55f2c33560d9233bb2764581cef3154bc03bd75ba29283f8e51788fcde356f682e9fe487a5506ccb82ed10ab373b11774989
7
+ data.tar.gz: a07444bc2d9d6a29b6b09303b5d4cef60709a4a4be0a31d2a4526f79366696875b72a36923747b673f05b686c857a78be803f2475fbbc89ffb3dac4a1c856c07
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.5 (2021-07-28)
2
+
3
+ - Added `anomalies` method
4
+
1
5
  ## 0.2.4 (2021-04-02)
2
6
 
3
7
  - Added support for flat growth
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
@@ -1,3 +1,3 @@
1
1
  module Prophet
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
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
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-04-03 00:00:00.000000000 Z
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.3
96
+ rubygems_version: 3.2.22
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Time series forecasting for Ruby