Prophet: Plots not showing

Created on 3 Mar 2017  路  5Comments  路  Source: facebook/prophet

I was working through the quickstart and for some reason, the plots won't show. No errors, everything installed just fine, code executes just fine but no graphs.

System:
MacOSX (El Capitian)
Python 3.6

Prophet Install:

pip3 install fbprophet
Requirement already satisfied: fbprophet in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: pandas in /usr/local/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: pystan in /usr/local/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: python-dateutil>=2 in /usr/local/lib/python3.6/site-packages (from pandas->fbprophet)
Requirement already satisfied: numpy>=1.7.0 in /usr/local/lib/python3.6/site-packages (from pandas->fbprophet)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/site-packages (from pandas->fbprophet)
Requirement already satisfied: Cython!=0.25.1,>=0.22 in /usr/local/lib/python3.6/site-packages (from pystan->fbprophet)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2->pandas->fbprophet)

Pystan is installed

pip3 install pystan
Requirement already satisfied: pystan in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: Cython!=0.25.1,>=0.22 in /usr/local/lib/python3.6/site-packages (from pystan)
Requirement already satisfied: numpy>=1.7 in /usr/local/lib/python3.6/site-packages (from pystan)

Code:

import pandas as pd
import numpy as np
from fbprophet import Prophet

df = pd.read_csv('~/tmp/example_wp_peyton_manning.csv')
df['y'] = np.log(df['y'])
df.head()

m = Prophet()
m.fit(df);

future = m.make_future_dataframe(periods=36)
future.tail()

forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

m.plot(forecast);

m.plot_components(forecast);

Output:

python3 growthprediction.py
STAN OPTIMIZATION COMMAND (LBFGS)
init = user
save_iterations = 1
init_alpha = 0.001
tol_obj = 1e-12
tol_grad = 1e-08
tol_param = 1e-08
tol_rel_obj = 10000
tol_rel_grad = 1e+07
history_size = 5
seed = 1120977435
initial log joint probability = -19.4685
    Iter      log prob        ||dx||      ||grad||       alpha      alpha0  # evals  Notes
      99       7977.57   0.000941357       431.339      0.3404      0.3404      134
     199        7988.7   0.000894011       356.862       0.739       0.739      241
     299       7996.29    0.00359033       180.856           1           1      358
     399       8000.11   0.000546236       205.358     0.09131      0.7253      481
     499       8002.89    0.00024026        99.613           1           1      608
     514       8003.11   5.25911e-05       135.817   7.646e-07       0.001      671  LS failed, Hessian reset
     580       8003.41   3.04884e-05       92.4947    1.88e-07       0.001      798  LS failed, Hessian reset
     599       8003.49   8.15685e-05        83.046      0.6885      0.6885      821
     607        8003.5   2.60204e-05       67.9783   1.712e-07       0.001      874  LS failed, Hessian reset
     654       8003.64   0.000118504       280.906   6.562e-07       0.001      973  LS failed, Hessian reset
     699       8003.75   2.52751e-06       58.0645      0.3238           1     1029
     705       8003.75   4.61033e-07       59.0008      0.2964           1     1037
Optimization terminated normally:
  Convergence detected: relative gradient magnitude is below tolerance

Not sure what's happening hear but I thought i'd report an issue just incase.

Most helpful comment

you may have to add plt.show() to cause the plots to render if you're executing that code outside of a notebook.

All 5 comments

you may have to add plt.show() to cause the plots to render if you're executing that code outside of a notebook.

What lemonlaug said is right, I fixed it by add two lines code:
`import matplotlib.pyplot as plt # first line

...
m.plot(forecast);
plt.show() # second line
`

@cooljacket ,i add the plt.show(), but still only get the output below
Optimization terminated normally: Convergence detected: relative gradient magnitude is below tolerance

environment:
Windows+Python 3.6

i replace the data with your example https://raw.githubusercontent.com/facebookincubator/prophet/master/examples/example_wp_peyton_manning.csv
it works, the data only could be daily? the format like this '%Y-%m-%d %H:%M:%S is not allowed?

the data can be at any frequency allowed in pd.date_range
you can make it work by modifying the line:
future = m.make_future_dataframe(periods=36)
to:
future = m.make_future_dataframe(periods=36, freq='H') or any other frequency
note that it can be aggregated as:
future = m.make_future_dataframe(periods=36, freq='5H')

Was this page helpful?
0 / 5 - 0 ratings