Repository navigation
Expand file tree
/
Copy pathsingle_date_plot.py
More file actions
104 lines (88 loc) · 2.33 KB
/
Copy pathsingle_date_plot.py
File metadata and controls
104 lines (88 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import datetime
import plotly.graph_objects as go
import polars as pl
import electricity_load_forecasting as elf
# %%
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--quantile_strategy', default='tabicl')
args = parser.parse_args()
# %%
pred = elf.make_data_op(horizons=tuple(range(1, 25)), quantile_strategy=None)
env = elf.get_env()
split = pred.skb.train_test_split(environment=env)
new_date = elf.get_new_date()
learner = pred.skb.make_learner().fit(split["train"])
prediction = learner.predict({"start": new_date, "end": None})
# %%
history = elf.resample(elf.fetch_load_mw_history())
history_tail = history.filter(pl.col("time") > new_date - datetime.timedelta(days=8))
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=history_tail["time"],
y=history_tail["load_mw"],
mode="lines+markers",
line={"dash": "dash", "color": "gray"},
)
)
fig.add_trace(
go.Scatter(
x=prediction["time"],
y=prediction["load_mw"],
mode="lines+markers",
)
)
fig.update_layout(height=700, showlegend=False)
fig.show(renderer="browser")
fig.write_html('example-mean.html')
# %%
pred = elf.make_data_op(
horizons=tuple(range(1, 25)),
quantile_strategy=args.quantile_strategy,
quantiles=(0.05, 0.5, 0.95),
)
learner = pred.skb.make_learner().fit(split["train"])
prediction = learner.predict({"start": new_date, "end": None})
# %%
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=history_tail["time"],
y=history_tail["load_mw"],
mode="lines+markers",
line={"dash": "dash", "color": "gray"},
name="historical data",
)
)
fig.add_trace(
go.Scatter(
x=prediction["time"],
y=prediction["q_0.5"],
mode="lines+markers",
name="median prediction"
)
)
fig.add_trace(go.Scatter(
x=prediction['time'],
y=prediction['q_0.95'],
mode='lines',
line=dict(width=0),
showlegend=False,
hoverinfo='skip'
))
fig.add_trace(go.Scatter(
x=prediction['time'],
y=prediction['q_0.05'],
mode='lines',
line=dict(width=0),
fill='tonexty',
fillcolor='rgba(0, 100, 250, 0.2)',
showlegend=True,
hoverinfo='skip',
name='5% - 95% confidence interval'
))
fig.update_layout(height=700)
fig.show(renderer="browser")
# %%
fig.write_html(f'example-{args.quantile_strategy}-90.html')