## Abstract

Solar energy is one of the main renewable energy sources capable of contributing to global energy demand. However, the solar resource is intermittent, making its integration into the electrical system a difficult task. Here, we present and compare two machine learning techniques, deep learning (DL) and support vector regression (SVR), to verify their behavior for solar forecasting. Our testing from Spain showed that the mean absolute percentage error for predictions using DL and SVR is 7.9% and 8.52%, respectively. The DL achieved the best results for solar energy forecast, but it is worth mentioning that the SVR also obtained satisfactory results.

## 1 Introduction

Renewable energy (RE) sources are increasingly being used due to the high electricity consumption of the modern society, making the world energy market grow [1]. In this context, solar energy has been a dominant renewable resource around the world. High prices for fossil fuels and carbon emissions are the main reasons driving the use of photovoltaic (PV) systems [2,3].

Power generation from decentralized RE sources has been increasingly used worldwide [4]. Particularly wind and PV plants have shown remarkable growth rate. The paradigm shift to clean generation has many motivations including emission reduction, regional self-sufficiency, and general advances to the decentralized energy systems [5–7].

Therefore, solar forecasting is an important area, with great significance for electricity generation systems that can be integrated into the distribution network and the management of traditional generation systems [8,9]. International energy markets, transmission system concessionaires/operators with their network dispatchers, and also operators of conventional power plants (which provide operational reserve) require reliable information about the immediate availability of electricity [10,11].

Support vector machine (SVM) is a methodology widely used in artificial intelligence (AI) due to the strong theoretical base and high generalization capacity. Since then, support vector regression (SVR) has been developed for forecasting applications [12]. SVR used for solar forecast can be found in researches from Refs. [13,–15]. For Meenal and Selvakumar [15], the accuracy of SVM, artificial neural network (ANN), and empirical solar radiation models were evaluated with different combinations of input parameters. The parameters studied were month, latitude, longitude, bright sunshine hours, day length, relative humidity, and maximum and minimum temperature. The models were evaluated based on statistical measures.

In research from Ref. [11], a forecasting model for a 20 kW PV plant in China was presented based on the SVM principle, weather forecasting, and actual power output data. The results showed that the proposed forecasting model for grid-connected PV systems was effective and promising. In Ref. [16], a wavelet-coupled support vector machine (W-SVM) model was adopted for global incident solar radiation forecast using the sunshine hours and other variables. To demonstrate the conclusive results, the merit of the W-SVM was benchmarked with the classical SVM model.

In the work of Yen et al. [17], two different kinds of solar prediction schemes for short-term (1-h) forecasting of solar output were proposed using SVM and random forest (RF) method. Jiang and Yao [18] proposed the penalized SVM model. A novel approach denoted as “forward regression on the quadratic kernel support vector machine” (QKSVM-FR) for building a quadratic regression model was developed using forward regression to select the main variables for solar forecasting in the Tibet Autonomous Region. SVM information criterion was used to select the kernel parameter and guarantee the model consistency. The results confirmed the outstanding forecasting performance of the proposed QKSVM-FR method compared to other existing methods.

Srivastava et al. [19] supervised machine learning techniques (neural networks, Gaussian processes, and SVM) were compared for the forecast of global horizontal irradiance (GHI). A simple linear autoregressive (AR) and two naive models based on persistence of the GHI and of the clear-sky index (denoted herein as scaled persistence model) were also analyzed.

Many researches have used ANN for solar forecast [20–37]. ANNs were used to forecast and estimate radiation and solar generation. In research from Gensler et al. [27], a long short term memory (LSTM), from deep learning (DL), was applied for short-term predictions based on a timescale that encompasses GHI 1 h and one day in advance. The power forecasts are filtered with the clear-sky filter. The power output forecast is matched with the values of the clear-sky filter. If the clear-sky curve estimated a value of terrestrial solar radiation equal to zero, the power forecast is set to zero as well. Ameen et al. [36] proposed a novel prediction model for PV system output current. The proposed model was based on cascade-forward back-propagation artificial neural network with two inputs and one output.

Deep learning (DL) has shown to be very powerful in forecasting tasks, such as economic time series or speech recognition. DL and ANN algorithms, such as deep belief networks, AutoEncoder, and LSTM, have been introduced in the field of RE power forecasting [38]. In the research from Zaouali et al. [39], an auto-configurable middleware based on a LSTM model was applied for several forecasting time dimensions to choose the significant timescale for learning setting. DL algorithms can be used to predict PV power generated and LSTM stands out for having an artificial recurrent neural network (RNN) architecture characterized by its ability to handle complex problems with high nonlinearity [40].

Al-Hajj et al. [41] presented a comparative study of various structures of stacking-based ensembles of data-driven machine learning predictors that are widely used nowadays to conclude the best stacking strategies in terms of performance to combine predictors of solar radiation. Khatib et al. [42] presented a research with feed-forward back-propagation artificial neural network and was developed to predict solar radiation in terms of longitude, latitude, time of the day, temperature, altitude, pressure, amount of dust, and volume mixing ratio of water ice clouds.

Within the context presented and the growing demand for RE, PV power has increased considerably in recent years. Accurate forecasting of PV power is important for the reliability of the system and the promotion of large-scale PV use [11]. Studies showed that a 25% improvement in PV power output forecast accuracy can lead to a reduction of 1.56% (US$ 46.5 million) in the net generation cost [43,44]. Hence, solar forecasting can be used to actively determine the generation capacity efficiency [40].

Motivated by the increasing use of PV plants in Spain, we propose a methodology using SVR and DL for the reduction of PV power forecasting errors, considering that these techniques offer performance and efficiencies suitable for the proposed application [45,46]. Additionally, we use a mathematical method to define the number of inputs of the mentioned techniques, as well as the number of DL processing units. It is worth mentioning that SVR already has in its algorithm a mechanism for defining the amount of support vectors. The definition of the number of processing units and inputs is a recurring theme in the field of AI. Usually, AI programmers use the trial and error method for fine-tuning [47–58] to achieve better results. Our algorithm is in condition to improve, self-evaluate, and refine SVR and DL, ensuring the ideal number of mechanisms in the presented topology. Such a refinement methodology is essential for comparison between SVR and DL, allowing that both methodologies work with the best possible performance.

This study was developed specifically for the comparison of the two forecasting techniques based on the topologies of DL and SVR. The literature review demonstrates the potential of the mentioned techniques, providing researchers with a base for an effective choice between the strategies. DL was chosen considering its specific properties such as the ability to ignore and/or store information for future processing. SVR, a technique based on machine learning, was selected considering its potential for generalization of time series characterization.

Support vector regression and DL have been tested over a period of 5840 h, which was implemented after a training phase of 46,720 h of solar irradiance and ambient temperature data, collected in Algeciras, Spain.

Another important contribution of our research is the definition of which technique achieves the best result in each season of the year. We emphasize that the comparison is implemented using the optimum topology of the mentioned techniques, generating a comparison without the interference of human decisions.

## 2 Methodology

### 2.1 Data Collection.

Solar irradiance and ambient temperature data were obtained from Algeciras, province of Cádiz, Spain (latitude: 36.128 deg, longitude: −5.450 36 deg, 08ft 12.9ft North, 5 deg 27ft 12.0″ West) using the PV geographical information system of the European Commission/Institute for Energy and Transport (IET).

Data collection period was from Jan. 2007 to Dec. 2015, totaling nine years of collection and resulting in 52,560 solar irradiance and ambient temperature measurements. For the two machine learnings training, eight years of all collected data were used (2921 days). Figure 1 shows the measurements location.

### 2.2 Support Vector Regression.

SVM was developed by Vapnik in 1995 to solve the classification problem. It is based on building a hyperplane with a decision surface in such a way that the margin of separation between positive and negative examples is maximum [59].

For the regression problems, a SVM extension called SVR was created. Basically, SVR uses the same principles as an SVM except that SVR determines the optimal separation hyperplane in order to minimize the distance between the training samples and this surface, regardless of which side of the hyperplane is the sample. Deviations are allowed as long as they do not exceed tolerance (Fig. 2).

Support vector regression structure is illustrated in Fig. 3, where *X*_{0}, *X*_{1}, and *X*_{2} represent the input variables, *K*_{(x,x1)} and *K*(*x*, *x*_{2}) are the intermediate processing units, *Y* represents the AI output, and the parameters *w*_{i} are the weights of the connections between intermediate and output layers.

*K*

_{(x,xi)}are found through Eq. (1), where

*x*is the input vector and

*σ*is the kernel parameter which defines the structure of the high dimensional feature space.

*w*

_{j}is the output of AI and

*w*

_{j}is the weight.

### 2.3 Deep Learning.

One of the emerging forecast in the field of AI is DL, a subcategory of machine learning capable of improvement over other methods of computer learning. DL technique architectures provide resources to model with detail characteristics of the data set imperceptible to other techniques, providing a more efficient representation than shallow models, thus improving generalization [60].

In order to explore these characteristics and produce predictions of solar irradiance, the technique called LSTM was implemented, which is a RNN architecture in the field of DL. LSTM has an advantage over conventional ANN due to their property of selectively remembering patterns for long durations of time [5], as shown in the process of the LSTM model with five layers (input layer, hidden layer, context layer, forget layer, and output layer) in Fig. 4.

*f*

_{t},

*i*

_{t},

*g*

_{t}, and

*o*

_{t}are the forgetfulness, input, update and output gates, respectively,

*c*

_{t}represents the memory cell,

*h*

_{t}represents the network output,

*σ*is the sigmoid function,

*ϕ*is the hyperbolic function,

*x*

_{t}is the LSTM input,

*w*refers to the weights of each stage, as well as

*b*is the bias of each stage.

### 2.4 Fine-Tuning Forecasting Techniques.

The data collected from solar radiation, temperature, month, and time of collection are evaluated as input of the machine learning inputs, and the amount of previous data used is defined by the method of incrementing and checking the error. Fine adjustments to define the processing unit in the hidden layer will follow the same methodology. Therefore, with each increase in the number of entries, starting from 1, forecasting techniques are retrained.

The algorithm finds an assessment value of the current situation and stores it in a vector. After the limit of increments is reached, the refiner used finds the ideal point, that is, the ideal number of system inputs that generates a smaller amount of errors. This methodology is repeated for the two solar forecasting techniques used in this paper.

*D*

_{p}are the predicted data,

*D*

_{o}are the observed data,

*n*is the number of predictions made, and

*m*is the limit of increments.

### 2.5 Performance Analysis.

*W*

_{forecasted}are the forecasted values,

*W*

_{true}are the collected values of irradiance, and

*N*is the number of data sample.

## 3 Results

Nine years of collected data from Algeciras, Spain, were used. Data are consecutive and all weather conditions in the period (including rainy and cloudy days) were considered. The last year of collection, 2015, was not used for the AI training but for testing. Figure 6 shows the behavior of the forecasts during the testing period.

The most accentuated SVR positive error was 73.14% while the most accentuated negative error was −69.67%. Considering DL, these values were 81.59% and −68.33%. Although DL showed greater error peaks, its behavior was considered more stable and reliable (MAPE of 7.89% for DL and of 8.52% for SVR). A forecast boxplot is shown in Fig. 7 comparing data provided by the two techniques and data collected in the period.

The interquartile range limits were 72.46–909.86 W/m^{2} for SVR, 27.49–892.73 W/m^{2} for DL and 0–938.38 W/m^{2} for the data collected in the trial period. The best results were achieved by DL. SVR obtained negative punctual values: the most accentuated predicted an irradiance of −198.92 W/m^{2}. This behavior was also found for DL but in a smaller number and with a less pronounced value of −81.55 W/m^{2}. To understand the behavior of the forecasts in different climatic conditions, Fig. 8 presents the boxplot of the techniques for the four seasons (winter, spring, summer, and autumn).

Support vector regression interquatial ranges were −3.76% to 2.41%, −4.94% to 1.89%, −4.37% to 2.53%, and −1.38% to 2.83% for winter, spring, summer, and autumn, respectively. DL values were −3.69% to 3.48%, −2.84%, 0.68%, −3.84% to 0.89%, and −2.59% to 2.63% for winter, spring, summer, and autumn, respectively. SVR MAPEs were 8.68%, 8.35%, 9.19%, and 7.83% for winter, spring, summer, and autumn, respectively. DL MAPEs were 8.67%, 7.39%, 7.92%, and 7.92% for winter, spring, summer, and autumn, respectively. Hence, DL shows a better performance in spring and summer, VR a better performance in autumn and a similar performance of the two techniques in winter.

To understand the general behavior during the testing period of the forecasting techniques, Figs. 9 and 10 are shown, where the distribution of errors and linear regression of the techniques studied are illustrated.

In relation to SVR, 73.10% of forecasts are between −10% and 10% of forecasting errors, while for DL this value is 73.16%. The positive errors were 34.55% for SVR and 31.55% for DL, while the negative errors were 40.53% for SVR and −43.53% for DL. MAPEs were 8.52% and 7.90% for SVR and DL, respectively. A greater data spread in the SVR linear regression graph is observed compared to the DL graph. Figure 11 shows the forecast histogram for the two techniques.

For SVR, the highest concentration of forecasts, generating a total of approximately 3450 forecasts, was in the range of −12.6% error to 1.73% error. For this range, the center is located at −5.41%, which shows a tendency of underestimation in the forecasts generated by this technique. With the asymmetry of the SVR technique demonstrated by means of the histogram, the second highlighted range has the limits of 1.75–16% of error, totaling 1030 predictions in that range, which has the center at 8.87% of error of prediction.

For DL, the highest concentration of forecasts, generating a total of approximately 3840 forecasts, was in the range of −8.36% error to 6.63% error. For this range, the center is located at −0.865% which demonstrates a great ability to approximate the predictions generated by the referred technique to the measured irradiance data. Through the histogram of the referred technique, it is also possible to perceive an approximate symmetry between the errors of the positive axis (overestimation of solar availability) and the negative axis (underestimation of the solar resource).

## 4 Discussions

The results characterize that due to the better behavior in two seasons (spring and summer), as opposed to a tie (winter) and a comparative disadvantage in just one season (autumn), as well as better MAPE, the DL is introduced as a technique with superior results in terms of solar forecasting capacity compared to SVR. The results are condensed using Table 1.

Comparison | SVR (%) | DL (%) |
---|---|---|

MPE | −0.65 | 0.52 |

MAPE | 8.52 | 7.90 |

Range −10% to 10% | 73.10 | 73.16 |

Positive error | 34.55 | 31.55 |

Negative error | 40.53 | 43.53 |

Comparison | SVR (%) | DL (%) |
---|---|---|

MPE | −0.65 | 0.52 |

MAPE | 8.52 | 7.90 |

Range −10% to 10% | 73.10 | 73.16 |

Positive error | 34.55 | 31.55 |

Negative error | 40.53 | 43.53 |

During the performance of the AIs tests, a total of 5840 h of exposure and processing of solar irradiance and ambient temperature data were used by the two techniques. This results in a long test time and, consequently, due to its use in a large time scale, it eliminates possible occasional errors of comparison of the techniques during the evaluation of the predictors. The fact is that the larger the sample, the greater the possibility that the processed data will clearly represent the difference between the techniques studied. From a cost perspective, it was found that due to errors in the solar and wind forecast in the German market, for example, electricity production from these sources was 2 GW h below forecast, resulting in an additional cost of 2.20 euros per MW h generated from wind and solar sources [61].

In Spain, the electricity from RE sources in 2020 was 109,269 GW h, of which 54,383.882 GW is wind energy and 15,287.635 GW is solar energy, totaling 69,671.517 GW of these two sources. A difference of error of 0.62% (MAPE) between the DL and the SVR would result in 431.963 GW of generated electricity expected in the Spanish electric sector. The large amount of electric energy from renewable and interminable sources, if not correctly predicted, can generate significant increases in the production costs of these sources.

After a detailed analysis of the solar forecasting techniques based on the SVR and DL topologies, it can be clearly seen that in the annual context, DL performs better than SVR.

Through the linear regression graph, it is possible to notice a smaller spread of the predictions of the DL in relation to the ideal point, which represents a greater capacity of accuracy of this technique. In addition, the histogram illustrates that the DL has an approximate symmetry between positive and negative errors as well as a large number of its predictions in the range of errors from average to zero. The superiority of this technique is undeniable as shown by the results and analysis obtained in this work.

In the climatic context, separating the performances by seasons, it can be seen that, although the DL presents superiority, the use of SVR is recommended, if accessible, during the autumn. DL presents better results for the other two seasons and a technical draw with SVR for only one climatic season of the year.

## 5 Conclusions

This paper presented a comparison of two machine learning techniques (DL and SVR) applied to the solar energy forecast. DL used for solar prediction obtained best results compared to the SVR technique.

In all the evaluation criteria, DL obtained an small advantage over SVR as shown in the following results:

SVR MAPE was 8.52%; DL MAPE was 7.90%.

SVR MPE was −0.65%; DL MPE was 0.52%.

The range −10% to 10% for SVR was 73.10%; for DL was 73.16%.

In this work, a mathematical system was developed to define the number of processing units in SVR and DL. Using Eq. (9), the ideal number of inputs was evaluated and in the case of DL, the number of processing units in the hidden layer. An important contribution of this research is that the developed algorithm automatically generates an evaluation of the behavior of the variations in the number of processing units. This automatically selects the ideal final topology, thus it does not take much time to empirically test the ideal topology. It is noteworthy that many studies did not use it in this way [11,15,17].

It can also be concluded that the use of DL as a solar resource predictor showed results closer than SVR. SVR technique achieved a hit rate of 91.48% and DL achieved a hit rate of 92.1%.

## Conflict of Interest

There are no conflicts of interest.

## Data Availability Statement

The authors attest that all data for this study are included in the paper. No data, models, or code were generated or used for this paper.