## 2 Materials and Methods
### RF-TPE-LSTM Prediction Model Construction  
To accurately predict the \(\text{CO}_{2}\) concentration in classrooms, we introduce the RF algorithm described above to determine the importance of each factor and select the influencing factors as model inputs. Additionally, using the TPE algorithm to optimize the selection of hyperparameters for the LSTM model, we propose the RF-TPE-LSTM model for predicting \(\text{CO}_{2}\) concentrations in classrooms. For time series prediction tasks, such as predicting environmental parameters, most current studies employ LSTM neural networks to construct prediction models. These networks have an internal processing unit that is capable of efficiently updating and storing both backward and forward dependencies, making them suitable for accurately modeling time series data with short-term and long-term dependencies. LSTM neural networks employ three types of \"gates\" to control the flow of information: the forget gate, input gate, and output gate. The core structure of the LSTM neural network is depicted in Figure 6.  
Figure 5: RF principle process. The forget gate decides which information is from the previous moment's memory cell state \(C_{t-1}\) and whether it should be retained as part of the current memory cell state \(C_{t}\). The input gate determines which new information from the current moment can be incorporated into the current memory cell state \(C_{t}\), and the output gate determines which information in the current memory cell state \(C_{t}\) at the current moment should be saved to the current hidden layer state, \(h_{t}\), and subsequently output. The calculation process for these three gates is defined in Equations (3)-(8). \[f_{t}=\sigma\Big{(}W_{f}\cdot[h_{t-1},x_{t}]+b_{f}\Big{)} \tag{3}\]  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{4}\]  
\[o_{t}=\sigma(W_{o}\cdot[h_{t-1},x_{t}]+b_{o}) \tag{5}\]  
\[\widetilde{C}_{t}=tanh(W_{c}\cdot[h_{t-1},x_{t}]+b_{c}) \tag{6}\]  
\[C_{t}=f_{t}\cdot C_{t-1}+i_{t}\cdot\widetilde{C}_{t} \tag{7}\]  
\[h_{t}=o_{t}\cdot tanh(C_{t}) \tag{8}\]  
where \(f_{t}\) is the forget gate, \(i_{t}\) is the input gate, \(o_{t}\) is the output gate, \(\widetilde{C}_{t}\) represents the temporary state entered at time \(t\), \(h_{t-1}\) is the output of the model at moment \(t-1\), \(x_{t}\) is the input of the model at moment \(t\), \(W\) represents the weight, \(b\) represents the bias term, \(\sigma\) denotes the sigmoid activation function, and \(tanh\) denotes the tanh activation function. The LSTM model parameters used in this study are listed in Table 2. However, the hyperparameters of the neural network have an impact on both the training speed and accuracy of the model; therefore, the hyperparameters must be adjusted to optimize the prediction accuracy of the neural network. The TPE algorithm first employs a stochastic process to generate the hyperparameters. Then, the sampled hyperparameters are utilized to evaluate the target function, resulting in a learning sample, which is denoted as \(\text{S}(x,y)\). In this context, \(x\) represents the configuration of the hyperparameters, and \(y\) denotes the optimal value achieved by applying the hyperparameter configuration \(x\) to the target function. Subsequently, the acquisition function is updated based on the learning sample \(\text{S}(x,y)\), and the next set of hyperparameter configurations \(\lambda_{N}\) is selected. This process continues until a certain number of randomly selected samples are obtained. The TPE method uses existing sample data to construct a nonparametric probability density function and samples it in the hyperparameter space to generate new learning samples. This cycle repeats until a hyperparameter configuration that yields a superior objective function value is found and recorded in each trial.