Acadlore Transactions on Geosciences https://www.acadlore.com/journals/ATG Forecasting Rainfall in Selected Cities of Southwest Nigeria: A Comparative Study of Random Forest and Long Short-Term Memory Models Timothy Kayode Samson , Francis Olatunbosun Aweda * 1 Statistics Programme, College of Agriculture, Engineering and Science, Bowen University, 232101 Iwo, Nigeria 2 Physics Programme, College of Agriculture, Engineering and Science, Bowen University, 232101 Iwo, Nigeria * Correspondence: Olatunbosun Aweda (aweda.francis@bowen.edu.ng) Received: 05-05-2024 Revised: 06-10-2024 Accepted: 06-19-2024 Citation: T. K. Samson and F. O. Aweda, “Forecasting rainfall in selected cities of Southwest Nigeria: A comparative study of random forest and long short-term memory models,” Acadlore Trans. Geosci., vol. 3, no. 2, pp. 79–88, 2024. https://doi.org/10.56578/atg030202. 2024 by the author(s). Published by Acadlore Publishing Services Limited, Hong Kong. This article is available for free download and can be reused and cited, provided that the original published version is credited, under the CC BY 4.0 license. Abstract: Rainfall is crucial for agricultural practices, and climate change has significantly altered rainfall patterns. Understanding the dynamic nature of rainfall in the context of climate change through Machine Learning (ML) and Deep Learning (DL) algorithms is essential for ensuring food security. ML techniques provide tools for processing large-scale data to extract meaningful insights. This study aims to compare the performance of a ML algorithm, Random Forest (RF), with a DL algorithm, Long Short-Term Memory (LSTM), in predicting rainfall in six state capitals in Southwest Nigeria: Osogbo, Ikeja, Ibadan, Akure, Ado-Ekiti, and Abeokuta. The dataset for this study was sourced from the HelioClim website archive, which offers high-quality solar radiation and meteorological data derived from satellite measurements. This archive is known for its accuracy and reliability, providing extensive and consistent historical datasets for various applications. The monthly rainfall data spanning from January 1, 1980, to December 31, 2022, were used, with 80% allocated for training and 20% for validation. As the data are time series, each model was constructed using a look-back period of five months, meaning the past five months’ rainfall data served as input features. The performance of these algorithms was evaluated using Mean Square Error (MSE), Root Mean Square Error (RMSE), and Mean Absolute Error (MAE). The results indicated that the RF algorithm yielded the lowest MSE, RMSE, and MAE across all selected cities in Southwest Nigeria. This study demonstrated the superiority of RF regression over LSTM in predicting rainfall in these regions, providing a valuable tool for agricultural planning and climate adaptation strategies. Keywords: Machine learning; Deep learning; Random forest; Long short-term memory; Meteorological parameters 1 Introduction Meteorologically, rainfall has been shown to contribute significantly to the lives of humans and animals on the earth’s surface. As a result, this remains one of the key parameters in atmospheric science, which deals with the pattern and movement of the planet and agricultural development around the world. According to the study by Le et al. [1], heavy rainfall contributes significantly to flooding in any area, causing infrastructure damage, road network collapse, and disruption of some socioeconomic activities. Furthermore, it is well known that floods and other extreme events are major consequences of climate change, and they are expected to occur more frequently in high-rainfall areas, potentially causing catastrophic consequences in any developed area [2]. According to the study by Czarnecka et al. [3], weather conditions have the potential to increase air pollution, which has been identified as a major concern. However, research has shown that rainfall mitigation improves the approach of invitation and possible forecasting by increasing human mobility [4–6]. It also helps to produce agricultural and industrial products for any community’s use and development [7–12]. Research on temperature and rainfall variability is critical for Nigeria due to its unique climatological and geographical features, such as its diverse climate zones ranging from arid in the north to humid in the south [4]. This variability has a significant impact on agriculture, a key economic sector, as well as food security [5]. Nigeria’s rapidly growing population and reliance on rain-fed agriculture make it especially vulnerable to climate change. Understanding these variations aids in the development of adaptive strategies to reduce negative impacts on crop yields, water resources, and overall https://doi.org/10.56578/atg030202 79