2017-02-22 23:59:43 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"block_hidden": true,
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext rpy2.ipython\n",
"%matplotlib inline\n",
"from fbprophet import Prophet\n",
"import pandas as pd\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"df = pd.read_csv('../examples/example_wp_peyton_manning.csv')\n",
"df['y'] = np.log(df['y'])\n",
"m = Prophet()\n",
"m.fit(df)\n",
"future = m.make_future_dataframe(periods=366)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"block_hidden": true,
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: Loading required package: Rcpp\n",
"\n",
" warnings.warn(x, RRuntimeWarning)\n"
]
},
{
"data": {
"text/plain": [
"STAN OPTIMIZATION COMMAND (LBFGS)\n",
"init = user\n",
"save_iterations = 1\n",
"init_alpha = 0.001\n",
"tol_obj = 1e-12\n",
"tol_grad = 1e-08\n",
"tol_param = 1e-08\n",
"tol_rel_obj = 10000\n",
"tol_rel_grad = 1e+07\n",
"history_size = 5\n",
2017-04-22 01:27:50 +00:00
"seed = 1595444319\n",
2017-02-22 23:59:43 +00:00
"initial log joint probability = -19.4685\n",
"Optimization terminated normally: \n",
" Convergence detected: relative gradient magnitude is below tolerance\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%R\n",
"library(prophet)\n",
"df <- read.csv('../examples/example_wp_peyton_manning.csv')\n",
"df$y <- log(df$y)\n",
"m <- prophet(df)\n",
"future <- make_future_dataframe(m, periods=366)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By default Prophet will return uncertainty intervals for the forecast `yhat`. There are several important assumptions behind these uncertainty intervals.\n",
"\n",
"There are three sources of uncertainty in the forecast: uncertainty in the trend, uncertainty in the seasonality estimates, and additional observation noise.\n",
"\n",
"### Uncertainty in the trend\n",
"The biggest source of uncertainty in the forecast is the potential for future trend changes. The time series we have seen already in this documentation show clear trend changes in the history. Prophet is able to detect and fit these, but what trend changes should we expect moving forward? It's impossible to know for sure, so we do the most reasonable thing we can, and we assume that the *future will see similar trend changes as the history*. In particular, we assume that the average frequency and magnitude of trend changes in the future will be the same as that which we observe in the history. We project these trend changes forward and by computing their distribution we obtain uncertainty intervals.\n",
"\n",
"One property of this way of measuring uncertainty is that allowing higher flexibility in the rate, by increasing `changepoint_prior_scale`, will increase the forecast uncertainty. This is because if we model more rate changes in the history then we will expect more in the future, and makes the uncertainty intervals a useful indicator of overfitting.\n",
"\n",
"The width of the uncertainty intervals (by default 80%) can be set using the parameter `interval_width`:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"forecast = Prophet(interval_width=0.95).fit(df).predict(future)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"output_hidden": true
},
"outputs": [
{
"data": {
"text/plain": [
"STAN OPTIMIZATION COMMAND (LBFGS)\n",
"init = user\n",
"save_iterations = 1\n",
"init_alpha = 0.001\n",
"tol_obj = 1e-12\n",
"tol_grad = 1e-08\n",
"tol_param = 1e-08\n",
"tol_rel_obj = 10000\n",
"tol_rel_grad = 1e+07\n",
"history_size = 5\n",
2017-04-22 01:27:50 +00:00
"seed = 1989486813\n",
2017-02-22 23:59:43 +00:00
"initial log joint probability = -19.4685\n",
"Optimization terminated normally: \n",
" Convergence detected: relative gradient magnitude is below tolerance\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%R\n",
"m <- prophet(df, interval.width = 0.95)\n",
"forecast <- predict(m, future)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, these intervals assume that the future will see the same frequency and magnitude of rate changes as the past. This assumption is probably not true, so you should not expect to get accurate coverage on these uncertainty intervals.\n",
"\n",
"### Uncertainty in seasonality\n",
"By default Prophet will only return uncertainty in the trend and observation noise. To get uncertainty in seasonality, you must do full Bayesian sampling. This is done using the parameter `mcmc.samples` (which defaults to 0). We do this here for the Peyton Manning data from the Quickstart:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"m = Prophet(mcmc_samples=500)\n",
"forecast = m.fit(df).predict(future)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"output_hidden": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2017-04-22 01:27:50 +00:00
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: The following numerical problems occurred the indicated number of times on chain 1\n",
2017-02-22 23:59:43 +00:00
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: count\n",
"Exception thrown at line 39: normal_log: Scale parameter is 0, but must be > 0! 5\n",
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: When a numerical problem occurs, the Hamiltonian proposal gets rejected.\n",
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: See http://mc-stan.org/misc/warnings.html#exception-hamiltonian-proposal-rejected\n",
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
2017-04-22 01:27:50 +00:00
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: If the number in the 'count' column is small, there is no need to ask about this message on stan-users.\n",
2017-02-22 23:59:43 +00:00
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
2017-04-22 01:27:50 +00:00
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: The following numerical problems occurred the indicated number of times on chain 2\n",
2017-02-22 23:59:43 +00:00
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
2017-04-22 01:27:50 +00:00
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: The following numerical problems occurred the indicated number of times on chain 3\n",
2017-02-22 23:59:43 +00:00
"\n",
" warnings.warn(x, RRuntimeWarning)\n",
2017-04-22 01:27:50 +00:00
"/usr/lib/python2.7/dist-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: The following numerical problems occurred the indicated number of times on chain 4\n",
2017-02-22 23:59:43 +00:00
"\n",
" warnings.warn(x, RRuntimeWarning)\n"
]
},
{
"data": {
"text/plain": [
"\n",
"SAMPLING FOR MODEL 'prophet_linear_growth' NOW (CHAIN 1).\n",
"\n",
"Chain 1, Iteration: 1 / 500 [ 0%] (Warmup)\n",
"Chain 1, Iteration: 50 / 500 [ 10%] (Warmup)\n",
"Chain 1, Iteration: 100 / 500 [ 20%] (Warmup)\n",
"Chain 1, Iteration: 150 / 500 [ 30%] (Warmup)\n",
"Chain 1, Iteration: 200 / 500 [ 40%] (Warmup)\n",
"Chain 1, Iteration: 250 / 500 [ 50%] (Warmup)\n",
"Chain 1, Iteration: 251 / 500 [ 50%] (Sampling)\n",
"Chain 1, Iteration: 300 / 500 [ 60%] (Sampling)\n",
"Chain 1, Iteration: 350 / 500 [ 70%] (Sampling)\n",
"Chain 1, Iteration: 400 / 500 [ 80%] (Sampling)\n",
"Chain 1, Iteration: 450 / 500 [ 90%] (Sampling)\n",
"Chain 1, Iteration: 500 / 500 [100%] (Sampling)\n",
2017-04-22 01:27:50 +00:00
" Elapsed Time: 208.52 seconds (Warm-up)\n",
" 304.548 seconds (Sampling)\n",
" 513.068 seconds (Total)\n",
2017-02-22 23:59:43 +00:00
"\n",
"\n",
"SAMPLING FOR MODEL 'prophet_linear_growth' NOW (CHAIN 2).\n",
"\n",
"Chain 2, Iteration: 1 / 500 [ 0%] (Warmup)\n",
"Chain 2, Iteration: 50 / 500 [ 10%] (Warmup)\n",
"Chain 2, Iteration: 100 / 500 [ 20%] (Warmup)\n",
"Chain 2, Iteration: 150 / 500 [ 30%] (Warmup)\n",
"Chain 2, Iteration: 200 / 500 [ 40%] (Warmup)\n",
"Chain 2, Iteration: 250 / 500 [ 50%] (Warmup)\n",
"Chain 2, Iteration: 251 / 500 [ 50%] (Sampling)\n",
"Chain 2, Iteration: 300 / 500 [ 60%] (Sampling)\n",
"Chain 2, Iteration: 350 / 500 [ 70%] (Sampling)\n",
"Chain 2, Iteration: 400 / 500 [ 80%] (Sampling)\n",
"Chain 2, Iteration: 450 / 500 [ 90%] (Sampling)\n",
"Chain 2, Iteration: 500 / 500 [100%] (Sampling)\n",
2017-04-22 01:27:50 +00:00
" Elapsed Time: 219.17 seconds (Warm-up)\n",
" 294.825 seconds (Sampling)\n",
" 513.994 seconds (Total)\n",
2017-02-22 23:59:43 +00:00
"\n",
"\n",
"SAMPLING FOR MODEL 'prophet_linear_growth' NOW (CHAIN 3).\n",
"\n",
"Chain 3, Iteration: 1 / 500 [ 0%] (Warmup)\n",
"Chain 3, Iteration: 50 / 500 [ 10%] (Warmup)\n",
"Chain 3, Iteration: 100 / 500 [ 20%] (Warmup)\n",
"Chain 3, Iteration: 150 / 500 [ 30%] (Warmup)\n",
"Chain 3, Iteration: 200 / 500 [ 40%] (Warmup)\n",
"Chain 3, Iteration: 250 / 500 [ 50%] (Warmup)\n",
"Chain 3, Iteration: 251 / 500 [ 50%] (Sampling)\n",
"Chain 3, Iteration: 300 / 500 [ 60%] (Sampling)\n",
"Chain 3, Iteration: 350 / 500 [ 70%] (Sampling)\n",
"Chain 3, Iteration: 400 / 500 [ 80%] (Sampling)\n",
"Chain 3, Iteration: 450 / 500 [ 90%] (Sampling)\n",
"Chain 3, Iteration: 500 / 500 [100%] (Sampling)\n",
2017-04-22 01:27:50 +00:00
" Elapsed Time: 203.151 seconds (Warm-up)\n",
" 302.178 seconds (Sampling)\n",
" 505.329 seconds (Total)\n",
2017-02-22 23:59:43 +00:00
"\n",
"\n",
"SAMPLING FOR MODEL 'prophet_linear_growth' NOW (CHAIN 4).\n",
"\n",
"Chain 4, Iteration: 1 / 500 [ 0%] (Warmup)\n",
"Chain 4, Iteration: 50 / 500 [ 10%] (Warmup)\n",
"Chain 4, Iteration: 100 / 500 [ 20%] (Warmup)\n",
"Chain 4, Iteration: 150 / 500 [ 30%] (Warmup)\n",
"Chain 4, Iteration: 200 / 500 [ 40%] (Warmup)\n",
"Chain 4, Iteration: 250 / 500 [ 50%] (Warmup)\n",
"Chain 4, Iteration: 251 / 500 [ 50%] (Sampling)\n",
"Chain 4, Iteration: 300 / 500 [ 60%] (Sampling)\n",
"Chain 4, Iteration: 350 / 500 [ 70%] (Sampling)\n",
"Chain 4, Iteration: 400 / 500 [ 80%] (Sampling)\n",
"Chain 4, Iteration: 450 / 500 [ 90%] (Sampling)\n",
"Chain 4, Iteration: 500 / 500 [100%] (Sampling)\n",
2017-04-22 01:27:50 +00:00
" Elapsed Time: 190.242 seconds (Warm-up)\n",
" 300.366 seconds (Sampling)\n",
" 490.608 seconds (Total)\n",
2017-02-22 23:59:43 +00:00
"\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%R\n",
"m <- prophet(df, mcmc.samples = 500)\n",
"forecast <- predict(m, future)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This replaces the typical MAP estimation with MCMC sampling, and takes much longer - think 10 minutes instead of 10 seconds. If you do full sampling, then you will see the uncertainty in seasonal components when you plot them:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"output_hidden": true
},
"outputs": [
{
"data": {
2017-04-22 01:27:50 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoEAAAKBCAYAAAAoU3G4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd83mW9//HX9957Zu82aZs0TTqBtoBllr1BRAE9h2MP\nTjw/OXJEQVREPYIIR5RTcLFRBIpQDkgRKFAKHene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pvJMW0XDt++9FZB/hhDHodNflO6gtdVObYWX5ZPQVOM99euYOntnbwVnM/+3rD\nsk5QCDFqJAQKIcaFg2VgHm/o4JYXdpPrMA0Hq65wggKniSq/fbSbeYiDZWQWVfjw2UzcdUEtp07L\n4d41B/jF6iY2ST1BIcQokkUpQogxT9M0dnaH+dOmdm57aS8lHgu/urgOj9VIVzjJVL+NGbkOdCNY\nEHokeaxGFpV72dAW4Jufmkp1noNfvt7M/oEY3z21KltPUNYJCiGOslEdCbzzzjupra1l1qxZXHHF\nFcTj8UM+//vf/57c3FzmzJnDnDlzuP/++0eppUKI0aKqGju6Qjy6sY1bX9pDuc/K/15aj9tqpCeS\noDrPTnXe2A2AB9mHjpvLc5o5qzqPX1xQS2cowddXbOPt/YO80dRPdyj+4RcSQogRMmohsK2tjbvv\nvpt169axdetWMpkMjz322Psed/nll9PQ0EBDQwP/9m//NgotFUKMlnRGZVN7gIc2tHHbqr1My7Fz\n7yV12E16eiNJZhW4qMxxjNpO4I/LqNcxu8jNVL+dyhw7v718Nn67iW89t53ndnTx9gE5d1gIcfSM\n6khgOp0mFouRTqeJRqM
2017-02-22 23:59:43 +00:00
"text/plain": [
2017-04-22 01:27:50 +00:00
"<matplotlib.figure.Figure at 0x7f07006c89d0>"
2017-02-22 23:59:43 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"m.plot_components(forecast);"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2017-04-22 01:27:50 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAogAAAKICAIAAAB8K5ztAAAACXBIWXMAAAsSAAALEgHS3X78AAAg\nAElEQVR4nOzdeZxT1fk/8HOX7JnJLJnMvi/AMAugUEBERRYBV1ar31akVq3iAlVsKxWqFlHQIoi1\n1bbWCj9FURRE9m3YEYYBRJgMw+yZLZlJJvty8/vjYoxJZk/ukjzvF3+QO5nkmZOb+8k59+QezO12\nIwAAAABwA852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8\n3aslEoler2e7kP7hY1OLRCKhUMjuXj0AoW7q+Ph475sDH8p2Op0URSGEKIpyOp30xk2bNhUWFo4Y\nMaKuri4vL4/eKJPJ6P9YrdYBP11fDPhDBlvcbjfvaqbxrmwWm7pCY9SaHc/vujYiWf7UL1IwDJUk\nyfpSjPtHDBTZnZIkWYXG+OQvUvLjJX/cU/Po6CS6nh7imfWaB4ALTT0APK0ZwQGkNwMP5tmzZ69d\nu3bbtm1isfj3v/99ZWXlrl275s+f/9Zbb33++edKpXLcuHFBLBQAPqrQGFuN9ud2XRuXHvX46BQM\n499EKk/BWbHiv+yvvdJmfmpcKnzLGYDQGfhQ9gC0t7eH6JElEglJkjA8wgCRSCQWi2HQr1f0l4Cb\nuuzP76y+PSdm4Q1JqJ/Tm7kwlO2NXpjylQO1Vqd7+aQMpVQQ8M/h414NQ9mMEYlEIpEIzoX5UCqV\n3jfhAiMABB+dyvV625Jvr04viBtAKnNQabI8WkSsmpo9XCV54mv1hRZzBVxbG4AQgGAGIMjorKrS\nWX7/7dVZhcr/K1Uh/qc
2017-02-22 23:59:43 +00:00
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%R -w 9 -h 9 -u in\n",
"prophet_plot_components(m, forecast);"
]
2017-04-04 00:47:45 +00:00
},
2017-07-05 01:27:57 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can access the raw posterior predictive samples in Python using the method `m.predictive_samples(future)`, or in R using the function `predictive_samples(m, future)`."
]
},
2017-04-04 00:47:45 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are upstream issues in PyStan for Windows which make MCMC sampling extremely slow. The best choice for MCMC sampling in Windows is to use R, or Python in a Linux VM."
]
2017-02-22 23:59:43 +00:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
}
},
"nbformat": 4,
"nbformat_minor": 0
}