def forecast(data, train_hours, test_hours):
    # Train on the first 6 days to predict the 7th day
    train = data.iloc[25:train_hours]

    # Create the SES Model
    model = Holt(np.asarray(train['seasonally differenced']), damped=True)
    model._index = pd.to_datetime(train.index)

    # Fit the model, and forecast
    fit = model.fit()
    pred = fit.forecast(test_hours)
    data['holtDamped'] = 0
    data['holtDamped'][25:] = list(fit.fittedvalues) + list(pred)
Пример #2
0
def forecast(data, train_hours, test_hours):
    # Split data into training and test data
    train = data.iloc[25:train_hours]

    # Create the Holt Model
    model = Holt(np.asarray(train['seasonally differenced']))
    model._index = pd.to_datetime(train.index)

    # Fit the model, and forecast
    fit = model.fit()
    pred = fit.forecast(test_hours)
    data['holt'] = 0
    data['holt'][25:] = list(fit.fittedvalues) + list(pred)