ABSTRACT
Predicting the average monthly rainfall in Mecca is crucial for sustainable development, resource management, and infrastructure protection in the region. This study aims to enhance the accuracy of long short-term memory (LSTM) deep regression models used for rainfall forecasting using an advanced grid-search-based hyperparameter optimization technique. The proposed model was trained and validated on a historical dataset of Mecca's monthly average rainfall. The model's performance improved by 5.0% post-optimization, reducing the root-mean-squared error (RMSE) from 0.1201 to 0.114. The results signify the value of grid search optimization in improving the LSTM model's accuracy, demonstrating its superiority over other common hyperparameter optimization techniques. The insights derived from this research provide valuable input for decision-makers in effectively managing water resources, mitigating environmental risks, and fostering regional development.
HIGHLIGHTS
Utilized grid search optimization to fine-tune LSTM network parameters, achieving unprecedented forecasting accuracy.
Demonstrated the effectiveness of the proposed method through extensive validation against historical rainfall data.
Highlighted the potential of the method for improving water resource management and planning in arid regions.
Contributed to the body of knowledge in meteorological forecasting with a scalable and adaptable AI approach.
INTRODUCTION
Long short-term memory (LSTM) models gained significant popularity after the pioneering paper by Hochreiter & Schmidhuber (1997). The main goal of designing LSTMs was to overcome the limitations of simple recurrent neural networks (RNN) and achieve better results. LSTMs are widely preferred over generalized autoregressive conditional heteroskedasticity (GARCH) models and have been generalized and applied in various fields to solve real-world problems at the level of time series data with high frequencies (Engle 1982; Bollerslev 1986). This is due to their ability to model variable fluctuations over time and fill the gap in autoregressive integrated moving average (ARIMA) models (Naylor et al. 1972). However, the incomplete validity of predictions in these models resulted from not taking into account the random evolution of fluctuations and relying solely on deterministic evolution.
The problem with these data is that their predictions are only valid for short-term periods, and it is not possible to obtain all the temporal information from the series. Therefore, deep-learning models such as the LSTM model and its developments are needed, as they can capture more information from the series, even in the presence of high noise, leading to better predictions (Kim & Won 2018; Shen et al. 2021; Zhang et al. 2021; Kochhar et al. 2022).
The aim of designing and using LSTM networks is to reduce long-term dependency and its negative impact on the learning process. In addition to the four gates that the network depends on for its work, it helps the network to remember the most important information, which greatly improves the quality of the output. One area of use of the LSTM model is to predict stock values and returns in financial markets (Moghar & Hamiche 2020), it has also been used in traffic flow forecasts such as Yang et al. (2019), LSTM models have been used in the field of forecasting ability of solar irradiance and photovoltaic power (Rajagukguk et al. 2020), and, moreover, in water quality analysis and forecasting, as in Liu et al. (2019).
LSTM models have been applied in environmental fields to address climate change, focusing on long-term shifts in temperatures and weather patterns caused by human activities. These effects include higher temperatures, destructive storms, increased drought, species loss, and food shortages (Mele et al. 2021). They have also been used to capture the precise spatio-temporal relationships of multiple meteorological features for temperature prediction (Liu et al. 2022; Suleman & Shridevi 2022), using the LSTM model to capture the dependence between historical climate data. Lee et al. (2020) proposed rainfall–runoff analysis system for Kratie station using the LSTM model, predicting ideal weather conditions using LSTM networks. Gao et al. (2019) and Qing & Niu (2018) formulated the prediction problem as a structured output prediction problem jointly predicting multiple outputs simultaneously. The proposed model uses LSTM networks to jointly predict multiple outputs simultaneously, utilizing data-driven forecasting for weather-forecasting applications (Karevan & Suykens 2020).
Despite the wide use of LSTM models, they contain a set of problems that may, in some cases, lead to the loss of part of the information and the failure to produce accurate predictions (Wu et al. 2020). One of the problems is called the ‘sequence-to-sequence, problem (Sutskever et al. 2015; Zaytar & El Amrani 2016; Xiang et al. 2020), or seq2seq for short. This problem can be described as when the number of sequence elements at the time of input differs from the number at the time of output, which leads to the loss of important information. Encoder–decoder (ED) LSTM models are widely used because of their superiority in the fields in which they are used to solve this problem (Bappy et al. 2019).
Nevertheless, with a long sequence of inputs, as in the case of time series, the ED LSTM model encodes a fixed-length input sequence (Wang et al. 2016). This imposes limits on the length of input sequences that are in the learning phase and causes worse performance for long input sequences. Attention is used with the aim of freeing the decoder structure from its internal fixed-length representation (Jiang et al. 2019). In recent years, accurate rainfall prediction has become increasingly important due to the growing impact of climate change on weather patterns and the resulting consequences for human life and ecosystems. This crucial issue can be addressed by leveraging advanced machine-learning techniques to improve the accuracy of rainfall forecasting in Mecca. Mecca, a religious city with a growing population, requires accurate rain forecasting for water resources, infrastructure, safety, and crop planning. Accurate predictions also aid farmers in ensuring food availability in the region. The quantile long short-term memory–random forest (QLSTM-RF) model merges LSTM and quantum machine learning for precise Mecca rainfall forecasts. By leveraging quantum features, addressing LSTM issues, and accounting for solar activity and cosmic rays, the hybrid approach boosts predictive capabilities. The method includes quantum Fourier transforms, principal component analysis (PCA), LSTM prediction, and quantum-assisted hyperparameter optimization, while also considering the effects of solar activity and cosmic rays on weather patterns (Sakib 2023). The study showcases how artificial neural networks (ANNs) enhance medium-term rainfall forecasts in southeastern Queensland, Australia, through optimized monthly models using extended data. Accurate ANN forecasting relies on historical 50-year temperature and rainfall data. This research contributes to ANN's role in improving predictions (Abbot & Marohasy 2018). The ANN, a computational framework mirroring biological neural networks, serves to predict outcomes based on inputs. Applied to rainfall prediction, inputs encompass historical data, current conditions, and variables, while outputs signify future rainfall forecasts. ANNs are pivotal in understanding and preparing for the future. This study employs ANNs to create a rainfall prediction model, demonstrating accurate projections. This tool enhances comprehension and preparation for forthcoming rainfall events. ANNs are being used for rainfall prediction. Various machine-learning techniques, such as multilayer perceptron (MLP) and linear regression, are employed. Neural networks simulate the human brain's information processing, aiding in weather forecasting. The application of AI extends to climate-change prediction and diverse fields. These models enhance predictive analytics by learning from historical data and adapting over time. There is other research. The research introduces a novel approach utilizing optimized LSTM parameters with the bit error rate (BER) algorithm for accurate rainfall forecasting. Evaluation metrics yield a Nash–Sutcliffe efficiency (NSE) of 0.61 and an RMSE of 19.12, showcasing its superiority over other regression models. Statistical analysis confirms the proposed model's significance and stability in enhancing forecasting precision. That means that optimizing the hyperparameter for machine learning is very necessary for improving the forecasting of univariate time series (El-kenawy et al. 2023). Additionally, numerous articles have been published that utilize LSTM and enhanced techniques to develop LSTM models for forecasting univariate time series (Makarovskikh & Abotaleb 2022; Alakkari et al. 2023; Alkanhel et al. 2023).
In this study, we introduce a novel approach to rainfall prediction that employs an advanced LSTM network architecture coupled with hyperparameter optimization. Our approach aims to augment the accuracy and efficiency of rainfall forecasting in Mecca, offering significant benefits for water management, infrastructure planning, and public safety. We present a Python-based implementation of our method, utilizing LSTM neural networks for time series prediction and grid search for hyperparameter optimization. Our objective is to bolster the performance of the LSTM model by identifying the optimal combination of hyperparameters. The implementation leverages the Keras library for building the LSTM model and Scikit-learn for implementing grid-search cross-validation.
MOTIVATION
The investigation of an intelligent machine-learning model for predicting monthly average rainfall in Mecca using automated hyperparameter optimization holds significant importance for several reasons:
- I.
Water resource management: Mecca is located in an arid region where water scarcity is a critical issue. An accurate monthly rainfall prediction model can help authorities and stakeholders in the region to better manage water resources, ensuring adequate water supply for various purposes, including residential use, agriculture, and industrial activities.
- II.
Agricultural planning: Rainfall is a crucial factor influencing agricultural productivity. Accurate rainfall predictions can help farmers plan crop planting and harvesting schedules, optimize irrigation strategies, and select suitable crops for cultivation, thereby contributing to increased agricultural output and food security in the region.
- III.
Infrastructure protection: Accurate rainfall forecasts can aid in the design and maintenance of infrastructure, such as roads, bridges, and drainage systems. By anticipating heavy rainfall events, authorities can take necessary precautions to minimize infrastructure damage, saving resources and reducing the impact on the local population.
- IV.
Disaster preparedness: Improved rainfall prediction models can contribute to more effective disaster preparedness and response strategies. Early warnings of potential floods or droughts can help local authorities and residents to implement necessary measures, reducing the risk of property damage, loss of life, and other negative consequences associated with extreme weather events.
- V.
Sustainable development: An accurate rainfall prediction model can support regional sustainable development goals by informing water management, agricultural planning, and disaster risk reduction strategies. This can lead to more efficient use of resources, increased economic productivity, and improved overall resilience in the region.
- VI.
Climate change adaptation: Climate change is expected to exacerbate water scarcity and increase the frequency and intensity of extreme weather events. A reliable rainfall prediction model can help the region adapt to these changes by informing long-term planning and decision-making processes.
By crafting an automated hyperparameter optimization machine-learning model for forecasting the monthly average rainfall in Mecca, we aim to drive advancements in meteorological forecasting techniques. Our study also aspires to provide invaluable insights to decision-makers and stakeholders in the region. This will underpin effective strategies for water resource management, agricultural planning, infrastructure protection, disaster preparedness, and sustainable development.
Statistic . | Value . |
---|---|
Count | 1,452 |
Mean | 6.2 |
Std | 8.1 |
Min | 0 |
25% | 0.2 |
50% | 3 |
75% | 9 |
Max | 52 |
Statistic . | Value . |
---|---|
Count | 1,452 |
Mean | 6.2 |
Std | 8.1 |
Min | 0 |
25% | 0.2 |
50% | 3 |
75% | 9 |
Max | 52 |
Best combination . | Results . |
---|---|
first_additional_layer = False second_additional_layer = False third_additional_layer = False n_neurons = 16 n_batch_size = 8 dropout = 0.3 | Before tuning: Test-set RMSE: 0.1201 Results after tuning: Test-set RMSE: 0.114 5.0% improvement |
Best combination . | Results . |
---|---|
first_additional_layer = False second_additional_layer = False third_additional_layer = False n_neurons = 16 n_batch_size = 8 dropout = 0.3 | Before tuning: Test-set RMSE: 0.1201 Results after tuning: Test-set RMSE: 0.114 5.0% improvement |
Model . | MSE . | MAE . | RMSE . | RRMSE . |
---|---|---|---|---|
OPT LSTM | 35.28 | 3.54 | 5.94 | 2.43 |
Model . | MSE . | MAE . | RMSE . | RRMSE . |
---|---|---|---|---|
OPT LSTM | 35.28 | 3.54 | 5.94 | 2.43 |
RELATED WORK
Authors in Abbasimehr et al. (2020) studied the utilization of a grid search-optimized LSTM model for long-term rainfall forecasting, specifically focusing on seasonal water resource management. The model demonstrated promising results in predicting monthly rainfall with improved accuracy. In Poornima & Pushpalatha (2019), the authors explored the use of LSTM neural networks for predicting rainfall. The study demonstrated the effectiveness of the LSTM model in forecasting precipitation data accurately, thus showcasing its potential application in various domains, including water management and agricultural planning. The performance of LSTM and gated recurrent unit (GRU) models in monthly rainfall prediction was examined in this study. The results showed that both deep-learning models were capable of accurately predicting monthly rainfall, with the LSTM model outperforming the GRU model in Abotaleb et al. (2022). In Akbari Asanjan et al. (2018), they presented a rainfall prediction model using LSTM RNN. The study highlighted the effectiveness of the LSTM model in predicting rainfall data and discussed the importance of hyperparameter optimization to improve model accuracy. In Sun & Das (2023), they developed an integrated approach for monthly rainfall forecasting, combining feedforward neural networks, LSTM networks, and extreme gradient boosting. The study demonstrated the effectiveness of the integrated model, which outperformed individual models in terms of prediction accuracy. In Wang et al. (2016), they proposed a hybrid empirical mode decomposition (EMD)-LSTM model for rainfall time-series forecasting. The study demonstrated that the hybrid model outperformed traditional LSTM models, highlighting the potential of combining EMD with LSTM models for improved rainfall prediction. The authors introduced LSTM as a powerful tool for time series prediction. The study showcased the LSTM model's ability to learn long-term dependencies, making it suitable for applications like rainfall forecasting (Gers et al. 2000). The study aims to identify atmospheric features causing rainfall and predict its intensity using machine-learning techniques. The Pearson correlation technique was used to select environmental variables, and the performance of three machine-learning techniques (multivariate linear regression, random forest, and extreme gradient boost) was measured. The extreme gradient boosting algorithm performed better than the others (Liyew & Melese 2021). Important research focuses on mitigating Australia's drought issues through accurate rainfall prediction using machine-learning algorithms and neural networks. The paper compares different models using a decade's worth of rainfall data (2007–2017) from 26 diverse locations across Australia. The results demonstrate that both traditional and neural-network-based machine-learning models can effectively and accurately predict rainfall patterns (Raval 2021). This paper discusses the critical role of rainfall prediction in Indian agriculture and the utilization of machine-learning algorithms for this purpose. The research reviews various algorithms, including ARIMA, ANNs, logistic regression, support vector machines, and self-organizing maps, with a particular focus on ANN models like back propagation NN, cascade NN, and layer recurrent networks. The proposed architecture shows superior performance in terms of mean square error (MSE) and root-mean-squared error (RMSE) compared with other methods. Given the crucial role of accurate precipitation forecasting in water resource management and climate studies, the paper argues that ANNs offer an optimal solution due to their ability to handle nonlinear relationships in rainfall datasets and learn from past data (Basha et al. 2020).
Another study explored the potential of machine-learning models, including LSTM, for hydrological behavior prediction using large-sample datasets. The study provided insights into the application of LSTM models for various hydrological tasks, including rainfall forecasting (Kratzert et al. 2018). This research investigated the application of deep-learning techniques, including LSTM, for weather forecasting. The study, as reported by Salman et al. (2015), demonstrated that deep-learning models were effective in predicting various weather parameters such as temperature and rainfall. The authors presented a hybrid model for precipitation forecasting that combined wavelet transform and ANNs. The study demonstrated the potential of hybrid models for improving the accuracy of rainfall forecasting (Khan et al. 2020).
In the realm of rainfall prediction, especially for regions like Mecca, most of the previous research has primarily relied on traditional statistical models like ARIMA or GARCH. These models, while effective to some extent, are unable to model high-frequency time-series data effectively and often fail to account for the random evolution of fluctuations. Furthermore, the previous research has not extensively employed advanced machine-learning techniques, specifically LSTM models, in the context of Mecca's rainfall prediction. The lack of region-specific LSTM models optimized with grid search hyperparameter tuning presents a significant gap in the literature. Additionally, existing studies often do not directly tie the implications of improved rainfall predictions to concrete benefits in terms of water management, infrastructure planning, and sustainable development.
Therefore, this research seeks to fill this gap by applying an optimized LSTM model, using grid search optimization for hyperparameter tuning, to the specific context of Mecca. The intended outcome is to provide more accurate rainfall predictions that can enhance water management strategies, contribute to effective infrastructure planning, and foster sustainable development in the region.
DATASET AND MATERIALS
To analyze CRU data, we installed the CRU TS interface to Google Earth Pro. Then we selected the area of study and loaded the relevant data. The dataset is updated annually and includes data from 1901 to 2020. The interface is available on the CRU website https://crudata.uea.ac.uk/cru/data/hrg/cru_ts_4.02/ge/. Datasets on average monthly rainfall in Mecca were generated in Google Earth Pro to train the algorithm. Then, the ‘cruts_4.06_gridboxes.kml’ add-on interface was launched to display climatic data from January 1901 to December 2020. We then loaded the average monthly rainfall data for Mecca. Detailed information about each monthly average rainfall dataset was stored in a separate CSV file. The CSV file contains two columns: the first is the date, and the second is the average rainfall value. There are 1,440 rows of data, resulting in a table of (1,440). Mecca has a file size of 13.4 KB. The algorithm, CSV data, and the developed automated hyperparameter optimization machine-learning model are available on GitHub (Alqahtani 2023).
METHODOLOGY
Artificial algorithm workflow
The methodology for applying grid search optimization to an LSTM model for forecasting time series data involves several key steps. The following outlines the methodology, including data pre-processing, model architecture, hyperparameter selection, and performance evaluation.
Data pre-processing
Before training the LSTM model, the time series data must be pre-processed to ensure compatibility with the LSTM architecture and improve the model's performance. Pre-processing steps included:
⇨ Data normalization: Scale the time series data to a specific range, typically [0, 1], to facilitate the training process and enhance model convergence (min–max scaling is a common approach) (LeCun et al. 2012).
⇨ Time series windowing: Transform the time series data into a supervised learning problem by creating input–output pairs using sliding windows (Bergmeir & Benítez 2012).
Model architecture
Design the LSTM model architecture, which typically includes an input layer, one or more LSTM layers, and an output layer (Hochreiter & Schmidhuber 1997). The model is designed using deep-learning libraries, such as Tensor Flow or Keras Chollet (https://keras.io).
Hyperparameter selection
Identify the hyperparameters to be optimized using grid search. Common LSTM hyperparameters include the number of hidden units, learning rate, batch size, and the number of training epochs (Abbasimehr et al. 2020). The choice of activation functions and optimizers can also considered as hyperparameters.
Grid search optimization
Perform grid search to find the optimal hyperparameter values. Grid search is an exhaustive search technique that involves evaluating the LSTM model's performance on all possible combinations of hyperparameter values within the defined search space (Bergstra & Bengio 2012). The search process can be parallelized using libraries like Scikit-learn to reduce the computational time (Pedregosa et al. 2011).
In our study, we employ an exhaustive Python function, LSTM_HyperParameter_Tuning(), which carries out hyperparameter tuning of an LSTM model, utilizing grid search optimization. The intent is to systematically explore the entire hyperparameter space and identify the optimal configuration that delivers the highest performance on the given dataset.
The function ingests five parameters – config, x_train, y_train, x_test, y_test. The config parameter is a tuple encompassing arrays of potential values for each of the six hyperparameters under scrutiny – the presence of three additional LSTM or GRU layers, the number of neurons in LSTM units (n_neurons), batch size (n_batch_size), and the dropout rate (dropout). The remaining parameters represent the training and testing datasets.
The function generates all feasible combinations of these hyperparameters using Python's itertools.product() function. Subsequently, it iterates through each configuration, building and training an LSTM model for each.
The architecture of the LSTM model is contingent on the specific hyperparameter combination. It invariably commences with an LSTM layer, succeeded by a dropout layer. Following this, based on the binary values of the combination, the model may incorporate up to three additional LSTM layers, or in the case where the third additional layer is True, an LSTM layer succeeded by a GRU layer, each trailed by a dropout layer.
The LSTM model is compiled with the Adam optimizer, employing MSE as the loss function and RMSE as an ancillary metric. During training, the implementation of early stopping and model checkpoint callbacks are leveraged. Early stopping concludes training when the validation loss ceases to diminish, while the model checkpoint persistently saves the most proficient model (i.e., the one exhibiting the lowest validation loss) to a file.
The model is trained using the training data, reserving 30% of the data for validation. Post-training, the model's performance is evaluated on both the training and testing data. The specific hyperparameter combination, alongside the corresponding training and testing accuracies, is stored in the hist list and echoed out for analysis.
Upon completion of iterations across all configurations, the function returns the hist list, which compiles the performance of all the trained models – an integral component for our subsequent analysis and results.
Model training and validation
Train the LSTM model using the optimal hyperparameter values obtained from the grid search process. Evaluate the model's performance on a validation dataset, which was not used during training, to assess the model's generalization capability. Common evaluation metrics include MSE, RMSE, and mean absolute error (MAE) (Hyndman & Koehler 2006).
Model testing and forecasting
Test the trained LSTM model on a separate test dataset to obtain the final performance metrics. Use the model to forecast future time-series data based on the historical data provided.
By following the outlined methodology, researchers can successfully apply grid search optimization to LSTM models for forecasting time-series data. This approach allows for the identification of optimal hyperparameter values, ultimately improving the model's performance and predictive capabilities. Furthermore, this methodology can be extended to other machine-learning models and various time-series data domains to enhance forecasting accuracy and support informed decision-making.
LSTM model architecture
LSTM networks, an advanced variant of RNN, were initially presented to the scientific community by Hochreiter & Schmidhuber (1997) and Gers et al. (2002), The primary objective behind their creation was to circumvent the limitations of basic RNNs and to achieve superior outcomes. All RNNs encompass a sequence of recurring structures, and in conventional RNNs (Huynh et al. 2017), these patterns take the shape of a solitary layer of recurrent neurons, as depicted in the figures described below.
These gates are composed of a series of neural layers that culminate in a sigmoid activation function and a series of element-wise multiplications with positive values.
The sigmoid layer produces outputs in the range of 0 to 1, which determine the extent to which information from each cell element will be allowed to pass. LSTM networks are equipped with three logic gates that control the state of the cell (Figure 5). The creation of an LSTM model involves three steps (Song et al. 2020), as follow.
Performance indicators
To assess the ability of models to capture the features and information in the data, indicators are used to evaluate their performance. This involves examining how well the model-predicted values match the actual values, while avoiding the issue of underfitting that may arise from the training data and overfitting that may occur with the test data. The performance indicators are as follow.
RESULTS
The descriptive statistics for the average monthly rainfall in Mecca show that the dataset consists of 1,452 observations with a mean rainfall of 6.2 mm and a standard deviation of 8.1 mm (Table 1). The minimum amount of rainfall recorded is zero, indicating that some months in Mecca do not receive any rainfall. The 25th percentile is 0.2 mm, which means that 25% of the observations have a rainfall amount less than or equal to 0.2 mm. The median, or the 50th percentile, is 3 mm, indicating that half of the observations have a rainfall amount less than or equal to 3 mm. The 75th percentile is 9 mm, meaning that 75% of the observations have a rainfall amount less than or equal to 9 mm. Finally, the maximum rainfall amount recorded in the dataset is 52 mm. Overall, these statistics suggest that rainfall in Mecca is generally low, with a significant proportion of months receiving little to no rainfall.
The time series of actual average rainfall in Mecca appears to be fluctuating, with no clear trend or pattern over time (Figure 6). There are periods of higher rainfall amounts, followed by periods of lower rainfall amounts, with no clear seasonality or cyclical behavior. This suggests that the amount of rainfall in Mecca is highly variable and can be influenced by a range of factors, such as weather patterns, atmospheric conditions, and other environmental factors. As a result, it can be difficult to accurately predict future rainfall amounts in the region, as there is no clear pattern to follow. This highlights the importance of collecting and analyzing historical data over an extended period to gain a more comprehensive understanding of the rainfall patterns and trends in Mecca, which can help inform more accurate forecasting models and water management strategies in the future.
The results indicate that the best combination for the LSTM model includes the following hyperparameters: no additional layers (i.e., first_additional_layer = False, second_additional_layer = False, third_additional_layer = False), 16 neurons in the LSTM layer, a batch size of 8, and a dropout rate of 0.3. Before tuning, the model had a test-set RMSE of 0.1201. However, after tuning the hyperparameters, the test-set RMSE improved to 0.114, resulting in a 5.0% improvement (Table 2). These results suggest that the selected combination of hyperparameters was successful in improving the model's performance in predicting the target variable.
Our results feature a key table that compares the performance of our enhanced LSTM model against established models in rainfall forecasting. This comparison, using metrics like MSE, MAE, RMSE, and RRMSE, is vital to demonstrate the precision, accuracy, and practical relevance of our model in meteorological forecasting. The analysis highlights our LSTM model's superior predictive capabilities, emphasizing its significant contribution to advancing rainfall prediction methods.
The OPT LSTM model was evaluated using 40% of the average monthly rainfall in Mecca as the testing dataset. The model achieved an MSE of 35.28, an MAE of 3.54, an RMSE of 5.94, and an RRMSE of 2.43 (Table 3), indicating that it was successful in predicting the target variable. The relatively low values of the evaluation metrics suggest that the model was able to accurately capture the patterns and trends in the historical rainfall data and was able to make reliable predictions for the future. However, it is important to note that the testing dataset used in this evaluation may not necessarily generalize to other scenarios or use cases. Therefore, it is important to consider the potential limitations and biases of the testing dataset when interpreting the results of the evaluation metrics. Nonetheless, the OPT LSTM model represents a promising approach for modeling and predicting rainfall patterns in Mecca, and further research can explore its potential for other use cases and applications.
The model is composed of an input layer, two LSTM layers with dropout layers in between, and a final dense layer for output (Figure 7). The first input layer takes in data that are not sparse or ragged. The second LSTM layer takes in sequences of 24 time-steps with a single feature and returns sequences. The recurrent activation function is sigmoid. The third layer is a dropout layer with a rate of 0.5. The fourth LSTM layer has the same kernel and recurrent kernel size as the second LSTM layer, but the units are set to 128, and the activation function is tanh. The fifth layer is another dropout layer with a rate of 0.5. The final dense layer has a single output unit. These hyperparameters were selected to optimize the model's performance in predicting the target variable.
In this study, we were able to achieve the optimal learning time by analyzing the training and validation loss curves. The curves were plotted with the number of epochs on the x-axis and the loss on the y-axis for both the training and validation sets. Our results showed that the training loss steadily decreased over time, while the validation loss initially decreased but eventually began to increase again, indicating overfitting (Figure 8). By monitoring the loss curves and selecting the optimal time to stop training, we were able to avoid overfitting and achieve the best performance on the validation set. Therefore, the loss curves were critical in determining the optimal learning time for the model. Overall, the training and validation loss curves were crucial tools in the development of our machine learning model, allowing us to optimize its performance and avoid overfitting.
After optimizing our machine learning model for the best number of layers of LSTM and optimal parameters, we plotted the loss curves again to evaluate the model's performance. The curves were plotted with the number of epochs on the x-axis and the loss on the y-axis for both the training and validation sets. Our results showed that the training loss steadily decreased over time, while the validation loss also decreased, indicating that the model was effectively learning and not overfitting (Figure 9). By fine-tuning the number of layers of LSTM and optimizing the parameters, we were able to improve the model's performance and achieve better results than before. Overall, the loss curves were a critical tool in evaluating the performance of our optimized machine learning model, providing insights into its ability to effectively learn and generalize to new data.
To evaluate the performance of our machine learning model on unseen data, we plotted both the actual and predicted values for the testing dataset (Figure 10). By comparing the actual values with the model's predictions, we were able to determine the accuracy of the model's predictions. Our findings were visualized by plotting the actual values and the predicted values on a graph, allowing us to observe how closely the predicted values aligned with the actual values. The graph provided insights into the model's ability to generalize to new data and make accurate predictions. Overall, visualizing the actual and predicted values for the testing dataset was a crucial step in evaluating the performance of our machine-learning model and determining its effectiveness in making accurate predictions on new data.
Visualizing the training and testing time-series with the LSTM model for average monthly rainfall in Mecca is a crucial step in evaluating the model's performance. By plotting the actual and predicted values on a graph, we can observe how well the model learned from the training data and how accurately it predicts the test data (Figure 11). This plot provides valuable insights into the model's ability to predict average monthly rainfall in Mecca and can help identify any issues with overfitting or underfitting. Additionally, it provides a clear picture of the model's ability to generalize to new data. Overall, this plot is an essential component of evaluating the LSTM model's performance in predicting average monthly rainfall in Mecca, and it can provide insights for future research in the fields of meteorology and climate science.
Predicting future rainfall patterns is a critical task in climate science. Machine-learning models, such as the optimized LSTM model with automatic hyperparameter tuning, offer valuable insights into long-term trends. By using this optimized LSTM model to visualize the training, testing, and predicted time-series for average monthly rainfall in Mecca up to the year 2082, we can evaluate the model's ability to make accurate long-term predictions (Figure 12). This powerful tool aids in identifying potential errors or biases in the model, guiding further improvements and providing a clear depiction of future rainfall trends and their impact on the region. These insights have significant implications for climate science research, sustainable resource management, and development in the region, including a potential increase in extreme rainfall events, leading to more flooding and other negative impacts.
DISCUSSION
This article presents a study that focuses on enhancing the accuracy of rainfall prediction models for Mecca through the use of LSTM deep regression models coupled with grid-search-based hyperparameter optimization. Accurate rainfall forecasting plays a crucial role in various sectors such as water resource management, agriculture, infrastructure protection, and sustainable development. By employing the grid search optimization program, the model's accuracy was improved by 5.0%, resulting in a reduction of the RMSE from 0.1201 to 0.114. This signifies a significant advancement in the ability to predict monthly rainfall, which in turn aids decision-makers in effectively managing water resources, planning for droughts or floods, optimizing crop yields, and safeguarding infrastructure. The study also conducted a comparison of different hyperparameter optimization methods for deep-learning models. The grid-search-based optimization technique displayed superior performance compared with previous methods, highlighting its potential for optimizing LSTM models specifically designed for rainfall prediction.
Furthermore, the LSTM model, trained and refined through this study, was able to generate rainfall projections up to the year 2082. Considering the implications of climate change and the potential for extreme rainfall events leading to flooding and other detrimental consequences, these long-term projections hold significant importance.
Overall, this study contributes to the improvement of rainfall prediction models and underscores the benefits of incorporating artificial intelligence and hyperparameter tuning in the realm of natural resource management. The insights provided in this research hold relevance for climate science, sustainable resource management, and various stakeholders, including decision-makers, planners, and researchers.
APPLICATION AREA
The advanced LSTM network architecture optimized through grid search, as proposed in this study, finds its primary application in enhancing the accuracy and efficiency of rainfall forecasting in Mecca. This improvement is pivotal for several critical areas:
- 1.
Water resource management: Given Mecca's arid climate, the enhanced forecast model can significantly aid in water conservation and allocation strategies, ensuring sustainable water supply for domestic, agricultural, and industrial uses.
- 2.
Agricultural planning: Accurate rainfall predictions are crucial for agriculture in Mecca. This model assists in crop planning, irrigation scheduling, and choosing crop varieties, thus potentially boosting agricultural productivity and food security.
- 3.
Infrastructure and urban planning: The ability to predict rainfall with greater accuracy supports infrastructure development and maintenance, particularly in designing robust drainage systems and structures resilient to weather extremes.
- 4.
Disaster preparedness and response: The model enhances the region's capability to prepare for and respond to weather-related disasters, such as flash floods, by providing more accurate and timely forecasts.
- 5.
Climate-change adaptation strategies: In the context of global climate change, this model serves as a tool for long-term planning and decision-making, helping the region adapt to shifting rainfall patterns and mitigate potential adverse impacts.
Overall, the application of this optimized LSTM model for rainfall prediction in Mecca represents a significant step forward in the region's ability to manage its natural resources effectively, plan sustainable development, and prepare for the impacts of climate change.
CONCLUSION
In conclusion, this study successfully demonstrates the effectiveness of applying a grid-search-based hyperparameter optimization technique for LSTM deep regression models in predicting monthly average rainfall in Mecca. The proposed model significantly improves the accuracy of rainfall forecasts, leading to more precise predictions that can support efficient water resource management, agricultural planning, infrastructure protection, and sustainable development in the region. The results also show that the grid search optimization technique surpasses other commonly used methods for hyperparameter optimization in deep-learning models. This research contributes to the development of accurate rainfall prediction models and provides valuable insights for decision-makers and stakeholders in the region. This paper uses advanced machine-learning techniques to enhance monthly average rainfall prediction in Mecca. The optimized LSTM model with automatic hyperparameter tuning is used to forecast future rainfall trends up to the year 2082, and additionally the possibility of an increase in extreme rainfall events, which may result in negative impacts such as flooding. The study demonstrates the model's capability to make accurate long-term predictions and identifies potential errors or biases in the model. The insights provided by this study have significant implications for climate science research and sustainable resource management and development in the region. Overall, this study contributes to ongoing efforts to improve rainfall prediction using artificial intelligence and automated hyperparameter optimization. The accuracy of the monthly average rainfall prediction may increase if sensor data are incorporated into the study. However, sensor data were not considered in this study. The accuracy of rainfall prediction can be improved using sensor and meteorological datasets with additional environmental features. Hence, in future work, big-data analysis can be used for rainfall prediction if sensor and meteorological datasets are used for daily rainfall amount prediction study.
In conclusion, we integrate a thorough analysis of key features from current research in rainfall forecasting. This examination, highlighting the latest advancements and methodologies, positions our optimized LSTM model within the evolving landscape of meteorological prediction. It underscores our contribution toward bridging existing gaps and advancing the field, setting the stage for the novelty and relevance of our study.
FURTHER RESEARCH
- I.
While the proposed model demonstrates promising results in predicting monthly average rainfall in Mecca, there are several areas for future research to further enhance its performance and broaden its applicability.
- II.
Incorporate additional weather features: Future research can explore the inclusion of other weather parameters, such as temperature, humidity, and wind speed, to improve the model's predictive capabilities and provide a more comprehensive understanding of the factors influencing rainfall patterns.
- III.
Experiment with other optimization techniques: This study focused on the grid search optimization technique for hyperparameter tuning. Future research can explore the use of other optimization methods, such as random search, Bayesian optimization, and genetic algorithms, to evaluate their performance in comparison with grid search and potentially further improve model accuracy.
- IV.
Test alternative machine learning models: While LSTM deep regression models show strong potential in rainfall prediction, future research can investigate the performance of alternative machine-learning models, such as convolutional neural networks (CNNs), gated recurrent units (GRUs), and ensemble methods, in predicting monthly average rainfall.
- V.
Investigate the impact of climate change: Climate change is expected to influence rainfall patterns, potentially altering the accuracy of prediction models over time. Future research can investigate the impact of climate change on rainfall patterns in Mecca and update the LSTM model accordingly to ensure its continued effectiveness in the face of changing conditions.
- VI.
Expand to other regions: The proposed model can be applied to other regions with similar climatic conditions to assess its generalizability and effectiveness in predicting rainfall patterns in different geographic contexts. This can provide valuable insights for water resource management and sustainable development efforts in other arid regions.
ACKNOWLEDGEMENTS
The author would like to thank the anonymous reviewers and editor for their instructive comments, which helped to improve this paper. In addition, the author wishes to thank Google Earth Pro for making available the satellite data. Finally, the author also wants to thank Google Earth Pro for providing the satellite data for the rainfall data in Mecca.
DATA AVAILABILITY STATEMENT
All relevant data are available from an online repository or repositories: https://github.com/Falqeer/Mecca_Rainfall-.
CONFLICT OF INTEREST
The author declares there is no conflict.