Saad
Saad
7–16)
Abstract
Climate change poses a severe threat to agricultural sustainability, particularly in water-scarce regions such
as Multan, Pakistan, which receives an annual average rainfall of only 186mm and experiences frequent
drought conditions (Pakistan Meteorological Department, 2022). The increasing depletion of groundwater
resources further exacerbates agricultural challenges in the region. It is a rising threat to agriculture, a
fundamental component of food security worldwide, and due to this, new ways of formulating crop estimate
models are needed. Most traditional approaches to forecasting ATTR might not accurately capture the
complex and non-linear or even non-additive mechanisms that connect climate parameters and crop yields.
In this work, we employ Long Short-Term Memory (LSTM networks) a state-of-art deep learning method to
forecast crop yields based on temperature, rainfall, and crop production data. As a result, the LSTM model
can process the sequential data and identify the temporal dependence pattern as the best model for this task.
The main input data included climate and yield data from a particular year in a specific region and some
preprocessing was done to handle missing values, scale inputs, and group rainfall data. The model had a
MAPE of 5.36%, an MAE of 1136.70, and an RMSE of 1136.70 giving the model a prediction accuracy of
94.64%. This work shows the efficiency of the proposed model and confirms that this approach is more
effective than traditional statistical methods. These predictions are highly accurate and provide valuable
information for different users including farmers, policy-makers, and researchers. This work elucidates how
LSTM-based models can help solve the future challenges of agricultural management and production. When
able to yield reliable predictions of the yields, such models can also help in proper resource planning,
managing the effects of climate change, and improving food security all over the world. As a result, it is
evident that machine learning critically occupies the subject area in constructing a long-lasting agricultural
future resistant to dramatic changes.
Keywords: Deep Learning; Long Short-Term Memory (LSTM); Crop Yield Prediction; Climate
Change; Food Security analysis
1. Introduction
Multan, a key agricultural hub in Pakistan, is crops, when to tend to those plants, and when to
categorized as a semi-arid region with limited water harvest them[4]. Thanks to modern agriculture,
availability for crop production. The city receives an technology has fitted the system of farming to be
average annual rainfall of 186mm, which is more productive. However, it is critical to
significantly lower than the minimum 500mm distinguish between the tremendous growth of
threshold required for sustainable rain-fed agricultural productivity and stability of harvests in
agriculture[1]. Additionally, erratic monsoon recent decades and the basic fragility of agricultural
patterns and prolonged dry spells have intensified production systems that hinges on the ability to
water stress, leading to declining groundwater levels adapt to environmental conditions[5], driven mainly
and increased reliance on irrigation. According to by weather factors and changes in climate and
the [2], Multan has experienced at least five drought season. These conditions have a great impact on the
years in the past two decades, further highlighting growth and yield of crops and their related farming
the vulnerability of its agricultural sector to climate criteria, which in turn have dynamic impacts on the
variability. Agriculture has proved to be central to farmer’s economy, global food supply, and the
the growth of human societies as a means of sustainability of the environment.
producing food[3], providing a medium for
The problem of forecasting regarding yields
exchange and, in fact, as the base upon which
for crops is further complicated when factors like
societies have depended for sustenance. Since the
temperature and rainfall are factored into the mix
beginning of agriculture, people have used natural
within the climate system[6]. Weather conditions
philosophies to dictate the climate and habits of the
are a critical consideration within agriculture since a
environment to know when and where to plant
7
Pak. J. Engg. Appl. Sci. Vol. 33, Special Issue July, 2025
little shift in environmental conditions can trigger a production.[5]. This model could assist farmers in
massive difference in yields[3]. For example, establishing a better way of predicting crop yields
unfavorable temperature levels may harm plants at for the next season in case of bad planting seasons,
certain development phases or irregular rainfall making good planning right from planting seasons,
would cause either drought, which is destructive to especially concerning the use of water and fertilizers
crop production. In addition, the time of occurrence during planting for increased crop yields[4], and
of rainfall and/or temperature changes is extremely also assist farmers’ crop selection as well as market
significant to crops[7]; for instance, drought at segmentation and strategies. Furthermore, such a
critical development phases such as flowering or model could be used for more precise yield
fruiting greatly reduces crop yield potential, while prediction, which would decrease food waste and
excess rainfall can either retard crop maturity or increase overall food security, making the
cause crop diseases. agricultural industry more sustainable[4].
The conventional yield prediction methods This research is a small step, but a noteworthy
that mainly use historical records may not give a one, in an attempt to reinvent the prediction of
proper on more intricate interactions between agriculture-related factors with machine learning
climate and crops. This is where modern systems[4]. The findings of this study also focus on
advancements in deep learning (DL) and artificial improving the predictions of crop yields to advance
intelligence (AI)[8] Help, and become useful. In the intelligent management of farming activities, as
recent years, deep learning techniques, especially they contribute to food security under climate
LSTM, have attracted a lot of attention in GWS due change[11]. In conclusion, this work aims to show
to massive data inputs and other hidden patterns that how incorporating such sophisticated machine
cannot be seen easily by even an analyst. Of these learning models like LSTMs with conventional
techniques, LSTM[9] Which is a specific type of techniques in agriculture can help improve the
RNN that has developed into a powerful tool for current agricultural system for the challenges of the
time series prediction. Problems where the sequence 21st century[10]. It is difficult to overemphasize the
of data points is critical include the use of LSTMs in importance of agriculture[12], as this sector has
weather prediction and in determining agricultural always been the foundation of human development,
yield[5]. meeting the most basic human needs, such as food,
materials for clothing, and job opportunities for
The notion of applying deep learning
billions of people globally[13]. It has always been
techniques, LSTMs in this case, to attempt to
the traditional way of producing food where farmers
forecast crop yields based on historical climate data
till the soil based on cycles, rainfall, and climatic
is unique and timely in light of climate change. And
conditions in a given region. Even with the
so, with global temperatures continuing to climb and
developments in technology and efficiency in
weather[9]. Becoming more unpredictable, it
planting and dealing with crops, climatic changes
remains a concern as to how farmers can continue
remain one of the biggest challenges for
relying only on traditional methods of forecasting.
farmers[14]. Since climate can significantly impact
AI and deep learning could play significant roles in
crop yields and production, fluctuations in
the betterment and improvement of agricultural
temperature, rainy season, or occurrence of natural
forecasting systems[10] and assist farmers in
disasters such as droughts, floods, and storms pose
overcoming these challenges since it would help
a significant risk towards food insecurity, financial
them make precise decisions regarding resources
loss, and social unrest[9].
and management in a way that enhances the
qualities of crops that would help them withstand Deep learning (DL) and artificial intelligence
the change in climate conditions[4]. This paper (AI) [8] In the recent past, they have been
investigates the ability of LSTM networks[9] in considered to be very promising technologies that
predicting crop production based on temperature, might be useful in altering how agricultural results
rainfall, and crop production data from past seasons. are predicted and handled among the many DL
Based on this data, we want to answer the question methodologies. Deep learning algorithms [15]
of whether an LSTM model[9] provides better and particularly the LSTM networks have been reported
more accurate predictions than basic forecasting, to offer remarkable performance in time series
which is valuable for farmers, decision-makers, and prediction. As opposed to non-recurrent machine
researchers. learning models, LSTM is designed to handle
sequential data in which the arrangement of the
The purpose of this research is to develop a
numbers matters. This makes them particularly
forecasting model that incorporates past
useful when the data we are trying to predict, in this
temperature and rainfall data over several years, as
case, weather patterns and crop yields, tend to have
well as crop production data, to predict future crop
8
Impact of climate change on crop yield in Water Scare region through deep learning
9
Pak. J. Engg. Appl. Sci. Vol. 33, Special Issue July, 2025
10
Impact of climate change on crop yield in Water Scare region through deep learning
Besides, production information in tons of with the crop yields. The monthly data was,
annual crop yield from the years 2008-09 to 2022- however, preserved as the need arose for finer
23 was collected. Wheat was selected as the focus analysis. Additionally, wheat is susceptible to
crop due to its economic importance and extensive climate variations, making it an ideal crop for
cultivation in Multan, where it covers a significant studying the impact of temperature and rainfall on
proportion of the total agricultural land. yield prediction. This dataset quantified the
agricultural yield of the region's main crops and was
Before feeding it to the training set and the
the forecast's dependent variable. The data were
test set, slight preprocessing was done to strip the
collected from the Bureau of Statistics of the Punjab
data clean of any inaccuracies. Most values in the
Government and other publicly available resources
rainfall data set were imputed to zero since gaps in
[16]. These records were preprocessed using Min-
the data would mess up the entire analysis. Data that
Max normalization before being input into the
was in alphabetical order, whereby others replaced
LSTM model. Data cleaning involved handling
some values due to non-completion of the
missing values, ensuring consistency, and
questionnaires, were normalized. The parameter of
structuring the data for time-series analysis. The
rainfall was in terms of monthly distribution, while
datasets were first cleaned and normalized as
the output was required to be in terms of annual
mentioned earlier, and then merged based on a
accumulation, thus, the monthly numbers were
common “Year” variable, and this merged dataset
rolled up into annual accumulation for comparison
comprised temperature, rainfall, and
11
Pak. J. Engg. Appl. Sci. Vol. 33, Special Issue July, 2025
Scaler to get the features in the range of 0-1. This The percentage of land cultivated out of total
step was crucial to render the model efficient and available land has declined progressively over time,
avoid distorting the values that have large numeric as suggested in below Fig. 8. The reason may be
differences, such as annual rainfall values, while urbanization, land degradation, or policy driven land
comparing with temperature values. Finally, the redistribution.
data was converted into the time series format
required by the LSTM model. This structuring 2.3 Model Architecture
entailed using data from the three prior years as The model architecture used in this study was
independent variables to forecast the yield of crops drawn from Long Short-Term Memory (LSTM)
in the subsequent year. For example, the data on networks, which are ideal for time series forecast.
temperature, rainfall, and crop yield collected LSTMs are a kind of recurrent neural network
between the years 2007 and 2009 were employed in (RNN) that has the capability of modeling and
the study to predict the crop yield in the year 2010. learning dependencies or correlation within
This approach allowed the model to capture sequential data hence can be used for making crop
temporal dependencies, which are important to yield prediction based on climatic and agricultural
understanding the functioning of agricultural history data. The first layer of the model was the
systems. Such a careful approach allowed for not LSTM layer with 50 units. This layer was intended
only data cleaning and normalization but also the to recognize multivariate temporal dependencies in
structuring of the data in a way that can take the input signals, with a certain emphasis placed on
advantage of the LSTM’s inherent strengths, thus the previous temperature and rainfall data. The
making it well suited for yield prediction problems. activation function used for this layer was ReLU
Although the data on soil moisture content is (Rectified Linear Unit) since it is very useful when
extremely essential for estimating a crop’s yield, the addressing problems such as the vanishing gradient,
available datasets for Multan did not include soil which is prominent in deep networks.
moisture data for an extended period. The attempts A dropout layer followed the first LSTM
to acquire remote sensing soil moisture data were layer with a rate set at 20% to minimize overfitting.
capped by poor temporal coverage and low spatial A Dropout technique is applied to randomly remove
resolution. Thus, this study was limited to the use of partially the neurons during the training stage to
temperature and rainfall as the main climate reduce over-dependency on the training data and to
indicators, which is why future work needs to focus generalize the model. The second LSTM layer also
on including trustworthy soil moisture datasets included 50 units and, similarly to the first LSTM
when they are made available. layer, the return sequences were set as False. This
configuration makes it possible for the second layer
to output a single real value, which is the final
predicted crop yield, not a sequence. This was done
because the goal of the model was to give a
prediction of the yield of the next year’s crop by
learning the patterns set by the input. Another
dropout layer was added after the second LSTM
layer to mitigate overfitting, set at a rate of 20%.
This layer made the learning process more
stochastic so that the model could generalize better
to unseen data.
Last, in which fully connected layer
consisting of one neuron is added to the model. This
layer was tasked with producing the values of the
various crop yield forecasts. Fully connected layers
are the layers where each neuron is connected to
each neuron of the preceding layer. In this case, it
returned the result of the model in the form of a
single value of crop yield for the given year. As for
the optimizer to fine-tune the model, the Adam
optimizer was chosen since it is among the most
efficient ones for training deep-learning models.
Fig. 7: LSTM Deep Learning Model Methodology The loss function selected for the model was MSE,
Diagram suitable for linear regression models and which
12
Impact of climate change on crop yield in Water Scare region through deep learning
Fig. 8: Percentage share of cultivated area over time, showing trends in land utilization
evaluates the mean of the squared differences of the the entire process of going through the training data
differences between the predicted and actual values. and modifying its weights 50 times.
For assessment, Mean Absolute Error (MAE) was
To, evaluate the model’s performance, two
employed, as it calculates the sum of the absolute
common metrics were used: Mean squared error
value of the differences in predicting and actual
(MSE) and mean absolute error (MAE). The
values divided by the sizes of the samples, which
performances of these metrics are based on the gap
gives a more descriptive measure of the
between the predicted and the actual crop yield
performance of the model. Using this architecture,
values to determine the accuracy of the model.
the required LSTM networks for time-series
prediction of crop yields were enhanced combined Mean Squared Error (MSE) is calculated using
with the dropout, which helps the model learn from the following formula:
the data sets and does not overfit the data the model 1
is trained on. 𝑀𝑆𝐸 = 𝑛 ∑𝑛𝑖=1(𝑦𝑖 − 𝑦̂𝑖 )2 (1)
13
Pak. J. Engg. Appl. Sci. Vol. 33, Special Issue July, 2025
Mean Absolute Error (MAE) is calculated using of accordance was witnessed between the actual
the following formula: yield and the one predicted in the model making the
1 𝑛 latter capable of capturing the temporal
𝑀𝐴𝐸 = 𝑛 ∑𝑖=1|𝑦𝑖 − 𝑦̂𝑖 | (2)
dependencies inherent and the nonlinear behavior
Where: present in this stochastic process. The efficiency of
the model is explained by its increased ability to
• n is the number of test samples
analyze sequential data and find hidden
• 𝑦𝑖 is the actual value of the 𝑖-th sample dependencies in temperature, rainfall, and yield
histories. However, it is also in these areas that the
• 𝑦̂𝑖 is the predicted value for the 𝑖-th sample
results also reveal lessons for improvement. One can
MAE offers a very clear interpretation of the only speculate that expanding the range of predictor
mean of the absolute difference between the actual variables by including soil fertility, irrigation, crop
and predicted values without making big errors variety, and improved accuracy of meteorological
larger than the case with MSE. data could improve the model. However, one can
utilize different advanced LSTM forms including
Throughout the model training process, both
Bidirectional LSTM or Attention-based LSTMs,
MSE and MAE were observed, thus at the end of the
and hybrid them with other pure machine learning
testing section for the model, we noted extremely
techniques like Gradient Boosting or Random
low figures for MSE and MAE. This indicates that
Forests to enhance the forecasting precision. In total,
both models were effective in estimating crop yield
the findings suggest that LSTM models can be
and that the estimated values are well approximated
effectively used for agricultural yield prediction in
by the actual crop yield in the test set.
practice. Modeling with larger, more complex
datasets requires integration with other large-scale
3. Results and Discussion datasets and more advanced statistical methods for
The performance of the LSTM model in further improvement of accuracy and reliability
terms of predicting crop yields was analyzed by across the range of agricultural situations. Although
comparing the predicted yield of the LSTM model soil moisture is essential for crop production, there
with the actual yield of crops obtained from the test is no reliable data available. This research showed
dataset. The model again also revealed fair that using temperature and rainfall alone in LSTM
prediction effectiveness; the prediction accuracy models produced 94.64% accurate yield predictions,
was 94.64%; the MAPE 5.36%; the MAE 1136.70; indicating that the two factors encompass a
and the RMSE 1136.70. Furthermore, a high level significant amount of climate impacts on yield.
Results shown in below Fig. 10.
14
Impact of climate change on crop yield in Water Scare region through deep learning
Fig. 10: LSTM Model Prediction Output Actual vs Predicted Crop Yield
Yet, the accurate soil moisture data that was risk management, and food security planning.
recorded could improve the prediction accuracy and However, this study also indicates places that
help better allocate water resources in future studies. research should continue, to improve the general
The graph in Fig. 11 demonstrates how the area efficiency and effectiveness of supply chains. The
sown shows its pattern together with the production various factors that might be useful in the model
index using 2012-13 as the base year. Index values include soil characteristics, irrigation technique, the
display variations between both parameters which kind of crops, and detailed weather conditions
show times of enhanced efficiency together with amongst others. Other steps can also look for more
instances of lowered agricultural output although different predictions via new architectures of
land usage remains steady. LSTM, for example, switching which could be
evaluated in one scheme to accomplish different
4. Conclusion forecasts or using various levels of LSTM.
Moreover, testing the presented model in other areas
This study successfully establishes the and under different crop conditions would
feasibility of using Long Short-Term Memory contribute to its applicability. The presented
(LSTM) models for yield forecasting based on approach can be considered a major step towards the
temperature, rainfall, and production history. utilization of machine learning for sustainable
According to the analysis, the model’s variable has agriculture. When used to predict accurate yield
high yields, a best fit of 94.64%, a MAPE of 5.36%, expectations, LSTM models can reduce the impacts
and low error metrics to yield forecasting. The paper of climate fluctuations and inform antimodel
suggests that LSTM-based models are useful tools agricultural management, as well as assist in global
for getting insights into busted trends in agriculture endeavors to improve food stability following the
to form data-driven decisions for resource allotment, negative repercussions of climate volatility.
Fig. 11: Trend analysis of area sown and production index (Base Year: 2012-13)
6. References
5. Acknowledgment
[1] World Bank Group & Asian Development
I gratefully acknowledge the Food and
Bank. (2021). Climate Risk Country Profile:
Agriculture Organization (FAO) for their generous
Pakistan. World Bank.
financial support, which made this research/project
[Link]
possible. Their contribution played a vital role in
facilitating the successful completion of this work
15
Pak. J. Engg. Appl. Sci. Vol. 33, Special Issue July, 2025
[2] Pakistan Meteorological Department. (2022). [10] Bian, C., Shi, H., Wu, S., Zhang, K., Wei, M.,
Pakistan_Climate_2022 (p. 16) [Climate]. Zhao, Y., Sun, Y., Zhuang, H., Zhang, X., &
[Link] Chen, S. (2022). Prediction of Field-Scale
[Link] Wheat Yield Using Machine Learning
Method and Multi-Spectral UAV Data.
[3] Iqbal, N., Shahzad, M. U., Sherif, E.-S. M.,
Remote Sensing, 14(6), 1474.
Tariq, M. U., Rashid, J., Le, T.-V., & Ghani,
[Link]
A. (2024). Analysis of Wheat-Yield
Prediction Using Machine Learning Models [11] Han, J., Zhang, Z., Cao, J., Luo, Y., Zhang,
under Climate Change Scenarios. L., Li, Z., & Zhang, J. (2020). Prediction of
Sustainability, 16(16), 6976. Winter Wheat Yield Based on Multi-Source
[Link] Data and Machine Learning in China. Remote
Sensing, 12(2), 236.
[4] Van Klompenburg, T., Kassahun, A., &
[Link]
Catal, C. (2020). Crop yield prediction using
machine learning: A systematic literature [12] Deb Burman, P. K., & Das, P. (2024). A
review. Computers and Electronics in Data‐Driven Approach to Assess the Impact
Agriculture, 177, 105709. of Climate Change on a Tropical Mangrove
[Link] in India. Journal of Geophysical Research:
09 Biogeosciences, 129(8), e2023JG007911.
[Link]
[5] Mousavi, S. R., Jahandideh Mahjenabadi, V.
A., Khoshru, B., & Rezaei, M. (2024). Spatial [13] Revenga, J. C., Trepekli, K., Jensen, R.,
prediction of winter wheat yield gap: Agro- Rummel, P. S., & Friborg, T. (2024).
climatic model and machine learning Independent estimates of net carbon uptake in
approaches. Frontiers in Plant Science, 14, croplands: UAV-LiDAR and machine
1309171. learning vs. eddy covariance. Agricultural
[Link] and Forest Meteorology, 355, 110106.
[Link]
[6] Khan, F., Liou, Y.-A., Spöck, G., Wang, X.,
106
& Ali, S. (2024). Assessing the impacts of
temperature extremes on agriculture yield [14] Ashfaq, M., Khan, I., Alzahrani, A., Tariq, M.
and projecting future extremes using machine U., Khan, H., & Ghani, A. (2024). Accurate
learning and deep learning approaches with Wheat Yield Prediction Using Machine
CMIP6 data. International Journal of Learning and Climate-NDVI Data Fusion.
Applied Earth Observation and IEEE Access, 12, 40947–40961.
Geoinformation, 132, 104071. [Link]
[Link] 735
[7] Harsányi, E., Mirzaei, M., Arshad, S., [15] Shook, J., Gangopadhyay, T., Wu, L.,
Alsilibe, F., Vad, A., Nagy, A., Ratonyi, T., Ganapathysubramanian, B., Sarkar, S., &
Gorji, M., Al-Dalahme, M., & Mohammed, Singh, A. K. (2021). Crop yield prediction
S. (2024). Assessment of Advanced Machine integrating genotype and weather variables
and Deep Learning Approaches for using deep learning. PLOS ONE, 16(6),
Predicting CO2 Emissions from Agricultural e0252402.
Lands: Insights Across Diverse Agroclimatic [Link]
Zones. Earth Systems and Environment. 2
[Link]
[16] Punjab Bureau of Statistics. (n.d.). Punjab
[8] Wang, J., Si, H., Gao, Z., & Shi, L. (2022). Bureau of Statistics [Climate and Crop Yield
Winter Wheat Yield Prediction Using an Data]. Punjab Bureau of Statistics
LSTM Model from MODIS LAI Products.
Agriculture, 12(10), 1707.
[Link]
[9] Bhimavarapu, U., Battineni, G., &
Chintalapudi, N. (2023). Improved
Optimization Algorithm in LSTM to Predict
Crop Yield. Computers, 12(1), 10.
[Link]
16