"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/_docs/quick_start.md" between
prophet-0.7.tar.gz and prophet-1.0.tar.gz

About: Prophet is a tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

quick_start.md  (prophet-0.7):quick_start.md  (prophet-1.0)
skipping to change at line 27 skipping to change at line 27
The input to Prophet is always a dataframe with two columns: `ds` and `y`. The `ds` (datestamp) column should be of a format expected by Pandas, ideally YYYY-M M-DD for a date or YYYY-MM-DD HH:MM:SS for a timestamp. The `y` column must be n umeric, and represents the measurement we wish to forecast. The input to Prophet is always a dataframe with two columns: `ds` and `y`. The `ds` (datestamp) column should be of a format expected by Pandas, ideally YYYY-M M-DD for a date or YYYY-MM-DD HH:MM:SS for a timestamp. The `y` column must be n umeric, and represents the measurement we wish to forecast.
As an example, let's look at a time series of the log daily page views for the W ikipedia page for [Peyton Manning](https://en.wikipedia.org/wiki/Peyton_Manning) . We scraped this data using the [Wikipediatrend](https://cran.r-project.org/pa ckage=wikipediatrend) package in R. Peyton Manning provides a nice example beca use it illustrates some of Prophet's features, like multiple seasonality, changi ng growth rates, and the ability to model special days (such as Manning's playof f and superbowl appearances). The CSV is available [here](https://github.com/fac ebook/prophet/blob/master/examples/example_wp_log_peyton_manning.csv). As an example, let's look at a time series of the log daily page views for the W ikipedia page for [Peyton Manning](https://en.wikipedia.org/wiki/Peyton_Manning) . We scraped this data using the [Wikipediatrend](https://cran.r-project.org/pa ckage=wikipediatrend) package in R. Peyton Manning provides a nice example beca use it illustrates some of Prophet's features, like multiple seasonality, changi ng growth rates, and the ability to model special days (such as Manning's playof f and superbowl appearances). The CSV is available [here](https://github.com/fac ebook/prophet/blob/master/examples/example_wp_log_peyton_manning.csv).
First we'll import the data: First we'll import the data:
```python ```python
# Python # Python
import pandas as pd import pandas as pd
from fbprophet import Prophet from prophet import Prophet
``` ```
```python ```python
# Python # Python
df = pd.read_csv('../examples/example_wp_log_peyton_manning.csv') df = pd.read_csv('../examples/example_wp_log_peyton_manning.csv')
df.head() df.head()
``` ```
<div> <div>
<style scoped> <style scoped>
.dataframe tbody tr th:only-of-type { .dataframe tbody tr th:only-of-type {
skipping to change at line 184 skipping to change at line 184
<th>ds</th> <th>ds</th>
<th>yhat</th> <th>yhat</th>
<th>yhat_lower</th> <th>yhat_lower</th>
<th>yhat_upper</th> <th>yhat_upper</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th>3265</th> <th>3265</th>
<td>2017-01-15</td> <td>2017-01-15</td>
<td>8.204125</td> <td>8.211542</td>
<td>7.449654</td> <td>7.444742</td>
<td>8.946255</td> <td>8.903545</td>
</tr> </tr>
<tr> <tr>
<th>3266</th> <th>3266</th>
<td>2017-01-16</td> <td>2017-01-16</td>
<td>8.529148</td> <td>8.536553</td>
<td>7.792752</td> <td>7.847804</td>
<td>9.284594</td> <td>9.211145</td>
</tr> </tr>
<tr> <tr>
<th>3267</th> <th>3267</th>
<td>2017-01-17</td> <td>2017-01-17</td>
<td>8.316555</td> <td>8.323968</td>
<td>7.563541</td> <td>7.541829</td>
<td>9.029357</td> <td>9.035461</td>
</tr> </tr>
<tr> <tr>
<th>3268</th> <th>3268</th>
<td>2017-01-18</td> <td>2017-01-18</td>
<td>8.149153</td> <td>8.156621</td>
<td>7.384345</td> <td>7.404457</td>
<td>8.840279</td> <td>8.830642</td>
</tr> </tr>
<tr> <tr>
<th>3269</th> <th>3269</th>
<td>2017-01-19</td> <td>2017-01-19</td>
<td>8.161075</td> <td>8.168561</td>
<td>7.430352</td> <td>7.438865</td>
<td>8.859482</td> <td>8.908668</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
You can plot the forecast by calling the `Prophet.plot` method and passing in yo ur forecast dataframe. You can plot the forecast by calling the `Prophet.plot` method and passing in yo ur forecast dataframe.
```python ```python
# Python # Python
fig1 = m.plot(forecast) fig1 = m.plot(forecast)
skipping to change at line 238 skipping to change at line 238
If you want to see the forecast components, you can use the `Prophet.plot_compon ents` method. By default you'll see the trend, yearly seasonality, and weekly s easonality of the time series. If you include holidays, you'll see those here, too. If you want to see the forecast components, you can use the `Prophet.plot_compon ents` method. By default you'll see the trend, yearly seasonality, and weekly s easonality of the time series. If you include holidays, you'll see those here, too.
```python ```python
# Python # Python
fig2 = m.plot_components(forecast) fig2 = m.plot_components(forecast)
``` ```
![png](/prophet/static/quick_start_files/quick_start_14_0.png) ![png](/prophet/static/quick_start_files/quick_start_14_0.png)
An interactive figure of the forecast and components can be created with plotly. You will need to install plotly 4.0 or above separately, as it will not by defa ult be installed with fbprophet. You will also need to install the `notebook` an d `ipywidgets` packages. An interactive figure of the forecast and components can be created with plotly. You will need to install plotly 4.0 or above separately, as it will not by defa ult be installed with prophet. You will also need to install the `notebook` and `ipywidgets` packages.
```python ```python
# Python # Python
from fbprophet.plot import plot_plotly, plot_components_plotly from prophet.plot import plot_plotly, plot_components_plotly
plot_plotly(m, forecast) plot_plotly(m, forecast)
``` ```
```python ```python
# Python # Python
plot_components_plotly(m, forecast) plot_components_plotly(m, forecast)
``` ```
More details about the options available for each method are available in the do cstrings, for example, via `help(Prophet)` or `help(Prophet.fit)`. The [R refere nce manual](https://cran.r-project.org/web/packages/prophet/prophet.pdf) on CRAN provides a concise list of all of the available functions, each of which has a Python equivalent. More details about the options available for each method are available in the do cstrings, for example, via `help(Prophet)` or `help(Prophet.fit)`. The [R refere nce manual](https://cran.r-project.org/web/packages/prophet/prophet.pdf) on CRAN provides a concise list of all of the available functions, each of which has a Python equivalent.
<a id="r-api"> </a> <a id="r-api"> </a>
## R API ## R API
In R, we use the normal model fitting API. We provide a `prophet` function that performs fitting and returns a model object. You can then call `predict` and ` plot` on this model object. In R, we use the normal model fitting API. We provide a `prophet` function that performs fitting and returns a model object. You can then call `predict` and ` plot` on this model object.
```R ```R
# R # R
library(prophet) library(prophet)
``` ```
R[write to console]: Loading required package: Rcpp
R[write to console]: Loading required package: rlang
First we read in the data and create the outcome variable. As in the Python API, this is a dataframe with columns `ds` and `y`, containing the date and numeric value respectively. The ds column should be YYYY-MM-DD for a date, or YYYY-MM-DD HH:MM:SS for a timestamp. As above, we use here the log number of views to Peyt on Manning's Wikipedia page, available [here](https://github.com/facebook/prophe t/blob/master/examples/example_wp_log_peyton_manning.csv). First we read in the data and create the outcome variable. As in the Python API, this is a dataframe with columns `ds` and `y`, containing the date and numeric value respectively. The ds column should be YYYY-MM-DD for a date, or YYYY-MM-DD HH:MM:SS for a timestamp. As above, we use here the log number of views to Peyt on Manning's Wikipedia page, available [here](https://github.com/facebook/prophe t/blob/master/examples/example_wp_log_peyton_manning.csv).
```R ```R
# R # R
df <- read.csv('../examples/example_wp_log_peyton_manning.csv') df <- read.csv('../examples/example_wp_log_peyton_manning.csv')
``` ```
We call the `prophet` function to fit the model. The first argument is the hist orical dataframe. Additional arguments control how Prophet fits the data and ar e described in later pages of this documentation. We call the `prophet` function to fit the model. The first argument is the hist orical dataframe. Additional arguments control how Prophet fits the data and ar e described in later pages of this documentation.
```R ```R
# R # R
m <- prophet(df) m <- prophet(df)
``` ```
Predictions are made on a dataframe with a column `ds` containing the dates for which predictions are to be made. The `make_future_dataframe` function takes the model object and a number of periods to forecast and produces a suitable datafr ame. By default it will also include the historical dates so we can evaluate in- sample fit. Predictions are made on a dataframe with a column `ds` containing the dates for which predictions are to be made. The `make_future_dataframe` function takes the model object and a number of periods to forecast and produces a suitable datafr ame. By default it will also include the historical dates so we can evaluate in- sample fit.
```R ```R
# R # R
future <- make_future_dataframe(m, periods = 365) future <- make_future_dataframe(m, periods = 365)
tail(future) tail(future)
``` ```
ds ds
3265 2017-01-14 3265 2017-01-14
3266 2017-01-15 3266 2017-01-15
3267 2017-01-16 3267 2017-01-16
3268 2017-01-17 3268 2017-01-17
3269 2017-01-18 3269 2017-01-18
3270 2017-01-19 3270 2017-01-19
As with most modeling procedures in R, we use the generic `predict` function to get our forecast. The `forecast` object is a dataframe with a column `yhat` cont aining the forecast. It has additional columns for uncertainty intervals and sea sonal components. As with most modeling procedures in R, we use the generic `predict` function to get our forecast. The `forecast` object is a dataframe with a column `yhat` cont aining the forecast. It has additional columns for uncertainty intervals and sea sonal components.
```R ```R
# R # R
forecast <- predict(m, future) forecast <- predict(m, future)
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')]) tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')])
``` ```
ds yhat yhat_lower yhat_upper ds yhat yhat_lower yhat_upper
3265 2017-01-14 7.824163 7.127881 8.609668 3265 2017-01-14 7.818359 7.071228 8.550957
3266 2017-01-15 8.205942 7.452071 8.904387 3266 2017-01-15 8.200125 7.475725 8.869495
3267 2017-01-16 8.530942 7.742400 9.300974 3267 2017-01-16 8.525104 7.747071 9.226915
3268 2017-01-17 8.318327 7.606534 9.071184 3268 2017-01-17 8.312482 7.551904 9.046774
3269 2017-01-18 8.150948 7.440224 8.902922 3269 2017-01-18 8.145098 7.390770 8.863692
3270 2017-01-19 8.162839 7.385953 8.890669 3270 2017-01-19 8.156964 7.381716 8.866507
You can use the generic `plot` function to plot the forecast, by passing in the model and the forecast dataframe. You can use the generic `plot` function to plot the forecast, by passing in the model and the forecast dataframe.
```R ```R
# R # R
plot(m, forecast) plot(m, forecast)
``` ```
![png](/prophet/static/quick_start_files/quick_start_30_0.png) ![png](/prophet/static/quick_start_files/quick_start_30_0.png)
 End of changes. 12 change blocks. 
26 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)