1

I am struggling with Croston's method which I am applying on an intermittent demand dataset. The library I use is the following: https://pypi.org/project/croston//.

The dataset that I use consists of 6 years of intermittent demand data: Erratic and intermittent demand datasets. The intermittent demand pattern is displayed in red. As can be seen from the picture, intervals of no demand switch of demand periods. The average length of an interval is 15, and the avg length of demand is 3, and thus the ADI is 5 which makes it an intermittent demand series according to Syntetos, Boylan, and Croston (2005). The code that I used is this:

Crost1 = croston.fit_croston(intermittent_time_series['D'],1,'original')
Croston = pd.DataFrame(np.concatenate([Crost1['croston_fittedvalues'],Crost1['croston_forecast']]))
Croston.index = pd.to_datetime(Croston.index, unit='D') 
intermittent_time_series['Croston'] = Croston

The output I get looks weird though. It fits the first few (zero demand) observations correctly, but after these it all gives values of around 1. I wonder what I am doing wrong. Ofcourse I would like better estimates of the intermittent demand.

To improve the fit, I investigated fora for solutions, but I could not find any. I also tried to switch up the methods ('original'/'sba'/'sbj'/'tsb'), and looked at the source code. Unfortunately, I did not manage to come up with a solution.

Thanks in advance, Daan.

EDIT

I do not know how to share a dataframe over the interwebz, but I can share the code I used to create the demand:

def intermittent_demand(demand_period,interval,stop):  
Dt = []
while stop < years*days:
    temp = round(interval + np.random.normal(0,5,size=None))
    if stop + temp > years*days:
        Dt = Dt + (years*days - stop) * [0]
        stop = years*days
    else:
        Dt = Dt + temp * [0]
        stop = stop + temp
        
    temp = round(demand_period + np.random.normal(0,1.2,size=None))
    if stop + temp > years*days:
        Dt = Dt + (years*days - stop) * [0] 
        stop = years*days
    else: 
        Dt = Dt + temp * [1]
        stop = stop + temp

for day in range(years*days):
    if Dt[day] == 1:
        Dt[day] = math.ceil(a_intermittent + error_inter[day]) 

return Dt
for day in range (days*years):
    intermittent_time_series = intermittent_demand(demand_period,interval,stop)

Where days = 365, years = 6, demand_period = 3, interval = 15, stop = 0, a_intermittent = 4, and error_inter = 'np.random.normal(avg, 2dev, daysyears)'

6'38''4
  • 23
  • 5
  • 1
    could you make your example executable by providing the timeseries data? thanks – hm6 Mar 26 '21 at 15:14

0 Answers0