class hana_ml.algorithms.pal.tsa.exponential_smoothing.Croston(alpha=None, forecast_num=None, method=None, accuracy_measure=None, ignore_zero=None, expost_flag=None)

Croston method is a forecast strategy for products with intermittent demand. Croston method consists of two steps. First, separate exponential smoothing estimates are made of the average size of a demand. Second, the average interval between demands is calculated. This is then used in a form of the constant model to predict the future demand.

alphafloat, optional

Value of the smoothing constant alpha (0 < alpha < 1).

Defaults to 0.1.

forecast_numint, optional

Number of values to be forecast.

When it is set to 1, the algorithm only forecasts one value.

Defaults to 0.

methodstr, optional
  • 'sporadic': Use the sporadic method.

  • 'constant': Use the constant method.

Defaults to 'sporadic'.

accuracy_measurestr or a list of str, optional

The metric to quantify how well a model fits input data. Options: "mpe", "mse", "rmse", "et", "mad", "mase", "wmape", "smape", "mape".

No default value.


Specify a measure name if you want the corresponding measure value to be reflected in the output statistics self.stats_.

ignore_zerobool, optional
  • False: Uses zero values in the input dataset when calculating "mpe" or "mape".

  • True: Ignores zero values in the input dataset when calculating "mpe" or "mape".

Only valid when accuracy_measure is "mpe" or "mape".

Defaults to False.

expost_flagbool, optional
  • False: Does not output the expost forecast, and just outputs the forecast values.

  • True: Outputs the expost forecast and the forecast values.

Defaults to True.


>>> croston = Croston(alpha=0.1,

Perform fit_predict():

>>> croston.fit_predict(data=df)


>>> croston.forecast_.collect()
>>> croston.stats_.collect()

Forecast values.




fit_predict(data[, key, endog])

Fit and predict based on the given time series.

fit_predict(data, key=None, endog=None)

Fit and predict based on the given time series.


Input data. At least two columns, one is ID column, the other is raw data.

keystr, optional

The ID column.

Defaults to the first column of data if the index column of data is not provided. Otherwise, defaults to the index column of data.

endogstr, optional

The column of series to be fitted and predicted.

Defaults to the first non-ID column.


Forecast values.

Inherited Methods from PALBase

Besides those methods mentioned above, the Croston class also inherits methods from PALBase class, please refer to PAL Base for more details.