# Machine Learning and Deep Learning Models Applied to Photovoltaic Production Forecasting
## 3 Case Study  
The Artificial Intelligence models described in previous section have been validated with photovoltaic production data collected from a single-family dwelling located in the state of Maryland, United States [62; 63]. The photovoltaic installation faces south and has a nominal power of 10.24 kW. Nevertheless, the photovoltaic power data are collected once the inversion has been made, which has an efficiency of 93%. Thus, the maximum useful power is 9.52 kW, so this value has been selected to normalize the metrics.  
The measurements correspond to hourly data divided into 2 periods of 1 year, from July 2013 to July 2014, and from February 2015 to February 2016. The composition of features selected to validate the methodology presented above are irradiance, as an independent variable, and photovoltaic production, as a dependent variable. The quality of the data is excellent, with a validity of 98.95% in irradiation, and 96.91% in photovoltaic production, once the data cleaning process has been applied.  
With knowledge of the domain and through the data cleaning process with a functional approach to the data set in weekly periods, inconsistent data have been corrected, i.e., data with structural errors, and missing data has been repaired in periods where the gap consists of a maximum of 3 h. Duplicate and irrelevant data have also been removed. With data mining techniques the temporal variables: hour of the day, day of the week and day of the year have been extracted. After several runs of the analysis, mean normalization is the one that better fits the objective variable. Consequently, this type of normalization is shown in the results section. To retain the information provided by the wrong data and ensure data continuity, one hot encoding has been used. Figure 5 graphically shows the main configuration used for forecasting with the Artificial Intelligence methods.  
Artificial Intelligence methods are carried out of the 10-fold cross-validation technique. In order to reproduce and compare the results, a seed has been applied. The data division is 95% training, where 90% corresponds to the train split and 5% to the validation split, and the remaining 5% is test. The hyperparameters used to perform the training process are 100 epochs and a batch size of 64. The optimizer used is the adaptive movement estimation algorithm, Adam, with a learning rate of 0.001.  
The Deep Learning models are made using bottleneck composition. The SNN model is composed of 4 dense layers of 100, 75, 50, and 25. Its activation functions are Linear except for the last hidden layer and the output layer, whose activation functions are ReLU. Short-term memory in the RNN model is set to 6 time steps, i.e., 6 h. In this model, the first hidden layer corresponds to the LSTM with 64 neurons. The rest of the model is composed of dense layers with 40 and 20 neurons. On the one hand, the activations functions of the LSTM layer are the typical ones. On the other hand, the linear activation function is selected for the first dense layer and the rest of layers are ReLU. The convolution layer in the CNN model has 64 filters with a kernel of 3. Padding is not considered and the stride is 1. After the convolutional layer, a flattening layer is applied for the imposition of two dense layers. The number of neurons and the activations functions are the same as the considered in the RNN model.  
Figure 5: Photovoltaic production forecasting problem, where the Artificial Intelligence model corresponds to the considered Machine Learning or Deep Learning model.