Indoor environment data prediction method and system based on LSTM-iTransform
Through the LSTM-iTransformer model, combined with multi-head differential attention and thermal response modulation, the lag problem of smart home devices in indoor environmental data prediction is solved, high-precision temperature and humidity prediction is achieved, and the accuracy of environmental regulation and the control effect of smart home devices are improved.
Patent Information
- Application Number
- CN202511172576.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-08-21
AI Technical Summary
Existing smart home devices have a lag in indoor environment data prediction and are unable to respond to environmental changes in a timely manner. Traditional methods and deep learning models find it difficult to capture complex spatiotemporal patterns and long-distance dependencies, which affects the environmental comfort adjustment effect.
An indoor environment data prediction method based on LSTM-iTransformer is adopted. By integrating LSTM, improved iTransformer and multi-head differential attention layer, combining position encoding and multi-layer perceptron, a high-precision long time series prediction model is constructed to capture the complex characteristics and dependencies of indoor environment data.
It achieves high-precision, long-term prediction of indoor temperature and humidity, enhances the model's ability to identify key time series patterns and physical rationality, and improves the control effect of smart home devices.
Smart Images

Figure CN120744481A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of indoor environment data prediction, and in particular to an indoor environment data prediction method and system based on LSTM-iTransformer. Background Art
[0002] In smart home scenarios, the indoor environment plays a crucial role, directly impacting occupant comfort. A favorable indoor environment provides a comfortable living space, while unfavorable conditions can diminish the living experience. Therefore, maintaining appropriate indoor environmental parameters and adjusting these factors in real time through smart home systems are key to enhancing occupant comfort. With the widespread adoption of IoT technology, smart home scenarios can collect environmental data through various environmental sensors, making indoor environmental data prediction research more feasible. Predicting the smart home environment can improve the smart home control system's ability to respond to environmental changes, thereby enhancing occupant comfort.
[0003] However, most current smart home devices rely on real-time or short-term historical data for adjustments. This approach is subject to lags and cannot respond promptly to environmental changes, thus impacting comfort. Predicting indoor environmental data presents numerous challenges, as the indoor environment is influenced by multiple factors and the patterns of environmental parameters vary in complex ways. Traditional prediction methods are limited when processing indoor environmental data and struggle to capture complex spatiotemporal patterns and long-range dependencies. Although deep learning models such as LSTM can process time series data, they often encounter vanishing or exploding gradients when predicting long sequences, limiting model performance and the ability to predict long-term trends, thus impacting the effectiveness of smart home device control.
[0004] The current key issue is how to overcome the limitations of traditional methods and existing deep learning models, build a model that can effectively capture the complex characteristics and dependencies of indoor environmental data, and accurately predict environmental data, thereby providing reliable data support for functional parameter recommendations of smart home devices. Summary of the Invention
[0005] In order to solve the above problems, the present invention proposes an indoor environment data prediction method and system based on LSTM-iTransformer. By integrating LSTM, improved iTransformer and thermal response modulation with multi-head differential attention, high-precision and long-term time series prediction of indoor temperature and humidity is achieved.
[0006] The specific plan is as follows:
[0007] On the one hand, the indoor environment data prediction method based on LSTM-iTransformer includes:
[0008] S1, integrates the temperature data and humidity data monitored by indoor sensors and the outdoor weather information provided by the meteorological station to obtain integrated environmental information;
[0009] S2, inputs the integrated environmental information into the LSTM module to extract temporal features;
[0010] S3, inputting the temporal features into an improved iTransformer module including a multi-head differential attention layer, a position encoding layer, and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence, performs position encoding on the enhanced representation of the input sequence, and obtains a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation;
[0011] S4, inputs the vector result containing the global deep feature representation into the time series prediction model including the encoder layer, average pooling layer, multi-layer perceptron and fully connected layer to predict the indoor temperature and relative humidity; among them, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local temporal features of the input sequence to obtain a feature representation with local pattern perception ability; the average pooling layer downsamples the feature representation with local pattern perception ability to obtain reduced dimensionality features; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality features to obtain abstract semantic features; the fully connected layer receives the abstract semantic features and predicts the indoor temperature and relative humidity.
[0012] Furthermore, the LSTM module includes two layers of LSTM neural networks connected in sequence; the number of neurons in the first layer of LSTM neural network is set to twice the feature dimension of the input environmental information, which is used to expand the expressive power of the input features; the number of neurons in the second layer of LSTM neural network is the same as the feature dimension output by the first layer of LSTM neural network, which is used to refine the expanded features.
[0013] Furthermore, in S2, the two-layer LSTM neural network includes a forget gate, which determines whether to retain or discard the information in the LSTM memory unit. The calculation formula is as follows:
[0014] ;
[0015] in, Represents the Sigmoid function, which is used to map the input to between 0 and 1; Represents the weight matrix of the forget gate; Indicates concatenating the previous hidden state with the current input; represents the bias term; Represents the output of the forget gate at time t.
[0016] Furthermore, in S3, the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence, specifically including:
[0017] The input time series features are respectively combined with the parameter matrix 、 and After linear transformation, project it onto the query vector , key vector Sum vector The calculation formula is as follows:
[0018] ;
[0019] ;
[0020] ;
[0021] in, Represents the temporal characteristics of the input; The query vector representing the first group; The key vector representing the first group; The query vector representing the second group; a key vector representing the second group; 、 and represents the parameter matrix, , is the number of heads;
[0022] The attention scores are calculated for the two sets of query vectors and key vectors. For the first set, and Perform the dot product operation and then divide by Zoom in, After function processing, we get the first set of attention scores and the second set of attention scores , where the calculation formula for the first set of attention scores is as follows:
[0023] ;
[0024] The final attention score is obtained by subtracting the two sets of attention scores and adding them to the value vector Multiply them together and the calculation formula is as follows:
[0025] ;
[0026] ;
[0027] in, Represents a learnable differential weight coefficient used to control the degree of differentiation; represents the final attention score of the traditional differential attention layer; 、 、 and represents a learnable vector; For initialization constant;
[0028] An enhanced representation of the input sequence is obtained based on the final attention score.
[0029] Furthermore, a thermal response modulation function is embedded in the multi-head differential attention layer , the calculation formula is as follows:
[0030] ;
[0031] ;
[0032] in, represents element-wise multiplication; , Indicates the difference between indoor air temperature and wall surface temperature. is the wall surface temperature, Indicates the indoor temperature; is the wall thermal response time constant; is the characteristic parameter of thermal conductive material.
[0033] Furthermore, in S3, the enhanced representation of the input sequence is positionally encoded, and the calculation formula is as follows:
[0034] ;
[0035] ;
[0036] in, Indicates location; Represents dimension; Represents the dimension of the input features; Represents the value of the even dimension of the encoding vector corresponding to the position pos; Supplement the odd-numbered dimensions of the encoding vector corresponding to position pos.
[0037] Furthermore, in S4, the calculation formula for predicting indoor temperature and relative humidity is as follows:
[0038] ;
[0039] ;
[0040] in, n represents the time step of future prediction; and Represents the fully connected layers for temperature prediction and humidity prediction respectively; Represents the multilayer perceptron operation; Represents the average pooling layer operation; Represents a one-dimensional convolutional layer operation; represents the output of the improved iTransformer module; The predicted time is time; Indicates The temperature forecast value at the moment.
[0041] On the other hand, the indoor environment data prediction system based on LSTM-iTransformer includes:
[0042] Integration module, used to integrate the temperature and humidity data monitored by indoor sensors with the outdoor weather information provided by the meteorological station to obtain integrated environmental information;
[0043] The time series feature acquisition module is used to input the integrated environmental information into the LSTM module to extract time series features;
[0044] A global deep feature representation acquisition module is used to input the temporal features into an improved iTransformer module including a multi-head differential attention layer, a position encoding layer, and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence, performs position encoding on the enhanced representation of the input sequence, and obtains a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation;
[0045] The prediction module is used to input the vector results containing the global deep feature representation into the time series prediction model including the encoder layer, the average pooling layer, the multi-layer perceptron and the fully connected layer to predict the indoor temperature and relative humidity; wherein, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local time series features of the input sequence to obtain a feature representation with local pattern perception ability; the average pooling layer downsamples the feature representation with local pattern perception ability to obtain reduced dimensionality features; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality features to obtain abstract semantic features; the fully connected layer receives the abstract semantic features and predicts the indoor temperature and relative humidity.
[0046] The present invention adopts the above technical solution and has the following beneficial effects:
[0047] (1) This paper uses a multi-head differential attention mechanism to calculate the difference between the two groups of attention scores and introduces a learnable differential weight coefficient λ, which enhances the model's ability to discern key temporal patterns;
[0048] (2) This invention incorporates the thermal inertia of walls, a key factor in the building thermal environment, into the deep learning model by embedding a thermal response modulation function based on physical mechanisms. This enables the model to better simulate the heat storage and release process of the building envelope in temperature prediction, thereby enhancing the physical rationality and accuracy of the prediction.
[0049] (3) The present invention adopts a hybrid architecture that combines LSTM with improved iTransformer. LSTM is used to effectively capture long-term temporal dependencies, while iTransformer is used to enhance the global context modeling capability, thus achieving multi-level, high-precision modeling and prediction of dynamic changes in complex nonlinear indoor environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 This is a flowchart of a method for predicting indoor environmental data based on LSTM-iTransformer according to an embodiment of the present invention;
[0051] Figure 2 This is a diagram showing the overall architecture of the environmental data prediction model based on LSTM-iTransformer in an embodiment of the present invention;
[0052] Figure 3 This is a diagram of the architecture of the multi-head differential attention mechanism according to an embodiment of the present invention;
[0053] Figure 4 This is a diagram of the indoor environment data prediction system based on LSTM-iTransformer in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The present invention will be described in further detail below with reference to the embodiments and drawings, but the embodiments of the present invention are not limited thereto.
[0055] like Figure 1 As shown, the indoor environment data prediction method based on LSTM-iTransformer of the present invention includes:
[0056] S1, integrates the temperature data and humidity data monitored by indoor sensors and the outdoor weather information provided by the meteorological station to obtain integrated environmental information.
[0057] Specifically, the core of constructing the training set in this embodiment lies in the systematic collection of real-world building operation and environmental time-series data. This focus on the correlation between the dynamics of the building's thermal environment and the operating status of equipment aims to provide a sufficient basis for localized indoor environment prediction models. Indoor data is collected through a high-precision sensor network deployed in key rooms. Core indicators include temperature and humidity, with an acquisition frequency set to every 5 minutes to accurately capture transient changes in the indoor microenvironment. Outdoor meteorological data simultaneously captures key indicators such as outdoor temperature, wind speed, and solar radiation intensity, also maintaining a collection frequency of every 5 minutes. The data must come from highly reliable local meteorological observation stations or rigorously calibrated self-built meteorological stations. By integrating these multi-source time-series data and performing rigorous preprocessing (including handling missing values, outliers, and standardization), a high-quality, spatiotemporally aligned dataset required for model training is ultimately constructed.
[0058] The model input data comes from multi-source data collected and integrated in the early stage, including environmental data of temperature and humidity monitored by indoor sensors and the switch status of indoor heaters, as well as outdoor weather information provided by the meteorological station. These data are arranged in chronological order to form a data set with time series characteristics. Before entering the model, the data needs to be preprocessed, including missing value and outlier processing, as well as standardization operations to ensure data quality and consistency. The processed data is input into the LSTM module in units of time steps. Assume that the time step is set to , each input data contains the past The indoor and outdoor environment data of time steps can be expressed as , the format is as follows:
[0059] ;
[0060] in, Indicates the indoor temperature. Indicates the outdoor temperature, Indicates indoor humidity, H indicates the switch status of the indoor heater, represents the radiation intensity, Indicates outdoor wind direction. represents outdoor wind speed. Each row represents various environmental data for a time step. Time step 0 represents the current observation, while the subscript -T+1 represents the data from the T-1th time step forward. Arranging data in chronological order from the past time step to the current time step clearly demonstrates how indoor and outdoor environmental data change over time, facilitating the model's learning and analysis of time series features.
[0061] S2, inputs the integrated environmental information into the LSTM module to extract the temporal features in the integrated environmental information.
[0062] Specifically, the LSTM module includes two layers of LSTM neural networks connected in sequence; the number of neurons in the first layer is set to twice the dimension of the input features to expand the expressive power of the input features; the number of neurons in the second layer is the same as the dimension of the input features to refine the expanded features.
[0063] Specifically, the time step of the LSTM module is set to 72, and environmental data is collected every 5 minutes to capture the temporal variation pattern within 6 consecutive hours.
[0064] Specifically, the LSTM module also includes a forget gate, which determines whether to retain or discard the information in the LSTM memory unit. The calculation formula is as follows:
[0065] ;
[0066] in, Represents the Sigmoid function, which is used to map the input to between 0 and 1; Represents the weight matrix of the forget gate; Indicates concatenating the previous hidden state with the current input; represents the bias term; Represents the output of the forget gate at time t.
[0067] Specifically, the fused data is input into a two-layer LSTM to extract short-term and long-term temporal dependencies and generate an enhanced temporal feature sequence.
[0068] In terms of model architecture design, considering that the indoor environmental data of ordinary households changes relatively slowly, in order to balance the model complexity and feature capture capability and avoid overfitting, this study sets the LSTM module to a two-layer structure. The number of neurons in the first layer of LSTM is set to twice the feature dimension of the input data, that is, This design aims to perform preliminary feature expansion on the input data, fully tap the potential feature information, and provide a richer data foundation for subsequent feature extraction. The number of neurons in the second layer of LSTM is the same as the input feature dimension. Its main function is to filter and refine the features output by the first layer, remove redundant information, and extract more representative time series features, so that the features output by the model can accurately reflect the essential characteristics of the indoor environment data.
[0069] Specifically, the input gate Control the extent to which new information enters the cell state and generates candidate cell states The calculation formula is as follows:
[0070] ;
[0071] ;
[0072] in, 、 is the weight matrix, 、 is the bias term, The function is used to generate new candidate cell states. The input gate controls the proportion of new information entering the cell state through the Sigmoid function, and uses The function generates candidate cell states and provides new information for updating the cell state; cell state The update formula is as follows:
[0073] ;
[0074] in, This represents element-by-element multiplication, and through the forget gate and input gate, it selectively retains and adds information to the cell state. This update mechanism allows the cell state to retain important historical information while promptly incorporating new information, effectively solving the problem of traditional recurrent neural networks in dealing with long-term dependencies.
[0075] Output Gate The output of the hidden state is determined based on the cell state and the current input. The calculation formula is as follows:
[0076] ;
[0077] ;
[0078] in, is the weight matrix of the output gate, is the bias term, and finally the hidden state of the current time step is obtained The output gate controls the output ratio of information in the cell state through the Sigmoid function, combined with the function The cell state is processed to generate the hidden state of the current time step, which contains rich temporal feature information.
[0079] Input Data Entering the LSTM module, LSTM uses a gating mechanism to process the data. After two layers of LSTM processing, the output contains a hidden state with rich local temporal feature information. The first layer of LSTM expands the input data feature dimension by 2 times to mine potential features; the second layer of LSTM refines the features and removes redundant information to obtain the output , providing high-quality input for subsequent improved iTransformer modules.
[0080] Through feature extraction using the LSTM module, the temporal features in indoor environmental data are fully mined and extracted. The hidden state output by the model contains rich local feature information, providing high-quality input for the subsequently improved iTransformer module. This effectively explores the temporal variations of indoor environmental data and lays a solid foundation for indoor environmental data prediction.
[0081] like Figure 2 The figure shows how the model in this embodiment combines LSTM, self-attention, and CNN to process sequence data. After the input sequence passes through the LSTM layer to extract long-term dependency features, the self-attention mechanism focuses on key information. The CNN layer then further extracts local spatial features, and finally, the fully connected layer outputs the classification or prediction results. These components work together to improve model performance.
[0082] S3, input the temporal features into the improved iTransformer module including a multi-head differential attention layer, a position encoding layer and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein, the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence, performs position encoding on the enhanced representation of the input sequence, and obtains a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation.
[0083] Specifically, the multi-head differential attention layer obtains an enhanced representation of the input sequence by calculating the difference between the attention scores of the input temporal features, including:
[0084] The input time series features are respectively combined with the parameter matrix 、 and After linear transformation, project it onto the query vector , key vector Sum vector The calculation formula is as follows:
[0085] ;
[0086] ;
[0087] ;
[0088] in, Represents the temporal characteristics of the input; The query vector representing the first group; The key vector representing the first group; The query vector representing the second group; a key vector representing the second group; 、 and represents the parameter matrix, , is the number of heads;
[0089] The attention scores are calculated for the two sets of query vectors and key vectors. For the first set, and Perform the dot product operation and then divide by Zoom in, After function processing, we get the first set of attention scores and the second set of attention scores , where the calculation formula for the first set of attention scores is as follows:
[0090] ;
[0091] The final attention score is obtained by subtracting the two sets of attention scores and adding them to the value vector Multiply them together and the calculation formula is as follows:
[0092] ;
[0093] ;
[0094] ;
[0095] in, Represents a learnable differential weight coefficient used to control the degree of differentiation; represents the final attention score of the traditional differential attention layer; 、 、 and represents a learnable vector; For initialization constant;
[0096] An enhanced representation of the input sequence is obtained based on the final attention score.
[0097] Specifically, the present invention proposes to embed a thermal response modulation function in the differential attention layer , Indicates the difference between indoor air temperature and wall surface temperature. The final attention score of the improved differential attention layer. hour, , amplify the attention of temperature-related features, when hour, , maintaining the original attention mechanism.
[0098] Specifically, the enhanced representation of the input sequence is positionally encoded, and the calculation formula is as follows:
[0099] ;
[0100] ;
[0101] in, Indicates location; Represents dimension; Represents the dimension of the input features; Represents the value of the even dimension of the encoding vector corresponding to the position pos; Supplement the odd-numbered dimensions of the encoding vector corresponding to position pos.
[0102] Specifically, the thermal response modulation function is embedded in the multi-head differential attention layer , the calculation formula is as follows:
[0103] ;
[0104] ;
[0105] in, represents element-wise multiplication; , Indicates the difference between indoor air temperature and wall surface temperature. is the wall surface temperature, Indicates the indoor temperature; is the wall thermal response time constant; is the characteristic parameter of thermal conductive material.
[0106] like Figure 3The figure shows a simplified process of a multi-head attention mechanism. The input first passes through multiple linear transformation layers to generate query matrices Q1 and Q2, key matrices K1 and K2, and value matrix V. Then, two attention scores are calculated: softmax(Q1K1T) and softmax(Q2K2T). These scores are multiplied by the value matrix V to obtain weighted feature representations. These results are calculated independently in different "heads", combined through concatenation, and group normalization (GroupNorm). Finally, the final result is output through linear transformation. This process effectively captures the complex dependencies in the input data.
[0107] Specifically, the traditional differential attention mechanism has core defects. It does not consider the indoor thermodynamic characteristics, cannot distinguish the heat conduction delay effect of different building structures, and is insensitive to changes in boundary conditions such as door and window switches. To solve the above problems, it is proposed to embed a thermal response modulation function in the differential attention layer. , real-time collection of wall surface temperature through infrared sensors , call material parameters based on building GIS database and .when hour, , amplify the attention of temperature-related features, when hour, , maintaining the original attention mechanism. This paper introduces a thermodynamic response control function into the differential attention mechanism for the first time. This model models the impact of heat diffusion on attention allocation through temperature differences and heat conduction time constants, addressing the traditional model's inadequate response to physical environmental changes. A nonlinear thermal response function (tanh smoothing control) avoids discrete jumps and incorporates the material physical property β and response time constant τ. This approach is particularly suitable for modeling the thermal stability of building interiors, such as predicting dynamic scenarios like window opening, air cooling, and thermal radiation intervention.
[0108] S4, inputs the vector result containing the global deep feature representation into the time series prediction model including the encoder layer, average pooling layer, multi-layer perceptron and fully connected layer to predict the indoor temperature and relative humidity; among them, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local temporal features of the input sequence to obtain a feature representation with local pattern perception ability; the average pooling layer downsamples the feature representation with local pattern perception ability to obtain reduced dimensionality features; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality features to obtain abstract semantic features; the fully connected layer receives the abstract semantic features and predicts the indoor temperature and relative humidity.
[0109] Specifically, the calculation formula for predicting indoor temperature and relative humidity is as follows:
[0110] ;
[0111] ;
[0112] in, n represents the time step of future prediction; and Represents the fully connected layers for temperature prediction and humidity prediction respectively; Represents the multilayer perceptron operation; Represents the average pooling layer operation; Represents a one-dimensional convolutional layer operation; represents the output of the improved iTransformer module; The predicted time is time; Indicates The predicted temperature value at the moment of the test. This LSTM-iTransformer model uses the LSTM module to capture temporal features, while the iTransformer module mines global features, achieving accurate multi-step predictions of indoor temperature and humidity. Taking into account the model structure, sampling frequency, and the changing characteristics of indoor environmental data, this study set the prediction range to no more than 72 time steps (i.e., 6 hours) in the future.
[0113] Specifically, the LSTM-iTransformer model used in this example was implemented in the Python programming language, and datasets were processed using toolkits such as Pandas, Numpy, Scipy, and Sklearn. The deep learning framework used was PyTorch, running on a Windows 10 operating system equipped with an Intel i5-13600KF processor, 32GB of RAM, and an NVIDIA GeForce RTX 2080 Ti graphics card. The software environment used was Python 3.8.16, PyTorch version 1.13.0, and CUDA 11.7 support. The dataset used in this study, FlexHouse, originated from an experimental study at the Technical University of Denmark. The study focused on the thermodynamic characteristics of buildings and aimed to provide empirical data support for building energy performance analysis and optimization control strategies. The dataset covers building operational data and environmental parameters from February 21, 2019, to March 13, 2019. Indoor data, including temperature and humidity in each room, was collected every five minutes using high-precision sensors to capture dynamic changes in the indoor environment. Outdoor weather information includes key indicators such as outdoor temperature, wind speed, and radiation intensity. It is also collected every 5 minutes and obtained from authoritative meteorological data sources.
[0114] The environmental variables used in model training include indoor temperature (T_in, 9.41~25.22℃, mean 18.42℃), outdoor temperature (T_out, -0.30~4.36℃, mean 1.64℃), indoor humidity (Rh, 23.85%~36.42%, mean 30.60%), heater status (H, 0 / 1, mean 0.55), radiation intensity (G, -0.004~0.248 kW / m², mean 0.001), outdoor wind direction (Wd, 65.73°~357.55°, mean 186.72°) and wind speed (Ws, 0.60~6.81 m / s, mean 3.68 m / s).
[0115] The model uses mean squared error (MSE = (1 / n)∑(y_i - ŷ_i)²) as the loss function and the Adam optimizer (with an initial learning rate of 0.001). This is combined with a learning rate decay strategy (multiplying by 0.9 every 10 epochs) and an early stopping mechanism (stopping training if the validation loss does not decrease after five consecutive epochs). The maximum number of training epochs is 100. The model architecture combines LSTM with an improved iTransformer module, generating predictions through forward propagation and updating parameters through backpropagation, effectively improving convergence and preventing overfitting.
[0116] To verify the performance of the model in smart home environment prediction, it was compared with classic models such as ARIMA, SVR, LSTM, and Transformer. In the comparative experiment, the ARIMA model had an MSE of 0.1995 and an R² of -0.068 for temperature prediction, and an MSE of 0.1148 and an R² of -0.214 for humidity prediction, which were the worst performance and even worse than the simple mean prediction. The SVR model achieved certain results through parameter optimization, with an MSE of 0.0596 and an R² of 0.929 for temperature, and an MSE of 0.0258 and an R² of 0.942 for humidity. The accuracy was acceptable but there were still significant errors. The standard LSTM model had an MSE of 0.0521 and an R² of 0.807 for temperature, but performed poorly in humidity prediction (MSE of 0.8036 and R² of 0.522), indicating its limited ability to model multiple variables. The Transformer model had an MSE of 0.0172 and an R² of 0.887 for temperature, which was better than traditional methods, but performed poorly in humidity prediction. There are still large deviations in temperature prediction (MSE is 0.0319, R² is 0.546); in terms of temperature prediction, the LSTM-iTransformer proposed in this paper has a mean square error (MSE) as low as 0.0095, a mean absolute error (MAE) of 0.0698, and a coefficient of determination (R²) as high as 0.9992; in terms of humidity prediction, the MSE is 0.0077, the MAE is 0.0539, and the R² reaches 0.9995; therefore, the LSTM-iTransformer method proposed in this paper shows significant advantages in both temperature and humidity prediction, with significantly reduced MSE and MAE, and R² close to 1, indicating that the model has extremely strong fitting ability and prediction accuracy, can accurately capture the laws of environmental changes, and provides efficient and reliable technical support for the precise control of smart homes.
[0117] like Figure 4 As shown, this embodiment also discloses an indoor environment data prediction method and system based on LSTM-iTransformer, including:
[0118] Integration module 41, for integrating temperature data and humidity data monitored by indoor sensors with outdoor weather information provided by the meteorological station to obtain integrated environmental information;
[0119] The time series feature acquisition module 42 is used to input the integrated environmental information into the LSTM module to extract time series features;
[0120] A global deep feature representation acquisition module 43 is configured to input the temporal features into an improved iTransformer module comprising a multi-head differential attention layer, a position encoding layer, and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence and performs position encoding on the enhanced representation of the input sequence to obtain a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation;
[0121] The prediction module 44 is used to input the vector result containing the global deep feature representation into a time series prediction model including an encoder layer, an average pooling layer, a multi-layer perceptron and a fully connected layer to predict the indoor temperature and relative humidity; wherein, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local time series features of the input sequence to obtain a feature representation with local pattern perception capability; the average pooling layer downsamples the feature representation with local pattern perception capability to obtain a reduced dimensionality feature; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality feature to obtain an abstract semantic feature; the fully connected layer receives the abstract semantic feature and predicts the indoor temperature and relative humidity.
[0122] Although the present invention has been particularly shown and described in conjunction with preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made to the present invention without departing from the spirit and scope of the invention as defined in the appended claims, and all such changes are within the scope of protection of the present invention.
Claims
1. A method for indoor environment data prediction based on LSTM-iTransformer, characterized in that: include: S1, integrates the temperature data and humidity data monitored by indoor sensors and the outdoor weather information provided by the meteorological station to obtain integrated environmental information; S2, inputs the integrated environmental information into the LSTM module to extract temporal features; S3, inputting the temporal features into an improved iTransformer module including a multi-head differential attention layer, a position encoding layer, and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence, performs position encoding on the enhanced representation of the input sequence, and obtains a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation; S4, inputs the vector result containing the global deep feature representation into the time series prediction model including the encoder layer, average pooling layer, multi-layer perceptron and fully connected layer to predict the indoor temperature and relative humidity; among them, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local temporal features of the input sequence to obtain a feature representation with local pattern perception ability; the average pooling layer downsamples the feature representation with local pattern perception ability to obtain reduced dimensionality features; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality features to obtain abstract semantic features; the fully connected layer receives the abstract semantic features and predicts the indoor temperature and relative humidity.
2. The indoor environment data prediction method based on LSTM-iTransformer according to claim 1 is characterized in that: In S2, the LSTM module includes two layers of LSTM neural networks connected in sequence; the number of neurons in the first layer of LSTM neural network is set to twice the feature dimension of the input environmental information, which is used to expand the expressive power of the input features; the number of neurons in the second layer of LSTM neural network is the same as the feature dimension output by the first layer of LSTM neural network, which is used to refine the expanded features.
3. The indoor environment data prediction method based on LSTM-iTransformer according to claim 2 is characterized in that: In S2, the two-layer LSTM neural network includes a forget gate, which determines whether to retain or discard the information in the LSTM memory unit. The calculation formula is as follows: ; in, Represents the Sigmoid function, which is used to map the input to between 0 and 1; Represents the weight matrix of the forget gate; Indicates concatenating the previous hidden state with the current input; represents the bias term; Represents the output of the forget gate at time t.
4. The indoor environment data prediction method based on LSTM-iTransformer according to claim 1 is characterized in that: In S3, the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence, specifically including: The input time series features are respectively combined with the parameter matrix 、 and After linear transformation, project it onto the query vector , key vector Sum vector The calculation formula is as follows: ; ; ; in, Represents the temporal characteristics of the input; The query vector representing the first group; The key vector representing the first group; The query vector representing the second group; a key vector representing the second group; 、 and represents the parameter matrix, , is the number of heads; The attention scores are calculated for the two sets of query vectors and key vectors. For the first set, and Perform the dot product operation and then divide by Zoom in, After function processing, we get the first set of attention scores and the second set of attention scores , where the calculation formula for the first set of attention scores is as follows: ; The final attention score is obtained by subtracting the two sets of attention scores and adding them to the value vector Multiply them together and the calculation formula is as follows: ; ; in, Represents a learnable differential weight coefficient used to control the degree of differentiation; represents the final attention score of the traditional differential attention layer; 、 、 and represents a learnable vector; For initialization constant; An enhanced representation of the input sequence is obtained based on the final attention score.
5. The indoor environment data prediction method based on LSTM-iTransformer according to claim 4 is characterized in that: The multi-head differential attention layer is embedded with a thermal response modulation function , the calculation formula is as follows: ; ; in, represents element-wise multiplication; , Indicates the difference between indoor air temperature and wall surface temperature. is the wall surface temperature, Indicates the indoor temperature; is the wall thermal response time constant; is the characteristic parameter of thermal conductive material.
6. The indoor environment data prediction method based on LSTM-iTransformer according to claim 1 is characterized in that: In S3, the enhanced representation of the input sequence is positionally encoded, and the calculation formula is as follows: ; ; in, Indicates location; Represents dimension; Represents the dimension of the input features; Represents the value of the even dimension of the encoding vector corresponding to the position pos; Supplement the odd-numbered dimensions of the encoding vector corresponding to position pos.
7. The indoor environment data prediction method based on LSTM-iTransformer according to claim 1 is characterized in that: In S4, the calculation formulas for predicting indoor temperature and relative humidity are as follows: ; ; in, n represents the time step of future prediction; and Represents the fully connected layers for temperature prediction and humidity prediction respectively; Represents the multilayer perceptron operation; Represents the average pooling layer operation; Represents a one-dimensional convolutional layer operation; represents the output of the improved iTransformer module; The predicted time is time; Indicates The temperature forecast value at the moment.
8. An indoor environment data prediction system based on LSTM-iTransformer, characterized by: include: Integration module, used to integrate the temperature and humidity data monitored by indoor sensors with the outdoor weather information provided by the meteorological station to obtain integrated environmental information; The time series feature acquisition module is used to input the integrated environmental information into the LSTM module to extract time series features; A global deep feature representation acquisition module is used to input the temporal features into an improved iTransformer module including a multi-head differential attention layer, a position encoding layer, and a multi-layer perceptron to obtain a vector result containing a global deep feature representation; wherein the multi-head differential attention layer calculates the difference between the attention scores of the input temporal features to obtain an enhanced representation of the input sequence; the position encoding layer introduces the position information of the sequence, performs position encoding on the enhanced representation of the input sequence, and obtains a feature representation with temporal position information; the multi-layer perceptron performs nonlinear transformation and feature fusion on the feature representation with temporal position information through a nonlinear activation function to obtain a vector result containing a global deep feature representation; The prediction module is used to input the vector results containing the global deep feature representation into the time series prediction model including the encoder layer, the average pooling layer, the multi-layer perceptron and the fully connected layer to predict the indoor temperature and relative humidity; wherein, the feedforward neural network structure of the encoder layer uses a one-dimensional convolutional layer to extract and model the local time series features of the input sequence to obtain a feature representation with local pattern perception ability; the average pooling layer downsamples the feature representation with local pattern perception ability to obtain reduced dimensionality features; the multi-layer perceptron performs nonlinear transformation and combination on the reduced dimensionality features to obtain abstract semantic features; the fully connected layer receives the abstract semantic features and predicts the indoor temperature and relative humidity.
Citation Information
Patent Citations
Photovoltaic power ultra-short-term prediction method and system based on itransfomer
CN119312054A
Face video heart rate detection method based on separable convolution
CN120318148A
Hybrid network 4D flight path prediction method based on LSTM and Transformer
CN120471313A
Non-Intrusive Load Decomposition Method Based on Informer Model Coding Structure
US20220397874A1
Cited By
Multi-encoder fusion and constraint enhancement deep-sea mining vehicle motion digital method
CN121031381A