Setup¶

In [ ]:
import warnings
warnings.filterwarnings("ignore")
In [ ]:
from datetime import datetime, timedelta
from openstef_dbc.log import logging
import numpy as np
import plotly.graph_objects as go

from app_settings import AppSettings

Settings = AppSettings()

logging.configure_logging(loglevel=Settings.loglevel, runtime_env=Settings.env)

Forecasting in practice with OpenSTEF¶

Create config object¶

In [ ]:
from openstef.data_classes.prediction_job import PredictionJobDataClass

prediction_job = PredictionJobDataClass(
    id=1337,
    model='xgb',
    quantiles=[0.1,0.3,0.5,0.7,0.9],
    forecast_type="demand",
    lat=52.0,
    lon=5.0,
    horizon_minutes=47*60,
    resolution_minutes=15,
    name="Example",
    default_modelspecs=None,
)

Load data¶

In [ ]:
import pandas as pd

data = pd.read_csv('data/example_input.csv', index_col='index', parse_dates=True)
In [ ]:
split = 200

data_train = data.iloc[:-split,:]
data_test = data.iloc[-split:,:]

data_forecast = data.copy()
data_forecast["load"].iloc[-split:] = np.nan

Visualize data¶

In [ ]:
data_train.head(5)
Out[ ]:
load APX clouds radiation temp winddeg windspeed windspeed_100m pressure humidity ... sjv_E1A sjv_E1B sjv_E1C sjv_E2A sjv_E2B sjv_E3A sjv_E3B sjv_E3C sjv_E3D sjv_E4A
index
2020-10-02 10:00:00+00:00 2.620000 34.0 99.758911 1.552899e+06 16.449036 154.711456 3.527778 9.349441 99453.476562 0.686240 ... 0.000031 0.000030 0.000029 0.000033 0.000032 0.000061 0.000048 0.000048 0.000031 0.0
2020-10-02 10:15:00+00:00 0.796667 34.0 99.819193 1.575618e+06 16.400948 157.491554 3.557639 9.232026 99416.363281 0.683780 ... 0.000032 0.000030 0.000029 0.000033 0.000032 0.000060 0.000048 0.000048 0.000031 0.0
2020-10-02 10:30:00+00:00 0.300000 34.0 99.879475 1.598338e+06 16.352859 160.271652 3.587500 9.114612 99379.250000 0.681319 ... 0.000032 0.000031 0.000029 0.000033 0.000031 0.000058 0.000048 0.000048 0.000031 0.0
2020-10-02 10:45:00+00:00 1.773333 34.0 99.939756 1.594736e+06 16.304771 163.051750 3.617361 8.997197 99342.136719 0.678859 ... 0.000032 0.000030 0.000029 0.000032 0.000031 0.000057 0.000048 0.000048 0.000031 0.0
2020-10-02 11:00:00+00:00 1.740000 28.8 100.000038 1.591135e+06 16.256683 165.831848 3.647222 8.879783 99305.023438 0.676398 ... 0.000031 0.000029 0.000027 0.000031 0.000030 0.000057 0.000048 0.000048 0.000031 0.0

5 rows × 25 columns

In [ ]:
import plotly.graph_objects as go

figure = go.Figure()

figure.add_scatter(x=data_train.index, y=data_train["load"], name="Measured")
figure.update_layout(title="Historic load")

figure.show()