## 3 Multi-Step Energy Prediction Model  
We propose a multi-step energy prediction model (see Figure 1) for prosumers that forecasts the energy values for each hour, \(t\), of the next day with respect to the current day denoted as \"day\" (i.e., 24 steps ahead):  
\[E_{predicted}^{prosumer,day}=\Big{\{}e_{t}^{day+1}\Big{|}\ \ t=\{1,\ldots,24\}\ \text{and}\ day\in\mathbb{Z}^{+}\ \Big{\}}. \tag{1}\]  
The features for the energy-prediction model are defined based on energy time-series intervals of 24 h corresponding to days in the past with time intervals of 1 h granularity spreading over the entire monitored data history:  
\[E_{historical}^{prosumer,day}=\Big{\{}e_{t}^{day-d}\Big{|}\ \ t=\{1,\ldots,24\},\ d \in\{1,2,\ldots\}\Big{\}}. \tag{2}\]  
We have considered and extracted relevant energy features by decomposing the energy profiles of the prosumer into three components: energy baseline, valleys, and peaks. This process is shown in Figure 2, where the energy profile is represented with blue, while the baseline profile is colored in orange. To determine the daily baseline energy profile of a prosumer, we selected and averaged similar intervals from X previous days, with each featuring 24 values for the hours, not including the highest and lowest profiles [2]:  
\[E_{baseline}^{prosumer,day}=\frac{1}{X_{days}-2}\sum_{day\in MID(X_{days})}^{X_{ days}-2}E_{historical}^{prosumer,day}. \tag{3}\]  
where \(X_{days}\) represents the number of days in the past considered. The valleys and the peaks were computed as the energy profile values that are lower or higher than the baseline, as shown in Algorithm 1. The energy-based features are enhanced by adding contextual information, as we expect different energy profile patterns in different time intervals of a day or for different days in the week or month, etc. The timestamp-derived features allow for the identification of complex and hidden energy patterns and the representation of the time differences in the energy profiles. Weather-related features such as solar irradiance, temperature, or humidity are considered similarly in the prediction process. Figure 1: Overview of defined energy-prediction process. Figure 2: Decomposition of prosumer energy data in baseline, peak, and valley profiles. The defined energy-prediction model described in Figure 1 uses the above-presented features, and it is based on an ensemble learner to aggregate partial prediction results from regressors and classifiers. A weighted average of two partial predictions is used to handle data heterogeneity, where the sum of the model weights is equal to one:  
\[E_{\textit{ensemble}}^{\textit{prosumer}}(t)=\omega_{1}(t)\times E_{\textit{ class}/\textit{fication}}^{\textit{prosumer}}(t)+(1-\omega_{1}(t))\times E_{\textit{ regression}}^{\textit{prosumer}}(t),\ \forall t\in\{1\dots 24\} \tag{4}\]  
The classification-based models predict the energy peak and valley classes, for the day ahead energy profile of a prosumer using a clustering algorithm (see Figure 3):  
\[f_{\textit{classify}}^{\textit{valley}}:R^{24}\rightarrow\left\{1\dots N_{ \textit{valley}}\right\}\text{, }f_{\textit{classify}}^{\textit{valley}}\left(E_{\textit{valley}}^{\textit{ prosumer},\textit{day}}\right)=class_{\textit{valley}}^{k} \tag{5}\]  
\[f_{\textit{classify}}^{\textit{peak}}:R^{24}\rightarrow\left\{1\dots N_{ \textit{peak}}\right\}\text{, }f_{\textit{classify}}^{\textit{peak}}\left(E_{\textit{peak}}^{\textit{ prosumer},\textit{day}}\right)=class_{\textit{peak}}^{k}. \tag{6}\]  
The functions \(f_{\textit{classify}}^{\textit{valley}}\) and \(f_{\textit{classify}}^{\textit{peak}}\) use K-Means clustering to group the energy valley and energy peak patterns from the historical data of the energy prosumer in \(N_{\textit{valley}}\) and \(N_{\textit{peak}}\) clusters, respectively. We chose K-Means because previous studies in the literature have shown that it is effective in clustering individual households based on their daily energy patterns [49].