Business intelligence made simple
Added support for forecasting more periods with Prophet
Andrew Kane814019b1aa79
diff --git a/README.md b/README.mdindex f3c08e3b..a7ddb4f2 100644--- a/README.md+++ b/README.md@@ -434,12 +434,10 @@ A forecast link will appear for queries that return 2 columns with types timesta### Prophet-**Note:** Prophet only supports daily forecasts right now.-Add [prophet](https://github.com/ankane/prophet) to your Gemfile:```ruby-gem 'prophet-rb'+gem 'prophet-rb', '>= 0.2.1'```And add to `config/blazer.yml`:diff --git a/lib/blazer/result.rb b/lib/blazer/result.rbindex a5bf9201..0a5e7253 100644--- a/lib/blazer/result.rb+++ b/lib/blazer/result.rb@@ -94,29 +94,10 @@ module Blazercase Blazer.forecastingwhen "prophet"require "prophet"-- df =- Daru::DataFrame.new(- "ds" => @rows.map { |r| r[0] },- "y" => @rows.map { |r| r[1] }- )-- # TODO determine frequency- freq = "D"-- m = Prophet.new- m.fit(df)- future = m.make_future_dataframe(periods: count, freq: freq, include_history: false)- fcst = m.predict(future)- ds = fcst["ds"]- if @rows[0][0].is_a?(Date)- ds = ds.map { |v| v.to_date }- end- forecast = ds.zip(fcst["yhat"]).to_h+ forecast = Prophet.forecast(@rows.to_h, count: count)elserequire "trend"-- forecast = Trend.forecast(Hash[@rows], count: count)+ forecast = Trend.forecast(@rows.to_h, count: count)end# round integers