4

I am working with an dataset of crimes in chicago and specially working on a future prediction of the crime rate in chicago (from 2012 till 2016 I have data). I generated a forecast using the prophet package of facebook. It worked very well and all done. Now I would like to train and test my model. Therefore, I split the dataset into 70% train and 30% test. I trained the model and test it and at the end I got a nice plot. I am further interested in the diagnostic part. Prophet provides for that a function called cross_validation() which I used: df.cv<- cross_validation(m, initial = nrow(trainData), period = 365, horizon = nrow(testData), units = 'days') . The problems is here, I am geting always this error and trying since yesterday to fix it, without success:

Fehler in generate_cutoffs(df, horizon.dt, initial.dt, period.dt) : 
Less data than horizon after initial window. Make horizon or initial shorter.

Does somebody know how to fix this error and provide a list of diagnostics?

My train/test plot looks so:

Train/Test Plot

And my train Dataset can be downloaded here: https://ufile.io/4e38c And my test Dataset here: https://ufile.io/ds65p

I hope somebody could help me! It would be really great and I would really appreciate it. Thanks in advance!

Daniel V
  • 1,305
  • 7
  • 23
Scrappy
  • 51
  • 1
  • 9

2 Answers2

3

Cross-validation will be applied on a sliding window, performing cutoffs based on the settings. Please read the docs here: https://facebook.github.io/prophet/docs/diagnostics.html

The error you get because your sliding window is out of bounds. Try like this:

df.cv<- cross_validation(m, initial = 100, period = 100, horizon = 100, units = 'days') 
tvgriek
  • 1,215
  • 9
  • 20
  • You can also check the source code of these two functions here https://github.com/facebook/prophet/blob/master/R/R/diagnostics.R. I also found the discussion here https://github.com/facebook/prophet/issues/483 very useful to understand the diagnostic utilities better – user131476 Oct 10 '19 at 13:36
  • The cut off has the size of 100 days (defined by horizon=100), right? What is the period? – xeon123 Jan 15 '20 at 07:24
1

I had similar issue and I managed to fix it by using string arguments such as horizon="365 days" , instead of int horizon = 365.

This solution worked on Python version.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Matus Hmelar
  • 348
  • 3
  • 13