Play with Prophet

As for what I mean, time series analysis is complicated and I'm not sure, but I have data for the time being, so I would like to introduce the recommended library Prophet [^ 1] [^ 2].

What is Prophet?

--Facebook-made time series analysis tool ――Even if you are not familiar with time series analysis, you can analyze it just by inserting the data. --Can be used with R and Python.

Conditions that make it easy to demonstrate performance

--There is time series data for several months (1 year if possible) --Event timing is known

Great place

--It's okay if there are missing or abnormal values ――It also responds to changes in trends. --In some cases, the default value was as good as that of a skilled analyst. --Can be used by people who are not good at time series analysis.

How Prophet works

Predicted by superimposing the following four.

--Change point of automatically detected tendency --Rough flow of the year --Weekly flow --User-provided event information

Installation

pip install fbprophet

tutorial

The theme is the prediction of the number of future page views of Wikipedia by American football player Peyton Manning [^ 3].

wget https://raw.githubusercontent.com/facebookincubator/prophet/master/examples/example_wp_peyton_manning.csv
import pandas as pd
import numpy as np
from fbprophet import Prophet
df = pd.read_csv('../examples/example_wp_peyton_manning.csv')
df['y'] = np.log(df['y'])
df.head()

Learning

Learn based on the data.

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

Preparation of forecast data

If you want to put out 365 days in the future, write as follows.

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

image.png

Display of forecast results

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

image.png

Future forecast transition

m.plot(forecast);

image.png

Display for each ingredient

m.plot_components(forecast);

image.png

The next article is "Forecast Bitcoin Price Changes with Prophet".

References

Recommended Posts

Play with Prophet
Play with PyTorch
Play with 2016-Python
Play with CentOS 8
Play with Pyramid
Play with Fathom
Play with Othello (Reversi)
Let's play with 4D 4th
Let's play with Amedas data-Part 1
Play with reinforcement learning with MuZero
Play with push notifications with imap4lib
Play around with Linux partitions
Let's play with Amedas data-Part 4
Play with Jupyter Notebook (IPython Notebook)
[Python] Play with Discord's Webhook.
Play RocketChat with API / Python
Let's play with Amedas data-Part 3
Let's play with Amedas data-Part 2
Play with ASE MD module
Play with A3RT (Text Suggest)
Predict Bitcoin price changes with Prophet
Easy time series prediction with Prophet
Play with numerical calculation of magnetohydrodynamics
Play with a turtle with turtle graphics (Part 1)
Play with Poincare series and SymPy
Let's play with Excel with Python [Beginner]
Play with Pythonista UI implementation [Action implementation]
Play with PIR sensor module [DSUN-PIR]
Play around with Linux partitions ~ Continued ~
Spark play with WSL anaconda jupyter (2)
Play with Turtle on Google Colab
Play with demons because it's setsubun
Play video with sound with python !! (tkinter / imageio)
[Introduction to WordCloud] Let's play with scraping ♬
Play audio files from Python with interrupts
Play handwritten numbers with python Part 2 (identify)
Play like a web app with ipywidgets
Play around with the pythonista3 ui module
[Complement] [PySide] Let's play with Qt Designer
Fractal to make and play with Python
I want to play with aws with python
Play with Pythonista UI implementation [Screen elements]
Play with MoleculeNet's PDBBind and DeepChem's RDKitGridFeaturizer
Play audio files with interrupts using PyAudio
Play with puns using the COTOHA API
Load csv with pandas and play with Index
Python hand play (let's get started with AtCoder?)
[REAPER] How to play with Reascript in Python
Play with Google Spread Sheets in python (OAuth)
[Piyopiyokai # 1] Let's play with Lambda: Creating a Lambda function
Play with custom image notebook on Kubeflow v0.71
Play with Lambda layer (python) for about 5 minutes
I wanted to play with the Bezier curve
Understand grid points and play with contour lines.
Play with your Ubuntu desktop on your Raspberry Pi 4