Added non autoregressive quantile results + changing sample plots

This commit is contained in:
2024-04-19 12:35:27 +02:00
parent 98a7244995
commit 4e713ef564
15 changed files with 107 additions and 48 deletions

View File

@@ -230,29 +230,29 @@ Some examples of the sampled full NRV day samples are shown in figure \ref{fig:a
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png}
\caption{Sample 1}
\label{fig:autoregressive_linear_model_sample_1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png}
\caption{Sample 2}
\label{fig:autoregressive_linear_model_sample_2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png}
\caption{Sample 3}
\label{fig:autoregressive_linear_model_sample_3}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png}
\caption{Sample 4}
\label{fig:autoregressive_linear_model_sample_4}
\end{subfigure}
\caption{Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples.}
\caption{Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples. The samples were generated using input features NRV, Load, Wind, PV, Net Position and the quarter embedding.}
\label{fig:autoregressive_linear_model_samples}
\end{figure}
@@ -261,6 +261,33 @@ The linear model is a simple model and can be used as a baseline to compare with
% ----------- Non-autoregressive model -----------
Until now, only the autoregressive linear model has been discussed. The non-autoregressive linear model can also be used to model the NRV and generate full-day samples. The model will now output the quantiles for every quarter of the day. The number of output values can be calculated as the number of quarters in a day multiplied by the number of quantiles. From this output, the cumulative distribution functions for every quarter of the day can be reconstructed. These functions can then be used to sample the NRV values for each quarter. There is a problem with this approach. The sampled NRV values are independent of each other. The NRV sample for the next quarter does not depend on what value was sampled for the quarter before.
\\\\
Training the non-autoregressive quantile model can be done in the same way as the autoregressive model. Now the pinball loss is calculated for every quarter of the day and the mean is taken over all the quarters. The models are also trained using the Adam optimizer with a learning rate of 1e-4. Early stopping is used with a patience of 5 epochs.
Training the non-autoregressive quantile model can be done in the same way as the autoregressive model. Now the pinball loss is calculated for every quarter of the day and the mean is taken over all the quarters. The models are also trained using the Adam optimizer with a learning rate of 1e-4. Early stopping is used with a patience of 5 epochs. Results of the non-autoregressive linear model are shown in table \ref{tab:non_autoregressive_linear_model_baseline_results}.
\begin{table}[ht]
\centering
\begin{tabular}{@{}lcccccc@{}}
\toprule
& \multicolumn{2}{c}{MSE} & \multicolumn{2}{c}{MAE} & \multicolumn{2}{c}{CRPS} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
& Train & Test & Train & Test & Train & Test \\
\midrule
NRV & 37690.02 & 41219.98 & 147.54 & 152.26 & 67.94 & 73.97 \\
NRV + Load & 38461.93 & 47045.17 & 149.85 & 163.24 & 69.68 & 79.72 \\
NRV + Load + PV & 37891.53 & 46404.63 & 148.95 & 161.82 & 69.02 & 79.74 \\
NRV + Load + Wind & 38113.90 & 48148.10 & 148.76 & 164.84 & 68.21 & 79.51 \\
NRV + Load + PV + Wind & 39072.94 & 50312.85 & 151.07 & 169.06 & 68.40 & 79.85 \\
NRV + Load + Wind + Net Position & 39505.20 & 49442.48 & 151.65 & 167.90 & 68.69 & 76.72 \\
\bottomrule
\end{tabular}
\label{tab:non_autoregressive_linear_model_baseline_results}
\caption{Non-Autoregressive linear model results}
\end{table}
Comparing the results from the autoregressive and non-autoregressive linear models, it is clear that the autoregressive model has lower MSE and MAE on the test set. The CRPS is, however, higher for the autoregressive model. The CRPS is calculated using the outputted quantiles while the MSE and MAE are calculated by sampling from the reconstructed distributions.
% TODO: Is this reasoning correct? + Explain the results more we see in the table (Weird results :( )
Because of error propagation in the autoregressive model, the outputted quantiles also contain more error which leads to a higher CRPS. The non-autoregressive model does not suffer from this problem.
\newpage
\subsection{Diffusion}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -51,12 +51,14 @@
\newlabel{sub@fig:autoregressive_linear_model_sample_3}{{c}{19}{Sample 3\relax }{figure.caption.9}{}}
\newlabel{fig:autoregressive_linear_model_sample_4}{{5d}{19}{Sample 4\relax }{figure.caption.9}{}}
\newlabel{sub@fig:autoregressive_linear_model_sample_4}{{d}{19}{Sample 4\relax }{figure.caption.9}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples.\relax }}{19}{figure.caption.9}\protected@file@percent }
\newlabel{fig:autoregressive_linear_model_samples}{{5}{19}{Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples.\relax }{figure.caption.9}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3}Diffusion}{20}{subsection.5.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {6}Policies for battery optimization}{20}{section.6}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Baselines}{20}{subsection.6.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {6.2}Policies using NRV predictions}{20}{subsection.6.2}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples. The samples were generated using input features NRV, Load, Wind, PV, Net Position and the quarter embedding.\relax }}{19}{figure.caption.9}\protected@file@percent }
\newlabel{fig:autoregressive_linear_model_samples}{{5}{19}{Test examples of the autoregressive linear model. The plots show the confidence intervals calculated from 1000 generated full-day NRV samples. The samples were generated using input features NRV, Load, Wind, PV, Net Position and the quarter embedding.\relax }{figure.caption.9}{}}
\newlabel{tab:non_autoregressive_linear_model_baseline_results}{{\caption@xref {tab:non_autoregressive_linear_model_baseline_results}{ on input line 282}}{20}{Models}{table.caption.10}{}}
\@writefile{lot}{\contentsline {table}{\numberline {5}{\ignorespaces Non-Autoregressive linear model results\relax }}{20}{table.caption.10}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3}Diffusion}{21}{subsection.5.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {6}Policies for battery optimization}{21}{section.6}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Baselines}{21}{subsection.6.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {6.2}Policies using NRV predictions}{21}{subsection.6.2}\protected@file@percent }
\abx@aux@read@bbl@mdfivesum{D41D8CD98F00B204E9800998ECF8427E}
\abx@aux@read@bblrerun
\gdef \@abspage@last{21}
\gdef \@abspage@last{22}

View File

@@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 18 APR 2024 00:26
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 19 APR 2024 12:04
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@@ -1336,29 +1336,37 @@ Underfull \hbox (badness 10000) in paragraph at lines 199--226
[]
[18]
<images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png, id=238, 2288.55pt x 1139.25626pt>
File: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png Graphic file (type png)
<use images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png>
Package pdftex.def Info: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png used on input line 233.
<images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png, id=238, 2288.55pt x 1139.25626pt>
File: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png Graphic file (type png)
<use images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png>
Package pdftex.def Info: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png used on input line 233.
(pdftex.def) Requested size: 223.07211pt x 111.04662pt.
LaTeX Font Info: Font shape `T1/LinuxLibertineT-TLF/m/n' will be
(Font) scaled to size 10.95pt on input line 234.
<images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png, id=239, 2284.535pt x 1135.24126pt>
File: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png Graphic file (type png)
<use images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png>
Package pdftex.def Info: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png used on input line 239.
<images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png, id=239, 2284.535pt x 1135.24126pt>
File: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png Graphic file (type png)
<use images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png>
Package pdftex.def Info: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png used on input line 239.
(pdftex.def) Requested size: 223.07211pt x 110.84581pt.
<images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png, id=240, 2283.53125pt x 1135.24126pt>
File: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png Graphic file (type png)
<use images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png>
Package pdftex.def Info: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png used on input line 245.
<images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png, id=240, 2283.53125pt x 1135.24126pt>
File: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png Graphic file (type png)
<use images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png>
Package pdftex.def Info: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png used on input line 245.
(pdftex.def) Requested size: 223.07211pt x 110.89777pt.
<images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png, id=241, 2282.5275pt x 1140.26pt>
File: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png Graphic file (type png)
<use images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>
Package pdftex.def Info: images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png used on input line 251.
<images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png, id=241, 2282.5275pt x 1140.26pt>
File: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png Graphic file (type png)
<use images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>
Package pdftex.def Info: images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png used on input line 251.
(pdftex.def) Requested size: 223.07211pt x 111.42284pt.
Package caption Warning: \label without proper reference on input line 282.
See the caption package documentation for explanation.
LaTeX Warning: Reference `tab:non_autoregressive_linear_model_baseline_results' on page 19 undefined on input line 264.
Underfull \hbox (badness 10000) in paragraph at lines 259--265
[]
@@ -1368,7 +1376,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 259--265
[]
[19 <./images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>]) [20] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/literature_study.aux))
[19 <./images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/aqr_linear_model_samples/AQR_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>] [20]) [21] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/literature_study.aux))
LaTeX Warning: There were undefined references.
@@ -1384,18 +1392,18 @@ Package logreq Info: Writing requests to 'verslag.run.xml'.
)
Here is how much of TeX's memory you used:
25696 strings out of 476025
459158 string characters out of 5790017
25699 strings out of 476025
459335 string characters out of 5790017
1866388 words of memory out of 5000000
45693 multiletter control sequences out of 15000+600000
45694 multiletter control sequences out of 15000+600000
597808 words of font info for 86 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
83i,16n,131p,1343b,5180s stack positions out of 10000i,1000n,20000p,200000b,200000s
</Users/victormylle/Library/texlive/2023/texmf-var/fonts/pk/ljfour/public/bbm/bbm12.600pk></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertinust1math/LibertinusT1Math.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/stix/stix-mathcal.pfb>
Output written on verslag.pdf (21 pages, 1933855 bytes).
Output written on verslag.pdf (22 pages, 1935435 bytes).
PDF statistics:
321 PDF objects out of 1000 (max. 8388607)
257 compressed objects within 3 object streams
57 named destinations out of 1000 (max. 500000)
327 PDF objects out of 1000 (max. 8388607)
262 compressed objects within 3 object streams
59 named destinations out of 1000 (max. 500000)
211 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@@ -15,7 +15,7 @@
\contentsline {subsubsection}{\numberline {5.2.1}Training}{14}{subsubsection.5.2.1}%
\contentsline {subsubsection}{\numberline {5.2.2}Evaluation}{15}{subsubsection.5.2.2}%
\contentsline {subsubsection}{\numberline {5.2.3}Models}{16}{subsubsection.5.2.3}%
\contentsline {subsection}{\numberline {5.3}Diffusion}{20}{subsection.5.3}%
\contentsline {section}{\numberline {6}Policies for battery optimization}{20}{section.6}%
\contentsline {subsection}{\numberline {6.1}Baselines}{20}{subsection.6.1}%
\contentsline {subsection}{\numberline {6.2}Policies using NRV predictions}{20}{subsection.6.2}%
\contentsline {subsection}{\numberline {5.3}Diffusion}{21}{subsection.5.3}%
\contentsline {section}{\numberline {6}Policies for battery optimization}{21}{section.6}%
\contentsline {subsection}{\numberline {6.1}Baselines}{21}{subsection.6.1}%
\contentsline {subsection}{\numberline {6.2}Policies using NRV predictions}{21}{subsection.6.2}%

View File

@@ -417,7 +417,7 @@ class AutoRegressiveQuantileTrainer(AutoRegressiveTrainer):
for i in range(10):
ax2.plot(predictions_np[i], label=f"Sample {i}")
ax2.plot(next_day_np, label="Real NRV", linewidth=3)
ax2.plot(next_day_np, label="Real NRV", linewidth=4, color="orange")
ax2.legend()
ax2.set_ylim(-1500, 1500)
@@ -561,16 +561,19 @@ class NonAutoRegressiveQuantileRegression(Trainer):
outputs = outputs.reshape(-1, 96, len(self.quantiles))
outputted_samples = [
sample_from_dist(self.quantiles, output.cpu()) for _ in range(100) for output in outputs
sample_from_dist(self.quantiles, output.cpu())
for _ in range(100)
for output in outputs
]
outputted_samples = torch.tensor(outputted_samples)
inversed_outputs_samples = self.data_processor.inverse_transform(
outputted_samples
)
expanded_targets = targets.unsqueeze(1).repeat(1, 100, 1).reshape(-1, 96)
expanded_targets = (
targets.unsqueeze(1).repeat(1, 100, 1).reshape(-1, 96)
)
inversed_expanded_targets = self.data_processor.inverse_transform(
expanded_targets
)
@@ -587,7 +590,6 @@ class NonAutoRegressiveQuantileRegression(Trainer):
expanded_targets = expanded_targets.to(self.device)
inversed_expanded_targets = inversed_expanded_targets.to(self.device)
for metric in self.metrics_to_track:
if metric.__class__ != PinballLoss and metric.__class__ != CRPSLoss:
transformed_metrics[metric.__class__.__name__] += metric(
@@ -628,7 +630,9 @@ class NonAutoRegressiveQuantileRegression(Trainer):
name=metric_name, value=metric_value
)
def debug_plots(self, task, train: bool, data_loader, sample_indices, epoch):
def debug_plots(
self, task, train: bool, data_loader, sample_indices, epoch, final=False
):
for actual_idx, idx in sample_indices.items():
features, target, _ = data_loader.dataset[idx]
@@ -664,6 +668,24 @@ class NonAutoRegressiveQuantileRegression(Trainer):
report_interactive=False,
)
if final:
# fig to PIL image
fig.savefig(f"sample_{actual_idx}_plot.png")
task.get_logger().report_image(
title="Final Training Plot",
series=f"Sample {actual_idx}",
iteration=epoch,
image_path=f"sample_{actual_idx}_plot.png",
)
fig2.savefig(f"sample_{actual_idx}_samples_plot.png")
task.get_logger().report_image(
title="Final Training Samples Plot",
series=f"Sample {actual_idx} samples",
iteration=epoch,
image_path=f"sample_{actual_idx}_samples_plot.png",
)
plt.close()
def get_plot(