Skip to content

Training on test sample in CH05 ?? #6

@OdysseusU

Description

@OdysseusU

In CH05, your method rolling_forecasting trains on test samples.

In this case :
the df corresponds to all the data (train AND test).
You are fitting SARIMAX to the train AND test samples.

            model = SARIMAX(df[:i], order=(2,0,0))
            res = model.fit(disp=False)
            predictions = res.get_prediction(0, i + window - 1)
            oos_pred = predictions.predicted_mean.iloc[-window:]
            pred_AR.extend(oos_pred)

In order to really do forecasting, your training should be based on train AND prediction sample.

            model = SARIMAX(df_train_estimated[:i], order=(2,0,0))
            res = model.fit(disp=False)
            predictions = res.get_prediction(0, i + window - 1)
            oos_pred = predictions.predicted_mean.iloc[-window:]
            pred_AR.extend(oos_pred)
            df_train_estimated.append({'value': oos_pred.values[0]}) #Adding the last prediction and use it as training

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions