Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 6, No. 3, 2023 54 Research on Temperature Prediction Based on LSTM Tianci Liu1, Xiangjun Li2, * 1 Computer Science College of Yangtze University, Jingzhou, 434023, Hubei, China 2 Jingzhou Vocational College of Technology Institute of Software Engineering, Jingzhou, 434023, Hubei, China * Corresponding author: Xiangjun Li (Email: 1007472895@qq.com) Abstract: Temperature change has an important influence on human health and the development of all walks of life, so accurate temperature forecast is becoming more and more important. With the dramatic increase in the scale and dimension of meteorological data, it poses a new challenge to temperature prediction. In the era of big data, traditional time series forecasting methods have been difficult to deal with massive meteorological data. Temperature data is a kind of time series data with obvious non-stationary fluctuation characteristics. Modeling the temperature data can analyze the temperature change. Aiming at the problem that the prediction accuracy of time series model is not high, this paper proposes to build a temperature prediction model based on long-term and short-term memory network LSTM deep learning network, and divide the training set prediction set with Jena climate data set to evaluate the accuracy of the model. The experimental results show that the long-term memory network LSTM deep learning network performs well in the temperature prediction model. Keywords: LSTM, Temperature prediction. 1. Introduction For a long time, temperature changes have an important influence on human daily life and the development of all walks of life. On the one hand, the change of temperature will affect people's daily life. People can know the future weather in advance through weather forecast, and plan clothes, travel and other activities. On the other hand, the change of temperature also affects the development of agricultural production, social industry, manufacturing and other industries. Therefore, the prediction of temperature change has always been a research hotspot in the field of meteorology, but accurately predicting the future temperature change has always been a major difficulty in the field of meteorological science research. The temperature change is a very complicated process. The temperature change at the same time is influenced by various factors, such as humidity, time, maximum wind speed, maximum temperature, air pressure and time attributes. Only by fully considering various influencing factors can the temperature be predicted more accurately, and then the temperature prediction effect can be achieved. Scholars at home and abroad have done a lot of research on temperature prediction, including: research on temperature prediction model based on support vector machine in Dehai South [1], temperature prediction based on decision tree combined classifier[2], and temperature prediction model based on RBF neural network in adjacent space[3]. The time series dependence in temperature prediction is ignored in the above methods. Long-term and short-term memory network LSTM is a kind of time recursive neural network, which can better fit the nonlinear relationship, and can not only solve the problem that only fixed-length data series can be used for prediction in feedforward networks, but also solve the problem that recursive networks are difficult to train. 2. Related Technologies 2.1. LSTM Algorithm Long Short-Term Memory[4]is a special Recurrent Neural Network, RNN) with good long-time learning ability. The basic structure consists of three gating units, including forgetting gate, input gate, output gate and a cell state. The main function of forgetting gate is to decide which information needs to be forgotten from the cell state. The input of forgetting gate includes the hidden state of the previous time step and the input data of the current time step. The main function of the input gate is to decide which information needs to be updated to the cell state. The input of the input gate also includes the hidden state of the previous time step and the input data of the current time step. The main function of the output gate is to decide which information needs to be output from the cell state to the hidden state of the next time step. The input of the output gate also includes the hidden state of the previous time step and the input data of the current time step. Through the interaction of these three gating units, LSTM can learn the long-term dependencies in the sequence and keep or forget the information when necessary, which makes LSTM show better performance in processing long sequence data. The neuron structure of LSTM neural network is shown in Figure 1: Figure 1. The Neuron Structure of LSTM Neural Network 55 3. Exploratory Data Analysis The data set used is Jena meteorological data set[5], and Jena Climate Dataset is a weather time series data set recorded at the meteorological station of Max Planck Institute of Biogeochemistry in Jena, Germany. Show all the data, including 420551 pieces of data and 14 different feature quantities [6]: Because the statistics are recorded every ten minutes, there are 144 data points every day. The following figure shows the temperature changes in the first 15 days of the data set. As can be seen from the figure, the temperature changes show a certain periodicity: Figure 1. Temperature in the first 15 days of the data set 4. Result Analysis 4.1. Evaluation indicators Root Mean Square Error (RMSE), The value of RMSE is the arithmetic square root of the ratio of the sum of the squares of the deviation between the predicted value and the true value obtained after model training to the number of verification n, which is often used as an evaluation index for deep learning models, as shown in the following formula: 𝑅𝑀𝑆𝐸 ∑ 𝑆 𝑖 𝑆 𝑖 (1) Among them: 𝑆 𝑖 is the true value of the data, and 𝑆 𝑖 is the predicted value of the current data. 4.2. Analysis of experimental results The LSTM temperature prediction model built in this paper consists of an input layer, an LSTM layer, and an output layer. In this paper, 100 days of data are used as the training set for training, and a total of 1440 data of the next 10 days are used as the test set. In the process of training the model, in order to speed up the learning rate and convergence rate of the LSTM deep learning model, this paper adds the Adam algorithm for optimization. Too few training times are not enough to extract all the features, and too many times may cause overfitting. After many experiments, the epoch was finally determined to be 10. The performance metrics of the model are as follows: Figure 3. The performance of the model on the first 1000 test sets Table 1. The indicators of the model Evaluation Index LSTM RMSE 0.803 MAE 0.545 R2 0.970 5. Summary In this paper, LSTM is used to build a temperature prediction model, and the temperature in the next 10 days is predicted through 100 days of data, and the Adam algorithm is added for optimization to effectively improve the performance indicators of the prediction model. From the analysis of the experimental results, the results of the temperature prediction model based on LSTM have high prediction accuracy. The research in this paper shows that LSTM has better performance in dealing with long-term series temperature prediction and other temperature prediction. References [1] Zhu Jingjing, Zhao Xiaoping, Wu Sheng An, et al. Research on temperature prediction model in Hainan based on support vector machine [J]. Journal of Hainan University (Natural Science Edition), 2016,34(01):40-44. [2] Li Junlei, Teng Shaohua, Andy. Temperature prediction based on decision tree combination classifier [J]. Journal of Guangdong University of Technology, 2014,31(04):54-59. [3] Zhang Cheng, Qu Weidong. Prediction Model of Near Space Temperature Based on RBF Neural Network [J]. Control Engineering, 2008(S1):106-108+112. [4] Tian Yibo. Exploration on assimilation analysis of single- station multi-channel observation data based on LSTM [D]. Institute of Disaster Prevention and Technology, 2023. [5] The Weather Station of the Max Planck Institute for Biogeochemistry https://www.bgc-jena.mpg.de/wetter/ [6] Jena Climate Dataset https://www.kaggle.com/datasets/mnassrib/jena-climate