1. Introduction
Climate change has become the most popular topic of recent times. Temperature rise, sea level rise, excessive melting of glaciers, the acidification of the oceans, loss of biodiversity, the degradation of forests, drought, and extreme weather events are all affected. Different methods have been developed to examine this problem, which is also the subject of research in many sciences. Artificial intelligence methods that have entered our lives make our lives much easier by serving many disciplines. Artificial neural networks and machine learning methods are used in many fields. These methods are especially successful in the prediction of hydrological and meteorological variables. In addition, the fact that meteorological forecasts are close to reality is the basis of ecological and hydrological research [
1]. Temperature, a meteorological variable, has also increased globally compared to the past. Rapid melting of glaciers not only changes the salt concentration of water but also threatens the diversity of life that lives there. Melting also raises the water level in the seas and oceans, posing a serious threat to people living in coastal areas. Each country, region, and basin is affected differently. Drought and desertification will be inevitable if the human-induced temperature increase is not intervened with and adequate measures are not taken. Human beings, who have intervened in nature both gradually and rapidly, have caused our world to warm rapidly by replacing forested areas with concrete settlements and increasing carbon dioxide emissions. Gasses such as CO
2, CFC, O
3, N
2O, CH
4, N
2O, and CH
4, which accumulate in the atmospheric layer, keep our world at a certain temperature. While CO
2, one of these gasses, was 280 ppm (parts per million) before industry, this value approached 417 ppm in 2021 [
2]. In addition, the excessive increase in these gasses due to industry and other factors has made the temperature increase in the earth unavoidable. The industrial revolution, which started in the 1760s, spread to almost all countries in the 1800s and 1900s and significantly increased global warming. Temperature forecasts play an important role in many sectors, especially in agriculture, transportation, energy, and air transportation. There is also a relationship between the temperature parameter and precipitation, humidity, and many meteorological variables. Temperature is the determining factor affecting the productivity of a region in terms of agriculture [
3]. In fact, temperature is a parameter that directly or indirectly affects almost every living thing and sector. In particular, it has a great impact on human life. As a matter of fact, people may face health problems in an inappropriate air temperature [
4]. On the other hand, real forecasts of air temperatures are crucial for energy policy, human activities, and business development planning [
5]. In addition, the results obtained close to reality are very important for the cultivation of plants. Since each plant has a certain growing range at a certain temperature, temperature forecasting in agricultural areas is important for crop cultivation and yield. Although instant weather forecasts are easy, it is very difficult to make long-term forecasts. Therefore, modeling should be performed with minimum error while forecasting. The success of the model is very important here. The best model should be preferred for the best result. Unfortunately, warming continues gradually. The most important step here is to minimize warming. Numerous studies on this subject are published every year. Although each prediction method can calculate differently from each other, the chaotic structure of natural events makes the results very difficult to use. Predicting random events in nature is very difficult with physics-based deterministic methods. This is because the internal limitations of these methods prevent the model from being successful. Therefore, black-box methods are used to predict uncertain events.
In the literature, the use of artificial neural networks and machine learning methods for temperature predictions is becoming widespread, but studies comparing different methods are limited. Most studies focus on a specific region or time period, creating a need to present a general methodology and demonstrate its applicability to different regions. In particular, comprehensive temperature prediction studies that include meteorological variables such as humidity, wind, and precipitation for Istanbul are lacking in the literature. This study compares the temperature prediction performance of artificial neural networks (ANNs) and different machine learning models (linear model, support vector machine, K-nearest neighbor, random forest) using monthly meteorological data for the province of Istanbul between 1950 and 2023. The generalization ability of the models is evaluated with the k-fold cross-validation technique, and a comparative performance analysis of different algorithms is presented for the literature. The study aims to fill the gap in the literature by aiming to increase the accuracy of predictions made with meteorological data in a period when the effects of climate change are increasing. This study provides a comprehensive overview of the literature by comparing the performance of both ANN and different machine learning methods on the same dataset and provides a reliable methodology that can be used in regional climate analyses.
The primary objective of this study is to develop a highly accurate model for temperature forecasting in Istanbul by leveraging artificial neural networks (ANNs) and a variety of machine learning models. This study stands out for its focus on integrating diverse meteorological variables—namely, humidity, wind, and precipitation—into temperature prediction models, which not only enhances the precision of regional analyses but also captures the intricate interdependencies among these factors. At a time when the impacts of climate change and rising global temperatures are becoming increasingly pronounced, this work provides a timely and significant contribution by addressing the challenges associated with accurate long-term meteorological forecasting.
What sets this study apart is its comprehensive comparative evaluation of multiple machine learning techniques alongside ANN, providing a robust assessment of their relative strengths and weaknesses in climate modeling. By utilizing an extensive dataset spanning several decades and employing advanced validation techniques, the study achieves reliable and generalizable insights. Furthermore, its novel methodological framework demonstrates the practical applicability of artificial intelligence in climate science, serving as a foundational reference for future research in similar contexts. Ultimately, this research not only enriches the growing body of knowledge on AI-driven climate forecasting but also underscores the critical role of innovative data-driven approaches in mitigating the adverse effects of climate variability.
2. Literature Review
ANN forecasting models can be used in many studies such as temperature forecasts, daily precipitation forecasts, wind speed forecasts, rainfall–runoff modeling, evaporation forecasts, erroneous time series forecasting, and river flow forecasts. In the literature review, estimation studies similar to our study are examined and given below.
Ashibek et al. (2012) revealed that it is possible to test the usability of a feedforward backpropagation neural network (FFNN) to predict from Canada’s daily maximum weather analyses between 1999 and 2009. According to the study, they stated that the ANN with the tan-sigmoid transfer function is quite successful in predicting the weather [
6]. Almazroui et al. (2013) examined the impact of altitude, population, and marine temperature on the air temperature trend using data from 24 cities in Saudi Arabia. They observed that the national temperature trend was 0.60 or 0.51 °C/decade. Additionally, they found no significant correlation between the increase in temperature and both population growth and altitude variation [
7]. Bendre et al. (2017) analyzed the minimum and maximum temperature, precipitation, and humidity of the Maharashtra city at a 95% confidence interval. They stated that iterative linear regression and iterative polynomial regression were used in the prediction, and iterative polynomial regression gave more successful results than the other regression [
8]. Musashi et al. (2018) analyzed spatial data of temperature in the Malang region using natural neighborhood interpolation and inverse distance-weighted interpolation methods. According to the statistical analyses made between the two methods, they stated that the inverse distance-weighted interpolation method gave more successful results [
9]. Ayeong et al. (2018) analyzed precipitation and instantaneous temperature data measured on 23 September, 24 December, 31 March, and 21 June in South Korea using IDW, Kriging, and Co-Kriging methods. Accordingly, they found that the IDW method was more successful in predicting precipitation and Kriging methods were more successful in predicting temperature data [
10]. Li et al. (2019) made a half-hour temperature forecast using the LSTM method. In addition to the study, they compared the LSTM method with random forest (RF) and deep neural network (DNN) methods [
11]. Using the Genetic Algorithm (GA) method, Tran et al. (2020) optimized the hyperparameters of multilayer LSTM, RNN, and ANN models. Hybrid models were used to predict the maximum air temperature at the Cheongju station in South Korea. Accordingly, they stated that the performance of GA-LSTM is higher than other models in predicting air temperature in the long term [
12]. Paul and Roy (2020) compared polynomial regression, linear regression, and support vector regression to determine the temperature of Bangladesh in 100 years and stated that the most appropriate model for the study was the third-degree polynomial regression [
13]. Fang et al. (2021) also used the LSTM method for multi-regional temperature forecasting. In the study, where different input variables were used, multiple-step forward forecasting was aimed for and they stated that the LSTM model gave successful results in short-term forecasts [
14]. Şevgin and Ali (2024) calculated the monthly average temperature values and temperature increase rates of 28 provinces in the east, west, north, and south of Turkey between 1950 and 2022 and made a comparison between the provinces. Using SSA and LSPF methods in their study, the authors calculated Erzincan as the province with the highest rate of a temperature increase and analyzed Antakya as the province with the lowest rate [
15].
Price et al. introduced a new machine learning-based weather forecasting model called GenCast in their study. As a model trained from atmospheric data, GenCast provides 15-day global weather forecasts faster and with higher accuracy, and they stated that it predicts extreme weather events and wind energy production better than traditional methods [
16]. Wang et al. used a data-driven approach for the combustion optimization of coal-fired boilers under variable load conditions. The developed CS-CNN-based prediction model considered multiple objectives such as boiler efficiency, NOx emission, and wall temperature, while the decision-making agent created with the TD3 algorithm optimized the boiler performance using this model. The simulation results provided a 0.411% increase in thermal efficiency, a 17.701 mg/m
3 decrease in NOx emissions, and the maintenance of safe wall temperature [
17]. In their work, Yuan et al. developed a transformer-based model, TianXing, which is augmented with physical orientation, and presented an effective and efficient approach to global weather forecasting. TianXing consumes less GPU resources compared to previous models, makes only a small compromise in accuracy, and increases the forecasting ability thanks to the mechanisms developed with physical insights. The model surpasses the performance of previous data-driven models and operational systems in the fields such as Z500 and T850, and is especially notable for its success in forecasting extreme weather events [
18]. Zhong et al. focused on the difficulties in predicting subseasonal variations in East Asian winter temperatures and developed the Subseasonal Predictability Mode Analysis (S-PMA) method, which combines an S-EOF analysis with the PMA approach. In the study, three basic modes representing East Asian winter temperatures were identified and significant forecasting success was achieved by constructing physically based empirical forecast models for these modes. This method offers the potential to increase seasonal forecasting skills in East Asia as well as the entire Asian continent [
19]. In their study, Bochenek et al. examined 500 scientific articles on machine learning methods published since 2018 and analyzed research trends in the fields of climate and numerical weather prediction. As a result of the research, the most studied meteorological fields, methods, and countries were determined; it was predicted that machine learning will play an important role in weather prediction in the future [
20]. Rakhee et al. developed a Genetic Algorithm-Optimized Artificial Neural Network (GA-ANN) model for the seasonal prediction of air temperature, which is an important factor in agriculture. In the analysis of weekly weather data from Hyderabad and New Delhi, the GA-ANN model achieved higher accuracy rates (R
2 = 0.937, 0.910) compared to MLR and classical ANN approaches. The study shows that the GA-ANN model is a reliable and effective method for seasonal temperature prediction [
21]. In their study, Pala et al. compared various R-based time series models for the prediction of long-term meteorological variables (e.g., atmospheric pressure, wind speed, and surface evaporation) in sensitive regions of Turkey, such as the Van Lake Basin. The results revealed that the AUTO.ARIMA model performed better than other models, contributing to the development of more reliable long-term forecasts that can be used in regional resource management and climate-related decision-making processes [
22]. In their study, Pala et al. proposed a new multi-hybrid model method that combines statistical and deep learning models for the more accurate prediction of natural gas consumption. In the analysis performed on the US natural gas vehicle fuel (NG-VFC) and industrial consumption (NG-IC) datasets, the best MAPE values were obtained as 5.40% and 3.19%, respectively. The study reveals that the proposed multi-hybrid model outperforms most of the existing methods with high prediction accuracy [
23]. This study differs and presents innovations in several important aspects from other studies in the literature. First, it provides a comprehensive evaluation in terms of methodology by comparatively examining both artificial neural networks (ANNs) and other machine learning methods (linear model, support vector machines, K-nearest neighbor, random forest) in temperature prediction for the Istanbul province. While most studies focus on only one method or region, this research adopts a broader approach to evaluate the performance of different models and analyze their effectiveness in Istanbul’s climate data.
In addition, the inclusion of meteorological variables such as humidity, wind, and precipitation in temperature prediction stands out as an innovation that increases the accuracy of the models. By examining the effect of these factors in detail, the general generalization capabilities of the models are strengthened. The study not only aims to provide high accuracy in temperature prediction, but also serves as a guide that highlights the potential applications of such artificial intelligence and machine learning techniques in areas such as climate change, energy planning, and agriculture.
4. Findings
4.1. Prediction with ANN
In this study, a feedforward artificial neural network (ANN) is used to predict temperature based on humidity, wind speed, and precipitation inputs. In the ANN model, a network with 20 hidden layers was selected. The data were normalized with the map minmax function and scaled to the range 0, 1. The artificial neural network was created with a feedforward net and the Levenberg–Marquardt algorithm (trainlm) was used for training. During the training of the model, the training process was optimized by adjusting parameters such as the number of epochs, learning rate, and target error. These parameters are as follows: number of epochs—1000, learning rate—0.001, and target error—1 × 10
−6. After training, the actual and predicted temperature values were visualized and the accuracy was evaluated by a regression analysis.
Figure 5 shows the regression plot.
In the ANN regression graph, the relationship between the target and predicted values of the neural network was calculated as R
2 = 0.9625 and the model predicted the target values with high accuracy. The predictions were concentrated around the ideal Y = T line, exhibiting a low error rate and strong generalization ability. However, some points deviate from the line, indicating that the model has some partial difficulties in adapting to certain outliers. Nevertheless, the close-to-96% linear relationship between predicted and target values proves that the model accurately captures the general trend of the data during the training process and achieves high performance without overlearning. These results show that the model has a successful prediction capacity and can be further optimized with minor improvements. The ANN training performance result graph is given in
Figure 6.
In the ANN training performance graph, the performance of the neural network on the training, validation, and test datasets is evaluated through the mean squared error (MSE). While the error value is high in the first epoch, it decreases rapidly in the following epochs and reaches a stable level at approximately the sixth epoch. The model weights were saved at the point where the validation error was the lowest, thus optimizing the generalization success. The fact that the training, validation, and test error values are close to each other shows that the model does not overlearn (overfitting) and successfully reaches the target error level. These results show that the model undergoes a fast and effective learning process and its generalization ability is satisfactory. The temperature prediction result graph of ANN training is given in
Figure 7.
The graph evaluates the performance of the model by comparing the neural network’s temperature predictions (predicted values) and actual values (actual values). The predictions are generally in fairly close agreement with the actual values, indicating that the model accurately captures the underlying trends and has a strong generalization capability. However, at some data points, the forecasts diverge from the true values, suggesting that the model may be in error in certain instances. Despite the intense fluctuations in the data, the general parallelism between predictions and actual values proves that the model offers a successful prediction performance.
Table 1 shows the actual and predicted temperature values based on humidity, wind, and precipitation values.
As can be seen in the table, the temperature estimate was provided with a high estimate rate. It was seen that the model gave extremely successful results.
4.2. Prediction with Machine Learning Models
In the second stage of the analysis, machine learning models such as the linear model (LM), support vector machine (SVM), K-nearest neighbor (KNN), and random forest (RF) were used in the R-Studio environment. Before moving on to the estimation processes, the effect of each input variable on the output was investigated in order to understand how the relationship between the input variables and the output of the models is. This situation is given in
Figure 8.
Humidity and temperature relationship: The graph of humidity shows the effect of the humidity variable on temperature. The negative relationship between temperature and humidity is clearly seen in the graph. In other words, as humidity increases, temperature decreases. The distribution points confirm this general trend and mostly follow a linear trend.
Wind and temperature relationship: In the graph of wind examining the relationship between wind speed and temperature, a negative trend is again striking. In other words, as wind speed increases, temperature decreases. Although the distribution points appear to be spread over a wider area, this inverse relationship is generally observed.
Rainfall and temperature relationship: The graph of temperature examines the relationship between rainfall amount and temperature. Here, again, a negative correlation is seen; as rainfall increases, temperature decreases. The distribution points exhibit a non-linear, more complex structure.
When using machine learning models, the cross-validation technique was used to make the dataset prediction results more accurate and realistic. For the data number of approximately 650, k-fold values were taken as 130, 65, 50, 25, 10, and 5, respectively. According to the data in
Table 2, four different machine learning models (LM, SVM, KNN, and RF) were used to evaluate the prediction performance for different k-fold values; MAE, RMSE, and R-squared values were examined as evaluation metrics.
Effect of k-fold number: As the number of k-folds increases (e.g., 130 k-folds), the models exhibit higher accuracy (lower MAE and RMSE, higher R-squared). This shows that the training and test data are better generalized with more folds. As the number of k-folds decreases (e.g., 5 k-folds), the prediction performance is observed to decrease. This is because with fewer k-folds, the model overfits the training data and its overall performance decreases.
LM exhibits poor performance at simple and low k-fold values. However, for LM, a very good R-squared (0.998) and low MAE/RMSE value were obtained at high k-fold values (130 k-folds). SVM generally shows a fairly stable and good performance at low and medium k-fold values. Especially, MAE and RMSE values are lower than LM. The performance of KNN varies depending on the number of k-folds. While it gives quite good results at high k-fold numbers, its performance decreases slightly at low k-fold numbers.
The RF model is generally the model that exhibits the most balanced performance. It achieved quite high accuracy at high k-fold numbers (R-squared: 0.997) and showed good results even at low k-fold numbers. R-squared values generally increase as k-fold increases. This shows that the models explain the data better. RF models and LMs provide the highest R-squared values. At low k-fold values, SVM and RF provided a more stable R-squared performance compared to other models.
The RF model has the lowest values for MAE and RMSE. This means that the relevant model makes the least errors in temperature predictions. The LM and SVM models have slightly higher errors at low k-fold values. KNN generally showed better performance at lower k-fold values, but it is not as effective as RF. In general, the RF model will be the best choice in cases where high accuracy is required (e.g., critical forecasting applications). For a faster and simpler solution, LM or SVM with high k-fold can also be preferred. The RF model has shown superior performance compared to other models with both low error (MAE/RMSE) and high explanatory power (R-squared). However, the performance of the models is quite sensitive to the number of k-folds. While generalization success increases with more k-folds, the generalization ability of the models decreases at low k-fold values. In addition, the graphs obtained depending on the metric values to show the effect of the k-fold parameter are given in
Figure 9.
Figure 9 shows that as the number of k-folds increases (for example, 130 k-folds), there are improvements in the performance metrics of the models (decrease in MAE and RMSE, increase in R-squared). Especially in the RF models and LMs, quite good results were obtained at high k-fold values (130 and 65). RF and KNN models show more stable performance when the k-fold length changes. As the k-fold length increases, the generalization success of the models also increases. This indicates that the model can make better generalization instead of overfitting the data. The MAE and RMSE values of the RF model remain at lower levels compared to the other models at each k-fold value. In general, the graph in
Figure 9 shows that the RF model is the most successful model in temperature prediction. This model offers both low error rates (MAE and RMSE) and high explanatory power (R-squared). However, the performance of the models is quite sensitive to the k-fold length used. Higher k-fold values allow models to perform better.
5. Conclusions
This study introduces a novel framework for temperature prediction in Istanbul by utilizing artificial neural networks (ANNs) alongside various machine learning models, including linear models, support vector machines, K-nearest neighbors, and random forests. Differently from usual research, this paper combines meteorological data (1950–2023) and several important factors, including humidity, wind, and precipitation, to make the prediction accuracy and regional characteristics more effective.
The ANN model achieved outstanding prediction accuracies, around 96%, indicating its capability in modeling heterogeneous nonlinearity in meteorological information. Nonetheless, the application of ANN models must also take into account that they can have several, for instance, computational requirements and the risk of overfitting unless appropriate regularization is adopted. Moreover, the “black-box” property of ANN increases the difficulty of interpreting its predictions over certain other model types.
In machine learning approaches, the random forest model outperformed the others in terms of good prediction accuracy and stability and with smaller computational requirements. The k-fold cross-validation method integration also confirmed the reliability of all models and generalized them across datasets.
By a systematic comparison between these approaches and tailoring them to the particular nature of the Istanbul climate, this paper sets a new benchmark for subsequent regional temperature forecasting research. Results also show the applicability of these approaches to play an important role in critical issues such as mitigating climate change, energy planning, and crop optimization. Future studies can continue the development of these models by gathering more of the public data and, specifically, addressing some issues that these models are facing as well as exploring new hybrid approaches. Although this study has shown the usability of ANN and RF models for temperature predictions in Istanbul, it was concluded that this methodology could also be applied to other regional climate analyses. Future studies can focus on optimizing the model’s hyperparameters and further increasing the prediction accuracy by using different input variables. In addition, comparing deep learning models with different network structures and algorithms is among the potential research areas. Such studies will contribute to our better understanding of the effects of climate change and taking effective measures.