Can the prophet predict the most erratic of all timeseries?
Published
July 17, 2021
At this point I have done quite a lot of deep learning - both computer vision and natural language processing. One area that I’ve done less is timeseries analysis.
Facebook has released Prophet which is an easy to use forecasting tool for a single numeric timeseries (Taylor and Letham 2018). I’m going to try to predict the daily price of bitcoin with this. Given how volatile the cryptocurrency world is I do not have any confidence in this.
Let’s start by getting the data. I’m using the binance exchange data from cryptodatadownload. This does require some special work, as the https certificate for the site is invalid and the source data needs some work.
Code
#hide_outputimport pandas as pdimport requestsimport io# skip ssl certificate verificationresponse = requests.get("https://www.cryptodatadownload.com/cdd/Binance_BTCUSDT_d.csv", verify=False)# first row is a link to cryptodatadownload, need to skip itdf = pd.read_csv( io.StringIO(response.content.decode("utf-8")), skiprows=1)df["date"] = pd.to_datetime(df.date)df = df.drop(columns="unix")df = df.set_index("date")
/home/matthew/.cache/pypoetry/virtualenvs/blog-HrtMnrOS-py3.8/lib/python3.8/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.cryptodatadownload.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
warnings.warn(
So now we can try to apply prophet to this. Before we do so, lets have a quick look at the data. I want to take the year of 2021 as the held out data to predict - is this reasonable?
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
CPU times: user 115 ms, sys: 35.7 ms, total: 150 ms
Wall time: 149 ms
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
CPU times: user 116 ms, sys: 32 ms, total: 148 ms
Wall time: 147 ms
So this is one where there seems to be a repeated pattern but prophet has failed to match any previous behaviour. My best guess is that it matches the downward trend from the peak around Q1 2018. All in all, quite disappointing. Can’t use prophet to make my fortune with crypto :-P