Abstract
This study aims to find the most powerful algorithm between LM and GD, applying them to the multilayer neural network (MLP) to predict the wind speed of the city of Tetouan. To achieve this we will use the meteorological data of this city from 31/07/2017 to 31/08/2022. The MLP adopted for our study is composed of two hidden layers, 30 neurons in the first layer and 15 in the second, 7 inputs and one output. The data is divided into 80% for training and 20% for testing. The results obtained showed that the Levenberg-Marquardt (LM) algorithm is more efficient than the gradient descent (GD) algorithm with a correlation coefficient R = 0.988102 and a mean square error MSE = 0. 0458. These results will allow us to accurately predict the wind speed of August for the year 2022 in this city.
Keywords
Introduction
Nowadays, the importance of producing energy from renewable sources is immense for all countries. The promotion of sustainability and environmental health is not the only benefit, but it also promotes economic resilience, energy autonomy, and a more sustainable future for all.
Our research will focus on wind energy, and we chose Tetouan City as the location due to its geographical favorableness for wind energy. The meteorological environment at the chosen site is particularly diverse, so to optimize the use of wind energy in this particular region, it is crucial to have accurate wind speed prediction.
Various methods are established to improve the accuracy of wind speed prediction, including time series techniques such as persistence, ARMA (Autoregressive Moving Average), gray predictor, and Kalman filter. Additionally, machine learning methods such as RNA (Recurrent Neural Networks), RNA-fuzzy, SVM (Support Vector Machines), and others include spatial correlation. (Beauregard-Harvey, 2018).
The effectiveness of these methods depends on the time horizon studied. In this context, we carried out a short-term study based on Tetouan’s historical data, our choice for wind speed forecasting was neural networks because of their ability to control variables with stochastic characteristics.
To predict the future values of wind speed, the MLP model, which is a feed-forward neural network, is used.
We implemented it each time using the two famous algorithms LM and GD in MATLAB on the meteorological data of Tetouan city for 5 years.
In this context, we conducted a short-term study using neural networks, which have proven to be highly relevant and powerful. The study is based on historical data to predict wind speed which has stochastic characteristics. Specifically, we employed a multilayer perceptron (MLP) implemented each time by the two famous algorithms LM (Levenberg-Marquardt) and GD (Gradient Descent). The training was performed in MATLAB using meteorological data from the city of Tetouan over 5 years.
The purpose of this article is to find answers to the following questions:
Is the MLP application suitable to process the data of this site? If yes, which is the most powerful algorithm among LM and GD, and which gives a good accuracy? (Salami et al., 2017).
Methodology
Theoretical study
The multilayer perceptron
A non-looped or forward propagating artificial neural network is constructed of three essential layers, the input layer in the form of variable values (are not neurons) which does not perform any calculation, a hidden layer (or more than one layer), and an output layer. The neurons of each layer are interconnected, while the nodes of the same layer are independent (Qu’est-ce qu’un réseau neuronal artificiel ? - IONOS, n.d.)
The general mathematical model of the multilayer perceptron is illustrated in the diagram below (Figure 1).

The structure of a multilayer artificial neural network (Beauregard-Harvey, 2018).
The desired output can be calculated by applying the following equation:
There:
The mathematical model chosen for our study is illustrated in the diagram below (Figure 2).

The perceptron with two hidden layers. (Nasr, n.d.).
To obtain the output of each layer, we apply the following mathematical relationships:
During the learning phase, the output of a neuron must exceed the specified threshold to activate, thus allowing the next layer to receive information that propagates in the same direction, so each output represents the input of the neuron that follows it, which justifies the process of forward propagation or feedforward of this model (Nasr, n.d.).
In this article, we try to improve the performance of the neural network by reducing the total error which can be calculated by:
Practical study using Matlab
Data preprocessing and normalization
The prediction gives a primordial importance to the preprocessing of the data, it is the first step to be carried out in this study. The collected data are pre-processed via EXCEL to eliminate some non-numerical variables disturbing the learning of the chosen model, and which are in a certain format not acceptable by MATLAB.
After the pre-processing phase, the data with variable scales will be transformed into other appropriate data of comparable scales before providing them to the learning algorithm, so that we can analyze them simply (Ren et al., 2009; Salami et al., 2017).
We will normalize them in an interval [−1,1] via the following relation.
With :
Xi: Original data
Choice of variables for the prediction model
We processed the weather data of the city of Tetouan from 31/07/2017 to 31/08/2022 obtained from the site https://power.larc.nasa.gov/data-access-viewer/ (Table 1).
Presentation of the weather sheet of Tetouan.
From the table of variables below (Table 2), we notice that the dew temperature and the wind temperature have a coefficient R = 0.826927, this value shows that these two variables have the same climatological characteristics, so they have the same effect on the desired output which allows us to eliminate one of them to avoid all the expensive calculations (Amellas et al., 2020a).
The correlation coefficients between the variables.
The inputs of the model include seven variables, pressure, relative humidity, surface temperature, precipitation, wind direction, maximum and minimum wind speed all at time t. The output is the wind speed that we want to predict at the same time t (Salami et al., 2017).
Programing steps Result and discussion
After preparing the program as shown in (Figure 3), we performed several tests by increasing the number of input variables from five inputs; pressure, temperature, humidity, precipitation, and wind direction; to seven inputs; pressure, temperature, humidity, precipitation, wind direction, minimum wind speed, and maximum wind speed. Thus we changed every time, the number of hidden layers and neurons for each hidden layer, we found that the model has a good performance with seven inputs, two hidden layers with 30 neurons at the first layer and 15 at the second for both algorithms (Figure 4) (Amellas et al., 2020b).

The flowchart of the short-term output prediction program is valid for both algorithms (Ren et al., 2009).

MLP -2 hidden layers- (30,15) neurons-Tansig activation function.
MSE, RMSE, and MAE are errors that show the difference between the actual output and the desired output, we have calculated them for the training and testing phases as shown in Tables 3, 5 and 7.
The training results were obtained by the two algorithms LM and GD
There:
The values of coefficient R obtained for the three phases; training, validation, and test are 0.99102, 0.98269, and 0.97673 for LM, 0.97213, 0.97316, and 0.97526 for GD (Figures 5 and 8) these values are close to 1, which shows the strong relationship between the actual and desired output (Figures 6 and 9); consequently, the model chosen for Tetouan city is capable of predicting the wind speed (Amellas et al., 2020b).

The diagram of the regression obtained by the LM algorithm.

Wind speed prediction obtained by the LM algorithm.
Figure 7 shows that the error decreases after more training epochs but in the case of LM, we notice that it can start to increase on the validation data set when the network starts to overfit the training data. In this case, the training stops after 31 consecutive increases in the validation error, and the best performance of value 0.036094 is obtained from the 11 epoch where the value of the validation error is the lowest (Analyze Shallow Neural Network Performance After Training - MATLAB & Simulink - MathWorks Benelux, n.d.). For the case of GD, the program needs to do 1000 epochs to reach the good performance of value 0.054519 as shown in Figure 10.

The performance graph obtained by the LM algorithm.

The regression diagram obtained by the GD algorithm.

Wind speed prediction obtained by the GD algorithm.

The performance graph obtained by the GD algorithm.
The errors obtained by both algorithms demonstrate that the program is well-trained, which justifies the accurate estimations of the wind speed for August as shown in Tables 4 and 6 and illustrated in Figures 11 and 12. These results demonstrate that the LM algorithm is more effective than GD algorithm for our site.
Forecast results using the LM algorithm.
Erreurs for The Tasting phase using LM.
Forecast results using the GD algorithm.
Erreurs for The Tasting phase using GD.

Wind speed prediction for August using the LM algorithm.

Wind speed prediction for August using the GD algorithm.
Training phase Testing phase
We need to test the program to judge the ability of the chosen model to predict the wind speed, for this purpose, we will apply the sim function to calculate the desired output (Ren et al., 2009)
Ptest: The test data of the neural network
Conclusion
The MLP study for Tetouan city, implemented by LM or GD in MATLAB to predict wind speed allowed us to conclude:
The application of MLP on dynamic features to identify and predict wind speed is feasible.
The MLP neural network has better fitting ability and higher predictive accuracy.
Despite the good results obtained by the two algorithms, the one of Levenberg Marquardt (LM) remains the most powerful, which gave a good accuracy with a coefficient MSE = 0.0458, compared to GD which has a value of MSE = 0.1101.
In a future article, we will study other predictive models to understand how they work and other algorithms designed to improve their performance.
Footnotes
Author contributions
All authors contributed to the study’s conception and design. Material preparation, data collection, and analysis were performed by [Wissal Masmoudi] and [Abdelouahed Djebli]. The first draft of the manuscript was written by [Wissal Masmoudi] and both authors commented on previous versions of the manuscript. Both authors read and approved the final manuscript.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
Ethical approval
This study does not contain any studies with human or animal subjects performed by any of the authors.
