Welcome to croston’s documentation!¶
croston¶
croston model for intermittent time series
-
croston.croston.
fit_croston
(input_endog, forecast_length, croston_variant='original')[source]¶ Parameters: - input_endog – numpy array of intermittent demand time series
- forecast_length – forecast horizon
- croston_variant – croston model type
Returns: dictionary of model parameters, in-sample forecast, and out-of-sample forecast
-
croston.croston.
_croston
(input_series, input_series_length, croston_variant, w, h, epsilon)[source]¶
example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import numpy as np import random from croston import croston import matplotlib.pyplot as plt a = np.zeros(50) val = np.array(random.sample(range(100,200), 10)) idxs = random.sample(range(50), 10) ts = np.insert(a, idxs, val) fit_pred = croston.fit_croston(ts, 10, 'original') # croston's method #fit_pred = croston.fit_croston(ts, 10, 'sba') # Syntetos-Boylan approximation #fit_pred = croston.fit_croston(ts, 10, 'sbj') # Shale-Boylan-Johnston yhat = np.concatenate([fit_pred['croston_fittedvalues'], fit_pred['croston_forecast']]) plt.plot(ts) plt.plot(yhat) |