README.md in prophet-rb-0.2.0 vs README.md in prophet-rb-0.2.1

- old
+ new

@@ -18,23 +18,51 @@ ```ruby gem 'prophet-rb' ``` -## Documentation +## Simple API -Check out the [Prophet documentation](https://facebook.github.io/prophet/docs/quick_start.html) for a great explanation of all of the features. The Ruby API follows the Python API and supports the same features. +Get future predictions for a time series -## Quick Start +```ruby +series = { + Date.parse("2020-01-01") => 100, + Date.parse("2020-01-02") => 150, + Date.parse("2020-01-03") => 136, + # ... +} +Prophet.forecast(series) +``` + +Specify the number of predictions to return + +```ruby +Prophet.forecast(series, count: 3) +``` + +Works great with [Groupdate](https://github.com/ankane/groupdate) + +```ruby +series = User.group_by_day(:created_at).count +Prophet.forecast(series) +``` + +## Advanced API + +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. + +## Advanced Quick Start + [Explanation](https://facebook.github.io/prophet/docs/quick_start.html) Create a data frame with `ds` and `y` columns - here’s [an example](examples/example_wp_log_peyton_manning.csv) you can use ```ruby df = Rover.read_csv("example_wp_log_peyton_manning.csv") -df.head(5) +df.head ``` ds | y --- | --- 2007-12-10 | 9.59076113 @@ -52,11 +80,11 @@ Make a data frame with a `ds` column for future predictions ```ruby future = m.make_future_dataframe(periods: 365) -future.tail(5) +future.tail ``` ds | --- | 2017-01-15 | @@ -67,11 +95,11 @@ Make predictions ```ruby forecast = m.predict(future) -forecast["ds", "yhat", "yhat_lower", "yhat_upper"].tail(5) +forecast[["ds", "yhat", "yhat_lower", "yhat_upper"]].tail ``` ds | yhat | yhat_lower | yhat_upper --- | --- | --- | --- 2017-01-15 | 8.21192840 | 7.52526442 | 8.92389960 @@ -145,24 +173,24 @@ Create a data frame with `holiday` and `ds` columns. Include all occurrences in your past data and future occurrences you’d like to forecast. ```ruby playoffs = Rover::DataFrame.new( - "holiday" => ["playoff"] * 14, + "holiday" => "playoff", "ds" => ["2008-01-13", "2009-01-03", "2010-01-16", "2010-01-24", "2010-02-07", "2011-01-08", "2013-01-12", "2014-01-12", "2014-01-19", "2014-02-02", "2015-01-11", "2016-01-17", "2016-01-24", "2016-02-07"], - "lower_window" => [0] * 14, - "upper_window" => [1] * 14 + "lower_window" => 0, + "upper_window" => 1 ) superbowls = Rover::DataFrame.new( - "holiday" => ["superbowl"] * 3, + "holiday" => "superbowl", "ds" => ["2010-02-07", "2014-02-02", "2016-02-07"], - "lower_window" => [0] * 3, - "upper_window" => [1] * 3 + "lower_window" => 0, + "upper_window" => 1 ) holidays = playoffs.concat(superbowls) m = Prophet.new(holidays: holidays) m.fit(df) @@ -243,9 +271,18 @@ ``` ## Resources - [Forecasting at Scale](https://peerj.com/preprints/3190.pdf) + +## Upgrading + +### 0.2.0 + +Prophet now uses [Rover](https://github.com/ankane/rover) instead of Daru. Two changes you may need to make are: + +- `Rover.read_csv` instead of `Daru::DataFrame.from_csv` +- `df[["ds", "yhat"]]` instead of `df["ds", "yhat"]` ## Credits This library was ported from the [Prophet Python library](https://github.com/facebook/prophet) and is available under the same license.