# Greenhouse Temperature Prediction Based on Time-Series Features and LightGBM
## 4 Experiment
### Feature Engineering  
In studying the regularity of time-series data with a change in indoor temperature, the autocorrelation analysis of the indoor temperature was carried out adopting the autocorrelation analysis method [26; 27]. The autocorrelation coefficient, which is between 0 and 1, was used as the quantitative indicator of correlation. A larger value indicates higher correlation. Suppose that there is a sequence \(X:x_{1},x_{2},x_{3},...,x_{n}\). Let \(X_{s,t}\) be the sequence \(x_{s},x_{s+1},...,x_{t-1},x_{t}\) starting at time \(s\) and ending at time \(t\). \(u_{s,t}\) is the mean value of the sequence \(X_{s,t}\) and \(\sigma_{s,t}\) is the standard deviation of the sequence \(X_{s,t}\). The first-order autocorrelation coefficient is then:  
\[R(1)=\frac{E(X_{2,n}-u_{s,n})*(X_{1,n-1}-u_{1,n-1})}{\sigma_{2,n}*\sigma_{1,n-1 }}. \tag{13}\]  
Similarly, the \(k\)-order autocorrelation coefficient is:  
\[R(k)=\frac{E(X_{k+1,n}-u_{k+1,n})*(X_{1,n-k}-u_{1,n-k})}{\sigma_{k+1,n}*\sigma_ {1,n-k}}. \tag{14}\]  
Adopting Formula (14), the high-order autocorrelation coefficient of the indoor temperature was calculated, and the change in correlation with order is shown in Figure 2.  
Figure 2 shows that the correlation gradually decreased with an increase in order, and the coefficient of the time-series correlation of temperature exceeded 0.6 when the order was less than 10 and exceeded 0.8 when the order was particularly low. It is therefore considered that the indoor temperature has a strong time-series correlation within the reasonable order range. In characterizing the regularity of environmental factors changing with time, the difference in each feature is regarded as a series feature. The collection interval of every two groups of data was 1 min in the training set and 30 min in the test set, and it is thus necessary to set the training set interval to 30 when generating the difference feature (i.e.,  
Figure 2: Variation in the autocorrelation coefficient of the indoor temperature with order. generating the difference from the data 30 min ago) and to set it to 1 in the test set (i.e., generating a difference from the previous group of data). Based on Figure 2, to ensure that the data have high autocorrelation, only the first-order difference features were used in this paper [28]. [PERSON] proposed that temperature and time have an exponential relation when environmental factors change [29]. There are static characteristics, such as temperature, air pressure, and humidity, in the dataset that are representative of the moment in time. In generating dynamic characteristics, we let \(t\) be the current time. \(t-2\), \(t-1\), and \(t+1\) then denote the two-previous times, previous time, and next time, respectively. We need to use data of the current time (i.e., the data information at time \(t\)) and previous times to predict the greenhouse temperature at time \(t+1\). The time interval of each collection in the test set was 30 min, and the time interval between \(t\) and \(t+1\) was therefore also 30 min. The indoor temperature change trend in the collected training set is shown in Figure 3. The value on the horizontal axis is the number of hours after 1:00 on 14 March 2019. We concluded from the change in the temperature autocorrelation with order in Figure 2 that temperature has a high time-series correlation within a certain order range. We then used the original features given in Table 1 to extract the differential features of each influence factor as part of the time-series features [30; 31]. As examples, the feature Temperature(outdoor)_diff describes the difference in outdoor temperature from \(t-1\) to \(t\), the feature Humidity(outdoor)_diff describes the difference in outdoor humidity from \(t-1\) to \(t\), and the feature Pressure(indoor)_diff describes the difference in indoor air pressure from \(t-1\) to \(t\).