# Machine Learning and Deep Learning Models Applied to Photovoltaic Production Forecasting
###### Abstract  
The increasing trend in energy demand is higher than the one from renewable generation, in the coming years. One of the greatest sources of consumption are buildings. The energy management of a building by means of the production of photovoltaic energy in situ is a common alternative to improve sustainability in this sector. An efficient trade-off of the photovoltaic source in the fields of Zero Energy Buildings (ZEB), nearly Zero Energy Buildings (nZEB) or MicroGrids (MG) requires an accurate forecast of photovoltaic production. These systems constantly generate data that are not used. Artificial Intelligence methods can take advantage of this missing information and provide accurate forecasts in real time. Thus, in this manuscript a comparative analysis is carried out to determine the most appropriate Artificial Intelligence methods to forecast photovoltaic production in buildings. On the one hand, the Machine Learning methods considered are Random Forest (RF), Extreme Gradient Boost (XGBoost), and Support Vector Regressor (SVR). On the other hand, Deep Learning techniques used are Standard Neural Network (SNN), Recurrent Neural Network (RNN), and Convolutional Neural Network (CNN). The models are checked with data from a real building. The models are validated using normalized Mean Bias Error (nMBE), normalized Root Mean Squared Error (nRMSE), and the coefficient of variation (R\({}^{2}\)). Standard deviation is also used in conjunction with these metrics. The results show that the models forecast the test set with errors of less than 2.00% (nMBE) and 7.50% (nRMSE) in the case of considering nights, and 4.00% (nMBE) and 11.50% (nRMSE) if nights are not considered. In both situations, the R\({}^{2}\) is greater than 0.85 in all models. 202220202020202202022020202  
Buildings in residential and industrial sectors correspond to 40%, these being responsible for 36% of emissions [7]. A sustainable solution to reduce emissions in the building sector is the use of distributed energy. Continuous improvement in efficiency and costs promotes the use of rooftop photovoltaic production [8]. This technology has great potential as less than 10% of building rooftops use this energy source. Moreover, it is estimated that it is possible to generate a quarter of current energy necessities [9]. Zero Energy Buildings (ZEB) [10], nearly Zero Energy Buildings (nZEB) [11], or Micro Grids (MG) [12] are some of the current approaches on which research efforts on photovoltaic solar production in buildings. All of them converge on a common goal, the reduction of the energy necessities of the building from the grid. This allows a reduction in greenhouse gas emissions from a flexible use of energy and greater energy efficiency from a priority renewable source approach [13]. Solar photovoltaic production depends on environmental conditions, so it does not generate constantly over time. Furthermore, there are periods of communication failures or in the photovoltaic panels themselves. In this way, the monitoring and forecasting of photovoltaic systems is of vital importance for efficient management in the previously presented fields, i.e., ZEB, nZEB, and MG [14]. Nowadays there is wide access to information. Specifically, photovoltaic inverters extract several variables, i.e., self-consumption, injection, tension, voltage, efficiency, active power, etc., that are constantly generated and are not usually employed beyond the information that is provided to consumers. These data can be combined with information that can be extracted from weather conditions to generate accurate models. An energy system that can efficiently recognize and manage these data is the basis for development in the direction of greenhouse gas reduction. Artificial Intelligence techniques take advantage of this large amount of data [15]. This technology is capable of creating a model that adjusts the necessities of the system in real time. Although, as time increases, data increase.