From 6c3a8a8e07ffe8dddfa761c1f4d749a5b0d64312 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Wed, 19 Aug 2020 16:29:50 -0700 Subject: [PATCH] Move flat trend docs to additional topics --- notebooks/additional_topics.ipynb | 42 ++++++++++++++++++++-------- notebooks/saturating_forecasts.ipynb | 25 +---------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/notebooks/additional_topics.ipynb b/notebooks/additional_topics.ipynb index 0defa85..1443908 100644 --- a/notebooks/additional_topics.ipynb +++ b/notebooks/additional_topics.ipynb @@ -2,18 +2,9 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/ryannazareth/Documents/Python_sprints/prophet/python/fbprophet/diagnostics.py:10: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n", - " from tqdm.autonotebook import tqdm\n" - ] - } - ], + "outputs": [], "source": [ "%load_ext rpy2.ipython\n", "%matplotlib inline\n", @@ -25,6 +16,33 @@ "warnings.filterwarnings(\"ignore\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Flat trend and custom trends\n", + "\n", + "For time series that exhibit strong seasonality patterns rather than trend changes, it may be useful to force the trend growth rate to be flat. This can be achieved simply by passing `growth=flat` when creating the model:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "m = Prophet(growth='flat')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is currently implemented only in the Python version of Prophet. Note that if this is used on a time series that doesn't have a constant trend, any trend will be fit with the noise term and so there will be high predictive uncertainty in the forecast.\n", + "\n", + "To use a trend besides these three built-in trend functions (piecewise linear, piecewise logistic growth, and flat), you can download the source code from github, modify the trend function as desired in a local branch, and then install that local version. This PR provides a good illustration of what must be done to implement a custom trend: https://github.com/facebook/prophet/pull/1466/files." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -113,7 +131,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.8" } }, "nbformat": 4, diff --git a/notebooks/saturating_forecasts.ipynb b/notebooks/saturating_forecasts.ipynb index 28e55d0..230d16d 100644 --- a/notebooks/saturating_forecasts.ipynb +++ b/notebooks/saturating_forecasts.ipynb @@ -306,29 +306,6 @@ "source": [ "To use a logistic growth trend with a saturating minimum, a maximum capacity must also be specified." ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Constant Trend" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For some datasets which exhibit strong seasonality patterns rather than trend changes, it may be useful to force the growth rate to be flat. This can be achieved simply by passing `growth=flat` before fitting the model. However, if used on a dataset with obvious non linear trend, most of the change in the trend would be fit with variance (high noise term) and hence we would observe a high predictive uncertainty." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "m = Prophet(growth='flat')" - ] } ], "metadata": { @@ -347,7 +324,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.7.8" } }, "nbformat": 4,