Sha256: 9bcf31ed44f01eb0f35096297c35c62df592cb41a3aeb410c071707437fcf9c0

Contents?: true

Size: 791 Bytes

Versions: 14

Compression:

Stored size: 791 Bytes

Contents

Blazer.register_anomaly_detector "anomaly_detection" do |series|
  anomalies = AnomalyDetection.detect(series.to_h, period: :auto)
  anomalies.include?(series.last[0])
end

Blazer.register_anomaly_detector "prophet" do |series|
  df = Rover::DataFrame.new(series[0..-2].map { |v| {"ds" => v[0], "y" => v[1]} })
  m = Prophet.new(interval_width: 0.99)
  m.logger.level = ::Logger::FATAL # no logging
  m.fit(df)
  future = Rover::DataFrame.new(series[-1..-1].map { |v| {"ds" => v[0]} })
  forecast = m.predict(future).to_a[0]
  lower = forecast["yhat_lower"]
  upper = forecast["yhat_upper"]
  value = series.last[1]
  value < lower || value > upper
end

Blazer.register_anomaly_detector "trend" do |series|
  anomalies = Trend.anomalies(series.to_h)
  anomalies.include?(series.last[0])
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
blazer-3.1.0 lib/blazer/anomaly_detectors.rb
blazer-3.0.4 lib/blazer/anomaly_detectors.rb
blazer_xlsx-3.0.8 lib/blazer/anomaly_detectors.rb
blazer_xlsx-3.0.7 lib/blazer/anomaly_detectors.rb
blazer_xlsx-3.0.6 lib/blazer/anomaly_detectors.rb
blazer_xlsx-3.0.5 lib/blazer/anomaly_detectors.rb
blazer-3.0.3 lib/blazer/anomaly_detectors.rb
blazer-3.0.2 lib/blazer/anomaly_detectors.rb
finery-3.0.3 lib/blazer/anomaly_detectors.rb
finery-3.0.2 lib/blazer/anomaly_detectors.rb
blazer-3.0.1 lib/blazer/anomaly_detectors.rb
finery-3.0.1 lib/blazer/anomaly_detectors.rb
finery-3.0.0 lib/blazer/anomaly_detectors.rb
blazer-3.0.0 lib/blazer/anomaly_detectors.rb