Exemple #1
0
def forecastSeasonalARIMAWitheXogenousRegressorsModel():

    #reading the model whichis trained on the whole dataset
    seasonalARIMAWitheXogenousRegressorsModel = readSeasonalARIMAWitheXogenousRegressorsModelForFullDataset(
    )

    #reading the dataset
    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    #reading the dataset with holidays
    seasonalARIMAWitheXogenousRegressorsDatasetWithHoliday = importSeasonalARIMAWitheXogenousRegressorsDatasetWithMissingDataForHoliday(
        "RestaurantVisitors.csv")

    exog_forecast = seasonalARIMAWitheXogenousRegressorsDatasetWithHoliday[
        478:][['holiday']]

    #forecasting for 38 months
    seasonalARIMAWitheXogenousRegressorsForecastedValues = seasonalARIMAWitheXogenousRegressorsModel.predict(
        len(seasonalARIMAWitheXogenousRegressorsDataset),
        len(seasonalARIMAWitheXogenousRegressorsDataset) + 38,
        exog=exog_forecast).rename("SARIMAX(0, 0, 0)x(1, 0, 1, 7) Prediction")
    #saving the forecasted values
    saveSeasonalARIMAWitheXogenousRegressorsForecastedValues(
        seasonalARIMAWitheXogenousRegressorsForecastedValues)
def testIsDatasetStationary():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    #order of p,d,q and P, D, Q is SARIMAX(0,0,0)x(1,0,1,7)
    #hence we do not have take diff to check stationarity.
    agumentedDickeyFullerTest(
        seasonalARIMAWitheXogenousRegressorsDataset["total"])
def preprocess():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    X_train, X_test = splitSeasonalARIMAWitheXogenousRegressorsDataset(
        seasonalARIMAWitheXogenousRegressorsDataset)

    saveTrainingAndTestingDataset(X_train, X_test)
def determineSARIMAXOrderOfPAndQ():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    # For SARIMA Orders we set seasonal=True and pass in an m value
    autoArimaResult = auto_arima(
        seasonalARIMAWitheXogenousRegressorsDataset["total"],
        seasonal=True,
        m=7,
        trace=True)

    print(autoArimaResult.summary())  #SARIMAX(0,0,0)x(1,0,1,7)
Exemple #5
0
def plotSeasonalARIMAWitheXogenousRegressorsForecastedValues():

    #reading the dataset
    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    #reading the forecated values
    seasonalARIMAWitheXogenousRegressorsForecastedValues = readSeasonalARIMAWitheXogenousRegressorsForecastedValues(
    )

    #visualizing the forecated values
    visualizeSeasonalARIMAWitheXogenousRegressorsForecastedValues(
        seasonalARIMAWitheXogenousRegressorsDataset,
        seasonalARIMAWitheXogenousRegressorsForecastedValues)
Exemple #6
0
def plotSeasonalARIMAWitheXogenousRegressorsForecastedValuesWithHolidays():

    #reading the dataset with holidays
    seasonalARIMAWitheXogenousRegressorsDatasetWithHoliday = importSeasonalARIMAWitheXogenousRegressorsDatasetWithMissingDataForHoliday(
        "RestaurantVisitors.csv")

    #reading the dataset
    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    #reading the forecated values
    seasonalARIMAWitheXogenousRegressorsForecastedValues = readSeasonalARIMAWitheXogenousRegressorsForecastedValues(
    )

    #visualizing the forecated values
    visualizeSeasonalARIMAWitheXogenousRegressorsForecastedValuesWithHolidays(
        seasonalARIMAWitheXogenousRegressorsDataset,
        seasonalARIMAWitheXogenousRegressorsForecastedValues,
        seasonalARIMAWitheXogenousRegressorsDatasetWithHoliday)
def trainSeasonalARIMAWitheXogenousRegressorsModelOnFullDataset():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")

    seasonalARIMAWitheXogenousRegressorsDataset[
        "total"] = seasonalARIMAWitheXogenousRegressorsDataset["total"].astype(
            'float64')

    #training model on the whole dataset
    seasonalARIMAWitheXogenousRegressorsModel = SARIMAX(
        seasonalARIMAWitheXogenousRegressorsDataset['total'],
        exog=seasonalARIMAWitheXogenousRegressorsDataset['holiday'],
        order=(0, 0, 0),
        seasonal_order=(1, 0, 1, 7),
        enforce_invertibility=False)

    seasonalARIMAWitheXogenousRegressorsModelFitResult = seasonalARIMAWitheXogenousRegressorsModel.fit(
    )

    saveSeasonalARIMAWitheXogenousRegressorsModelForFullDataset(
        seasonalARIMAWitheXogenousRegressorsModelFitResult)

    print(seasonalARIMAWitheXogenousRegressorsModelFitResult.summary())
def etsDecomposition():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")
    visualizeEtsDecomposition(seasonalARIMAWitheXogenousRegressorsDataset)
def plotTheSourceDataWithHoliday():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")
    visualizeSourceDataPlotWithHolidays(
        seasonalARIMAWitheXogenousRegressorsDataset)
def plotPACFPlot():

    seasonalARIMAWitheXogenousRegressorsDataset = importSeasonalARIMAWitheXogenousRegressorsDataset(
        "RestaurantVisitors.csv")
    visualizePACFPlot(seasonalARIMAWitheXogenousRegressorsDataset)