Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad plot for shaded area around prediction intervals in hourly data #216

Closed
antoinecarme opened this issue Aug 30, 2022 · 2 comments
Closed

Comments

@antoinecarme
Copy link
Owner

antoinecarme commented Aug 30, 2022

For an hourly dataset, the shaded area is not plotted correctly (should have been light blue).

Scripot : (same as demo.py with 'H' instead of 'D' for frequency)

import numpy as np
import pandas as pd

if __name__ == '__main__':
    # generate a hourly signal covering one year 2016 in a pandas dataframe
    N = 365
    np.random.seed(seed=1960)
    df_train = pd.DataFrame({"Date" : pd.date_range(start="2016-01-25", periods=N, freq='H'),
                             "Signal" : (np.arange(N)//40 + np.arange(N) % 21 + np.random.randn(N))})
    # print(df_train.head(N))
    
    import pyaf.ForecastEngine as autof
    # create a forecast engine. This is the main object handling all the operations
    lEngine = autof.cForecastEngine()
    
    # get the best time series model for predicting one week
    lEngine.train(iInputDS = df_train, iTime = 'Date', iSignal = 'Signal', iHorizon = 7);
    lEngine.getModelInfo() # => relative error 7% (MAPE)

    lEngine.standardPlots("outputs/bug_hourly_");

Plot :

image

@antoinecarme
Copy link
Owner Author

antoinecarme commented Aug 30, 2022

Fixed.

Culprit :

x = x.apply(lambda t : t.date());

Conversion to date format discards time (HH-MM-SS) data. Removed.

@antoinecarme
Copy link
Owner Author

New plot (after fix):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant