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].
--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.
--There is time series data for several months (1 year if possible) --Event timing is known
--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.
Predicted by superimposing the following four.
--Change point of automatically detected tendency --Rough flow of the year --Weekly flow --User-provided event information
pip install fbprophet
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()
Learn based on the data.
m = Prophet()
m.fit(df);
If you want to put out 365 days in the future, write as follows.
future = m.make_future_dataframe(periods=365)
future.tail()
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
m.plot(forecast);
m.plot_components(forecast);
The next article is "Forecast Bitcoin Price Changes with Prophet".
References
Recommended Posts