A class forecasting method for time series