Two-stage indoor personnel occupation detection method based on machine learning

By constructing a two-stage indoor people detection method based on machine learning, and utilizing the interactive feature set and cascaded model of the pure physical dimension, the problems of feature redundancy and time regularity dependence in the existing technology are solved, and high-precision indoor people detection is achieved.

CN121980263APending Publication Date: 2026-05-05HANGZHOU DIANZI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU DIANZI UNIV
Filing Date
2026-01-19
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing non-invasive indoor personnel detection technologies suffer from feature redundancy, excessive reliance on time patterns leading to poor generalization ability, and problems such as zero-value inflation and high false alarm rates faced by single regression models.

Method used

A two-stage detection method based on machine learning is adopted. By constructing an interactive feature set of pure physical dimension, including time-de-temporal processing, multi-environment feature coupling and two-stage modeling strategy, the best feature subset is selected, and a cascaded model is constructed using gradient boosting decision tree variant to perform personnel presence and number regression detection.

Benefits of technology

While protecting privacy, it improves the accuracy and generalization ability of indoor personnel detection, reduces computational complexity, and decreases the false alarm rate during unattended periods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121980263A_ABST
    Figure CN121980263A_ABST
Patent Text Reader

Abstract

The invention discloses a two-stage indoor personnel occupancy detection method based on machine learning. The method comprises the following steps: acquiring multi-modal time sequence data comprising a plurality of original data packets; the original data packet comprises a sampling timestamp and a physical sensor feature vector; performing time removal on the original data packet; obtaining time sequence derivative features and environment parameter interaction features, and combining the time sequence derivative features and the environment parameter interaction features with physical sensor feature vectors to form a high-dimensional physical feature matrix; screening the high-dimensional physical feature matrix by using a Pearson correlation coefficient and a recursive feature elimination algorithm to remove redundant information, and generating an optimal feature subset; generating a to-be-detected feature vector according to the optimal feature subset; selecting an existence detection model and a people number regression detection model from the candidate model set to construct a two-stage cascade model; and performing binary judgment on whether a person exists or not by using an existence detection model, if yes, inputting the to-be-detected feature vector into a person number regression detection model to obtain a person detection result, and otherwise, outputting that the number of persons is zero.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer data processing, pattern recognition, and intelligent building control technology, and in particular to a two-stage indoor occupancy detection method based on machine learning. Background Technology

[0002] As a major energy consumer, the building sector faces significant challenges in energy conservation and emission reduction. Heating, ventilation, and air conditioning (HVAC) systems typically account for 40%-60% of a building's total energy consumption. Traditional building automation systems often rely on rigid control logic based on preset schedules, leading to energy waste. Therefore, the concept of occupant-centered controls (OCC) has emerged, its core being the precise adjustment of equipment operation based on real-time, sensed information about indoor occupants.

[0003] The key to achieving OCC (Occupational Caution) lies in accurate and real-time indoor occupant detection. Existing indoor occupant detection technologies mainly fall into the following categories: visual technologies, with camera-based visual recognition offering the highest accuracy, but posing serious privacy risks and hindering widespread adoption; passive infrared (PIR) technology, the most mature non-invasive technology, is inexpensive, but its physical principles limit its detection to moving heat sources, easily producing false negatives for static individuals such as those sitting at work or reading, and making it difficult to accurately count the number of people; and environmental sensor fusion technology, which uses data from sensors such as CO2, temperature, humidity, and sound / light sensors to infer the presence and number of people. These methods are non-invasive and protect privacy, but environmental data exhibits significant lag, leading to larger detection errors.

[0004] Existing personnel detection methods based on environmental sensors face the following key technical bottlenecks in practical applications: 1. Over-reliance on time features: Most existing algorithms directly use timestamps (such as hours or weekdays) as input features. Because indoor human behavior has certain regularities, the model is essentially memorizing the building's work-rest schedule, rather than learning the physical laws governing how environmental parameters change with people. Once overtime work, holiday adjustments, or changes in work-rest schedules occur, the model's detection ability will significantly decrease, leading to poor generalization ability.

[0005] 2. Zero inflation problem: In office or residential settings, there are often long periods of time when no one is present. Traditional single regression models struggle to balance the large number of zero values ​​with the small number of non-zero values ​​when dealing with such highly skewed data distributions. This results in non-zero detection results when no one is present, or detection values ​​biased towards the average value when someone is present, leading to significant detection errors.

[0006] 3. Lack of physical interactivity in feature engineering: Raw sensor data is often interfered with by environmental background noise (such as HVAC operating noise and direct sunlight heating). Existing feature engineering construction methods lack the ability to explore the nonlinear coupling relationships between physical quantities (such as the interaction between sound pressure level and temperature, and the difference between indoor and outdoor environments), making it difficult to distinguish between equipment operation and personnel activities in complex dynamic environments. Summary of the Invention

[0007] To address the shortcomings of existing technologies, this invention proposes a two-stage indoor occupancy detection method based on machine learning. The aim is to solve the problems of feature redundancy, poor generalization due to over-reliance on temporal patterns, and the high false alarm rate and zero-value inflation faced by single regression models in existing non-invasive indoor occupancy detection technologies. By constructing a purely physical interaction feature set and adopting a two-stage modeling strategy, this method can eliminate reliance on temporal patterns, deeply mine environmental physical interaction features, and effectively solve zero-value interference, thereby improving the accuracy of indoor occupancy detection while protecting privacy.

[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A two-stage indoor occupancy detection method based on machine learning includes the following steps: S1. Acquire multimodal time-series data from the integrated office environment sensors, including multiple raw data packets; the raw data packets include sampling timestamps and physical sensor feature vectors; S2. De-template the original data packet to obtain time-derived features and environmental parameter interaction features; merge the physical sensor feature vector, time-derived features, and environmental parameter interaction features into a high-dimensional physical feature matrix. S3. Filter the high-dimensional physical feature matrix to remove redundant information and generate the best feature subset; S4. Generate the feature vector to be detected based on the best feature subset; select the existence detection model and the number regression detection model from the constructed candidate model set to construct a two-stage cascaded model; S5. Input the feature vector to be detected into the selected existence detection model to make a binary judgment on whether there is a person. If it is determined that there is a person, input the feature vector to be detected into the selected number regression detection model to obtain the person detection result; otherwise, output the number of people as zero.

[0009] Preferably, the physical sensor feature vector includes the following physical quantities: indoor carbon dioxide concentration, volatile organic compound concentration, noise level (decibels), indoor and outdoor relative humidity, indoor and outdoor temperature, and light intensity.

[0010] Preferably, S1 includes using sampling timestamps to perform integrity detection on multimodal time series data: setting a fault determination threshold based on the sampling period of the physical sensor feature vector; traversing the multimodal time series data, and if the timestamp interval between adjacent original data packets is found to be greater than the fault determination threshold, then determining that a data fault exists here; dividing the data before and after the data fault into independent continuous subsequences, and de-timerizing the continuous subsequences respectively.

[0011] Preferably, S2 includes: S21. Based on the relative time series relationship determined by the sampling timestamps, calculate the dynamic changes of physical quantities, thereby constructing time series derived features including hysteresis features, differential features, and sliding window statistical features; the hysteresis feature is the sensor readings of a preset time step before the current time; the differential feature is the difference between the sensor readings of the current time and past times; the sliding window statistical features are the mean, maximum, minimum, and standard deviation of the sensor readings within the preset time window; S22. Based on the principle of multiphysics coupling, construct environmental parameter interaction characteristics to characterize the nonlinear coupling changes between environmental physical quantities caused by the presence of people, including those used to capture the acoustic-thermal synchronization effect and the relationship between noise decibels and indoor CO2. 2 Acoustic metabolic coupling characteristics of concentration co-occurrence patterns, metabolic thermo-humidity coupling characteristics for capturing the linkage effect between metabolism and thermo-humidity, indoor-outdoor environmental difference characteristics for characterizing the relative changes caused by internal personnel activities, and multi-source heterogeneous comprehensive indicators for characterizing the overall state of the environment.

[0012] As preferred options, acoustic metabolic coupling characteristics include acoustic-thermal interaction characteristics and acoustic-carbon interaction characteristics; metabolic-thermal-humidity coupling characteristics include carbon-temperature interaction characteristics, carbon-humidity interaction characteristics and carbon volatile interaction characteristics; indoor-outdoor environmental difference characteristics include indoor-outdoor temperature difference characteristics and indoor-outdoor humidity difference characteristics, which are the difference in air temperature and relative humidity between indoors and outdoors, respectively; multi-source heterogeneous comprehensive indicators include indoor comfort index and activity intensity index.

[0013] Preferably, S3 uses a two-level feature filtering strategy to filter the high-dimensional physical feature matrix, including: The first-level screening involves calculating the Pearson correlation coefficient between each feature in the high-dimensional physical feature matrix and removing high-dimensional physical features whose absolute Pearson correlation coefficient is greater than a preset threshold. The second-level screening uses a recursive feature elimination algorithm to iteratively eliminate the high-dimensional physical feature matrix that has passed the first-level screening, and selects the best feature subset with the lowest feature dimension while maximizing the detection accuracy of the classification model.

[0014] As a preferred option, in the second-level screening, the recursive feature elimination algorithm uses time series segmentation as a cross-validation strategy, and the screening process aims to maximize the accuracy of the classification model.

[0015] Preferably, S4 includes: S41. Construct a candidate model set; S42. Classify the confidence level of personnel existence through classification gating reasoning and generate binary decision; select the candidate model with the highest accuracy as the existence detection model; S43. Train each candidate model on the full training dataset with and without people to learn the complete continuous mapping from environmental perturbations to both empty and occupied environments; select the candidate model with the lowest mean absolute error as the people regression detection model.

[0016] As preferred options, both the existence detection model and the number regression detection model are trained and evaluated using 5-fold time series cross-validation.

[0017] As a preferred approach, the people regression detection model uses a post-processing module that includes non-negative truncation and discretization rounding to ensure that the people detection results are non-negative integers.

[0018] Compared with the prior art, the beneficial effects of the present invention are reflected in: 1. Unlike traditional techniques that use a single regression model to directly predict the number of people, which can easily lead to noise output during periods of no people, this invention adopts a two-stage serial technique of classification followed by regression, which effectively filters out a large number of unattended samples and solves the problem of false detection during periods of no people.

[0019] 2. Unlike traditional techniques that directly utilize time features (such as hours and days of the week) leading to overfitting of building activity patterns, this invention employs a feature engineering approach that is completely de-temporalized and based on the coupling of multiple environmental features (such as sound-temperature interaction and indoor-outdoor temperature difference). This approach avoids overfitting of the model to time patterns and improves its generalization ability under different activity patterns.

[0020] 3. Unlike traditional techniques that use static thresholds to filter features, which leads to feature redundancy, this invention employs a Pearson decollinearity removal combined with recursive feature elimination (RFECV) technique, which reduces the computational complexity of the model while improving its detection accuracy. Attached Figure Description

[0021] Figure 1 This is an overall flowchart of a two-stage indoor occupancy detection method based on machine learning according to Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the time-de-scaling physical feature engineering construction process of Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the curves showing the number of features and model accuracy based on RFECV in Embodiment 1 of the present invention; Figure 4 This is a schematic diagram comparing the existence detection classification confusion matrix and the time series fitting of the number prediction on the first fold validation set when the present invention uses 5-fold time series cross-validation for performance evaluation. Figure 5 This is a schematic diagram comparing the existence detection classification confusion matrix and the time series fitting of the number of people prediction on the second fold validation set when the present invention uses 5-fold time series cross-validation for performance evaluation. Figure 6 This is a schematic diagram comparing the existence detection classification confusion matrix and the time series fitting of the number of people prediction on the third fold validation set when the present invention uses 5-fold time series cross-validation for performance evaluation. Figure 7 This is a schematic diagram comparing the existence detection classification confusion matrix and the time series fitting of the number of people prediction on the fourth fold validation set when the present invention uses 5-fold time series cross-validation for performance evaluation. Figure 8 This is a schematic diagram comparing the existence detection classification confusion matrix and the time series fitting of the number prediction on the fifth fold validation set when the present invention uses 5-fold time series cross-validation for performance evaluation. Figure 9 This is a schematic diagram of the overall cumulative classification confusion matrix of the 5-fold cross-validation of this invention; Figure 10 This is a scatter plot of the time series fitting for the total cumulative population prediction using the 5-fold cross-validation method of this invention. Figure 11 This is a schematic diagram showing the full-time fitting comparison between the overall cumulative model prediction results and the actual results using the 5-fold cross-validation method of this invention; Figure 12 This is a schematic diagram comparing the sample frequency distribution histograms of the total cumulative model predicted by the five-fold cross-validation of this invention with the actual number of people. Detailed Implementation

[0022] To make the technical means, inventive features, objectives, and effects of the invention readily understandable, the invention is further described below with reference to specific illustrations. However, the invention is not limited to the embodiments described below.

[0023] It should be noted that the structures, proportions, sizes, etc., illustrated in the accompanying drawings of this specification are only used to complement the content disclosed in the specification for those skilled in the art to understand and read, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.

[0024] Example 1: like Figure 1The two-stage indoor occupancy detection method based on machine learning, as shown, includes the following steps: S1. Acquire multimodal time-series data from integrated office environment sensors, including timestamp information and physical sensor feature vectors; S11. Acquisition of multimodal time series data: This embodiment first acquires multimodal time-series data from a comprehensive environmental sensor system deployed in an office. Let's assume... The raw data packets collected at each moment are denoted as It contains timestamp information and physical sensor feature vectors: in, This is the sampling timestamp. Here is the physical sensor feature vector at that moment: in, Indoor carbon dioxide concentration, This refers to the concentration of volatile organic compounds. Noise level in decibels. / This refers to the indoor and outdoor relative humidity. / Indoor and outdoor temperatures, Light intensity.

[0025] It should be noted that, although multimodal time series data includes sampling timestamps However, to avoid the model overfitting the specific daily routines of buildings, this invention will implement a time-de-modification strategy in subsequent steps. That is, it will not directly use time-related features (such as hours or days of the week) as feature inputs, but only use the sampling timestamps. Used for time alignment and difference calculation of data.

[0026] S12. Multimodal time series data cleaning: Using sampling timestamps The sequence is inspected for integrity, and a fault detection threshold is set based on the sampling period of the physical sensor data. In this embodiment, the sampling period is 10 minutes, and the fault detection threshold is set to 30 minutes. The algorithm traverses the multimodal time series data. If the timestamp interval between adjacent data is greater than the fault detection threshold, a data fault is determined to exist. To prevent subsequent calculations of lagging features from crossing the fault and causing errors in physical meaning, this embodiment employs truncation, dividing the data before and after the fault into independent continuous subsequences for feature engineering.

[0027] S2. De-template the original data packet to obtain time-derived features and environmental parameter interaction features; merge the physical sensor feature vector, time-derived features, and environmental parameter interaction features into a high-dimensional physical feature matrix. like Figure 2 The temporalized physical feature engineering construction shown: based on physical sensor feature vectors Construct a high-dimensional physical feature matrix for model input. The core of this step lies in the physical reconstruction of features: explicitly abandoning the use of timestamps. The derived absolute time features retain and construct only those features strongly correlated with the environmental physical state. The specific construction process is as follows: S21. Construct time-series derived features (based on relative time), including lag features, difference features, and sliding window statistical features; This embodiment utilizes sampling timestamps. Given a defined relative temporal relationship, the dynamic changes of physical quantities are calculated. This is not simply data processing, but rather based on principles of environmental physics, extracting the inertia and abrupt changes of environmental parameters over time. Hysteresis characteristics: characterizing the physical memory and cumulative effect of environmental parameters. Due to the physical lag and inertia of gas diffusion and heat transfer in the air, the current environmental state is often the result of accumulated human activities over a past period. To capture this physical memory, this embodiment constructs a hysteresis operator. : In the formula, Sampling timestamp The physical sensor feature vector, The time lag step corresponds to the time scale of the physical process. express Physical sensor feature vectors from a previous time step.

[0028] This feature is used to address issues of ambiguous state. For example, when the indoor CO2 concentration is 800 ppm, there are two possibilities: either the concentration is rising because someone has just entered, or the concentration is falling because someone has just left. Relying solely on the current value... If they cannot be distinguished, they can be combined with lag operators. ,like This implies accumulation / someone, if This implies disappearance / no one is there.

[0029] Difference characteristics: characterizing the dynamic abrupt changes in environmental parameters. The entry, departure, or significant activity of personnel typically causes a momentary disruption of the equilibrium of environmental parameters. To capture these dynamic abrupt changes caused by personnel behavior, this embodiment calculates first-order difference characteristics: In the formula, Sampling timestamp The physical sensor feature vector, for In this embodiment, the physical sensor feature vectors from a time step ago are respectively taken as follows: and As a difference feature, It approximates the rate of change (gradient) of environmental parameters over time.

[0030] The core function of this feature is baseline removal. Baseline environmental values ​​(such as initial room temperature and background noise) may differ on different dates, so direct use... It is easy to introduce bias. And difference characteristics... The focus is on the amount of change.

[0031] Sliding window statistical characteristics: characterizing the fluctuations and short-term trends of environmental parameters. Sensor readings at a single moment are easily affected by transient noise (such as noise from passing vehicles outside the window or instantaneous airflow from air conditioning vents). To extract the statistical regularity of environmental parameters over a period of time, this embodiment focuses on key physical quantities. (include , Apply sliding window transformation. Set the time window length to... In this embodiment, two windows are set: 30 minutes and 60 minutes, for the aforementioned key physical quantities. Calculate the following statistical indicators: a. Moving average In the formula, For window length, It is a key physical quantity.

[0032] The moving average can act as a low-pass filter, smoothing out high-frequency random noise and reflecting environmental parameters in a more accurate manner. The baseline level over the period of time is not affected by jitter in a single measurement.

[0033] b. Sliding peak and trough Sliding peak and trough characteristics can capture extreme events within a window period; for example, when the average noise level is low, but... If it is very high, it indicates that someone is there; conversely, if... and Approaching indicates that the environment is unoccupied and stationary.

[0034] c. Sliding standard deviation In the formula, For window length, It is a key physical quantity.

[0035] The sliding standard deviation characterizes the volatility of environmental parameters. When unattended, environmental parameters typically exhibit smooth changes due to equipment operation or natural diffusion. When the value approaches a low level, the breathing, movements, and conversations of people can introduce random disturbances, causing drastic fluctuations in local microenvironment parameters. Significantly increased.

[0036] S22. Construct environmental parameter interaction characteristics, including acoustic metabolic coupling characteristics, metabolic thermo-humidity coupling characteristics, indoor and outdoor environmental difference characteristics, and multi-source heterogeneous comprehensive indicators; To overcome the limitations of single sensors in characterizing human activity, this embodiment constructs the following four types of interactive features based on the principle of multiphysics coupling to enhance the model's ability to identify indoor personnel: Acoustic metabolic coupling characteristics, including acoustic-thermal interaction characteristics This captures the acoustic-thermal synchronization effect. For example, this characteristic value only increases significantly when both noise level and indoor temperature are high simultaneously; acoustic-carbon interaction characteristics. Capture noise decibels and indoor CO2 2 Co-occurrence of concentrations. For example, in a meeting or discussion setting, noise levels (decibels) and indoor CO2 concentrations... 2 The concentrations showed a strong positive correlation.

[0037] In the formula, Noise level in decibels. Indoor temperature, This represents the indoor carbon dioxide concentration.

[0038] Metabolic thermo-humidity coupling characteristics, including carbon-temperature interaction characteristics Carbon-wet interaction characteristics Interactive characteristics of carbon volatiles This set of features utilizes the gating effect of multiplication. When indoor CO2... 2When any one of the four factors—concentration, indoor temperature, indoor relative humidity, and TVOC—is at a low background value (in an unoccupied state), the interaction characteristic value will be lowered; only when multiple indicators are simultaneously increased due to the influence of the human body will the characteristic value exhibit a non-linear explosive growth.

[0039] In the formula, Indoor carbon dioxide concentration, This refers to indoor relative humidity. Indoor temperature, This represents the concentration of volatile organic compounds.

[0040] The characteristics of the indoor and outdoor environmental differences, in order to highlight the relative changes caused by the activities of people inside, include the indoor and outdoor temperature differences. Indoor and outdoor humidity difference It achieves baseline removal at the physical level and provides more stable criteria than pure indoor data.

[0041] In the formula, This refers to indoor relative humidity. Outdoor relative humidity, Indoor temperature, This refers to the outdoor temperature.

[0042] Multi-source heterogeneous comprehensive indicators, referencing building environment assessment standards, construct high-level semantic features characterizing the overall environmental state by weighted fusion of heterogeneous sensor data, including an indoor comfort index. By normalizing and fusing physical quantities of different dimensions, it reflects the overall degree of environmental congestion and indirectly indicates population density; Activity Intensity Index It integrates transient sounds and cumulative breathing changes to capture the dynamic characteristics of people entering or engaging in intense activity.

[0043] In the formula, Indoor carbon dioxide concentration, This refers to the concentration of volatile organic compounds. Noise level in decibels. This refers to indoor relative humidity. Indoor temperature, for The first-order difference. In this embodiment, the weights are set to... =0.3, =0.2, =0.3, =0.2.

[0044] Finally, the original sensor data and the derived features created above are merged into a high-dimensional physical feature matrix. .

[0045] S3. Filter the high-dimensional physical feature matrix to remove redundant information and generate the best feature subset; Two-stage cascaded feature selection: constructing a high-dimensional physical feature matrix This may contain redundant information; therefore, this embodiment employs a two-level filtering strategy: S31. Collinearity elimination screening: Calculate the high-dimensional physical feature matrix. Any two features and The Pearson correlation coefficient between them. : in, For the first The feature in the first The value at each time step. For the first The feature in the first The value at each time step. For the first The feature is the arithmetic mean over all time steps. For the first The feature is the arithmetic mean over all time steps, and N is the total number of time series samples used for calculation.

[0046] In this embodiment, a threshold is set. ,like This eliminates features that are less correlated with the target variable, thereby eliminating redundant collinearity among features.

[0047] S32. Recursive Feature Elimination (RFECV): Employs a recursive feature elimination algorithm combined with time series cross-validation. Evaluation Criterion: The accuracy of the classification model is used as the scoring standard. The formula is: In the formula, It is a true positive. This is a false positive. Optimizing accuracy aims to minimize false alarms when no one is present.

[0048] Iterative process: In each iteration, a classification model is trained (LightGBM is used as the base model in this embodiment), the feature importance of all features is calculated, and the features with the lowest importance are successively removed until a score is achieved. The peak value is reached. The optimal feature subset selected at the end is denoted as... .

[0049] S4. Generate the feature vector to be detected based on the best feature subset; select the existence detection model and the number regression detection model from the constructed candidate model set to construct a two-stage cascaded model; input the feature vector to be detected into the two-stage cascaded model to generate the personnel detection results.

[0050] Detection model selection: To achieve optimal detection performance, a multi-model competition framework was constructed. Based on the optimal feature subset selected by S3 From the high-dimensional physical feature matrix The feature vector to be detected is obtained from the process. This feature vector is used for training and validation.

[0051] S41. Construct a candidate model set; In this embodiment, three gradient boosting decision tree (GBDT) variants, LightGBM, XGBoost, and CatBoost, were selected as candidate models, and their performance was compared and optimized through rigorous cross-validation.

[0052] Candidate model settings: 1) LightGBM (Lightweight Gradient Boosting): It adopts a gradient-based one-sided sampling strategy, and its advantage is that the training speed is fast.

[0053] 2) XGBoost (Extreme Gradient Boosting): It adopts a pre-sorting and weighted quantile sketch algorithm. Its advantage lies in its extremely fine control over regularization and strong ability to prevent overfitting.

[0054] 3) CatBoost (Category Gradient Boosting): It adopts a symmetric decision tree and ranking boosting strategy, and its advantages lie in handling category features and its ability to withstand noise.

[0055] S42. Classify the confidence level of personnel presence through classification gating inference; select the candidate model with the highest accuracy as the classification model. The first stage involves comparing and selecting classification models.

[0056] Screening strategy and evaluation metrics: Five-fold time series cross-validation was used to train and evaluate the three models mentioned above. Considering that this invention has a two-stage architecture, the core task of the first stage is gating. Since the model output is not a binary integer of 0 or 1, but rather a confidence level indicating the presence of a person... Therefore, a classification-gated reasoning system was designed, with a decision threshold set as follows: Generate binary decision : The first stage aims to minimize the number of false positives (no one being identified as someone), otherwise the subsequent regression model will output incorrect non-zero numbers. Therefore, this embodiment abandons commonly used accuracy or F1 score evaluation metrics, and instead uses precision, similar to the recursive feature elimination in step three. This is the highest priority selection criterion.

[0057] Accuracy Evaluation indicator calculation formula: In the formula, It is a true positive. This is a false positive.

[0058] Based on the results, the best model was selected as the existence detection model for the first stage.

[0059] S43. Train each candidate model on the full training dataset with and without people to learn the complete and continuous mapping from environmental perturbations to both empty and crowded environments; select the candidate model with the lowest mean absolute error as the people regression detection model. The second stage involves comparing and screening regression detection models for the number of people.

[0060] Candidate model settings: LightGBM, XGBoos, and CatBoost were selected for comparison. All models were trained using the full training datasets with and without people to learn a complete continuous mapping from environmental perturbations to zero people and non-zero people.

[0061] The original output of the above machine learning model Since the number is a floating-point number, to conform to the physical definition of the number of people, this embodiment designs a post-processing module that includes non-negative truncation and discretization rounding to output the number of people. The calculation formula is: In the formula, Implement non-negativity constraints to ensure that the number of people cannot be negative. Perform rounding to the nearest integer, mapping continuous values ​​to a discrete space of integers.

[0062] Screening strategy and evaluation metrics: Five-fold time series cross-validation was also used. The evaluation focuses on the model's fit to a specific number of people, especially the accuracy of people detection in occupied situations. Therefore, the mean absolute error was used as the evaluation metric. As an evaluation indicator.

[0063] Mean Absolute Error Evaluation indicator calculation formula: In the formula, Indicates the actual number of people. This indicates the number of people output by the model.

[0064] Based on the results, the best model was selected as the regression model for the second stage.

[0065] Final Model Construction and Cascading: Based on the above optimization results, the final two-stage cascading model is constructed.

[0066] S5. Input the feature vector to be detected into the selected existence detection model to make a binary judgment on whether there is a person. If it is determined that there is a person, input the feature vector to be detected into the selected number regression detection model to obtain the person detection result; otherwise, output the number of people as zero.

[0067] The optimal model trained in S4 is used for construction, and the feature vector to be detected is... The input is fed into the existence detection model for a binary judgment of whether someone is present. If someone is present, the model continues to call the people regression detection model, using the same feature vector to be detected. The input to the people regression detection model is the current people detection result; if the existence detection model determines that there is no one, it directly outputs that the number of people is zero and does not call the people regression detection model.

[0068] Example 2: Experimental verification and result analysis: To verify the effectiveness of the method proposed in this invention, a full-process test was conducted in this embodiment using a dataset collected from a real office building. The dataset contains 5184 samples, spanning from September to October 2021. The number of employees during working hours fluctuated between 0 and 12, while the number of employees outside of working hours was 0, consistent with the normal activity patterns of office workers. The dataset was sampled at 10-minute intervals.

[0069] 1. Feature Engineering and Screening Results a. Initial feature construction: Based on the construction strategy in step two, the initially generated high-dimensional physical feature matrix contains a total of 63 features.

[0070] b. Pre-screening: Pure time features were removed, leaving 47 features.

[0071] c. First stage screening: Remove collinear features, calculate Pearson correlation coefficient, set the threshold to 0.95, remove 26 highly redundant features, leaving 21 features.

[0072] d. Second-stage screening: Recursive feature elimination is performed using 5-fold time series cross-validation, such as... Figure 3 As shown in the figure, the results indicate that the classification model achieves optimal accuracy when the number of features is reduced to 8.

[0073] e. Optimal Feature Subset: The final eight core features determined were indoor carbon dioxide concentration. Indoor relative humidity Indoor temperature Light intensity outdoor relative humidity Outdoor dry bulb temperature Indoor and outdoor temperature difference Sound-temperature interaction characteristics Among them, the sound-temperature interaction feature and the indoor-outdoor temperature difference feature proposed in this invention were both successfully selected, proving the effectiveness of the physical interaction feature.

[0074] 2. Model Selection and Performance Evaluation a. Classification Model: The LightGBM, XGBoost, and CatBoost algorithms were compared, and the experimental results are shown in Table 1. Table 1: Results of Classification Model Screening Indicators

[0075] Experimental results show that the XGBoost classifier model achieved the highest average precision in cross-validation and was therefore selected as the first-stage model.

[0076] b. Regression Model: LightGBM, XGBoos, and CatBoost were selected for comparison. The experimental results are shown in Table 2. Table 2: Results of index selection for regression model

[0077] The CatBoost regressor model outperformed other models in all error metrics and was therefore selected as the second-stage model.

[0078] 3. Overall effect of the two-stage model The above-mentioned optimized models were cascaded and tested. The final comprehensive performance indicators are as follows: Overall MAE: 0.5692; Overall RMSE: 1.5404. When using 5-fold time series cross-validation for performance evaluation, the comparison of the existence detection classification confusion matrix and the time series fitting of the number prediction on each fold validation set is as follows: Figures 4 to 8 As shown; the visualization results of the overall cumulative performance evaluation under 5-fold cross-validation are as follows. Figures 9 to 12 As shown.

[0079] The results show that, compared with a single regression model, the two-stage architecture of this invention achieves higher prediction accuracy while significantly compressing feature dimensions and reducing computational load.

[0080] Example 3: Hardware implementation environment: This invention also provides a computer system for performing the above-described methods. The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. A data acquisition module receives the environmental sensor data streams described above via a data interface. The processor is configured to execute the feature engineering, feature selection, and two-stage model inference logic described in steps one through five. The memory stores the trained XGBoost classification model file and CatBoost regression model file, as well as a historical feature list for feature selection.

[0081] Example 4: Furthermore, embodiments of the present invention also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned two-stage indoor occupancy detection method based on recursive feature elimination and machine learning.

[0082] It will be understood by those skilled in the art that the above description is merely a preferred example of the invention and is not intended to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, those skilled in the art can still modify the technical solutions described in the foregoing examples or make equivalent substitutions for some of the technical features. All modifications and equivalent substitutions made within the spirit and principles of the invention should be included within the scope of protection of the invention.

Claims

1. A two-stage indoor occupancy detection method based on machine learning, characterized in that, Includes the following steps: S1. Acquire multimodal time-series data from the integrated office environment sensors, including multiple raw data packets; the raw data packets include sampling timestamps and physical sensor feature vectors; S2. De-template the original data packet to obtain time-derived features and environmental parameter interaction features; merge the physical sensor feature vector, time-derived features, and environmental parameter interaction features into a high-dimensional physical feature matrix. S3. Filter the high-dimensional physical feature matrix to remove redundant information and generate the best feature subset; S4. Generate the feature vector to be detected based on the optimal feature subset; An existence detection model and a number regression detection model were selected from the constructed candidate model set to construct a two-stage cascaded model; S5. Input the feature vector to be detected into the selected existence detection model to make a binary judgment on whether there is a person. If it is determined that there is a person, input the feature vector to be detected into the selected number regression detection model to obtain the person detection result; otherwise, output the number of people as zero.

2. The two-stage indoor occupancy detection method based on machine learning according to claim 1, characterized in that, The physical sensor feature vector includes the following physical quantities: indoor carbon dioxide concentration, volatile organic compound concentration, noise level (decibels), indoor and outdoor relative humidity, indoor and outdoor temperature, and light intensity.

3. The two-stage indoor occupancy detection method based on machine learning according to claim 1, characterized in that, S1 includes using sampling timestamps to perform integrity detection on multimodal time series data: setting a fault determination threshold based on the sampling period of physical sensor feature vectors; traversing multimodal time series data, if the timestamp interval between adjacent original data packets is greater than the fault determination threshold, then determining that there is a data fault; dividing the data before and after the data fault into independent continuous subsequences, and de-timerizing the continuous subsequences respectively.

4. The two-stage indoor occupancy detection method based on machine learning according to claim 1, characterized in that, S2 include: S21. Based on the relative time series relationship determined by the sampling timestamps, calculate the dynamic changes of physical quantities, thereby constructing time series derived features including hysteresis features, differential features, and sliding window statistical features; the hysteresis feature is the sensor readings of a preset time step before the current time; the differential feature is the difference between the sensor readings of the current time and past times; the sliding window statistical features are the mean, maximum, minimum, and standard deviation of the sensor readings within the preset time window; S22. Based on the principle of multiphysics coupling, construct environmental parameter interaction characteristics to characterize the nonlinear coupling changes between environmental physical quantities caused by the presence of people, including those used to capture the acoustic-thermal synchronization effect and the relationship between noise decibels and indoor CO2. 2 Acoustic metabolic coupling characteristics of concentration co-occurrence patterns, metabolic thermo-humidity coupling characteristics for capturing the linkage effect between metabolism and thermo-humidity, indoor-outdoor environmental difference characteristics for characterizing the relative changes caused by internal personnel activities, and multi-source heterogeneous comprehensive indicators for characterizing the overall state of the environment.

5. The two-stage indoor occupancy detection method based on machine learning according to claim 4, characterized in that, Acoustic metabolic coupling features include acoustic-thermal interaction features and acoustic-carbon interaction features; metabolic thermo-humidity coupling features include carbon-temperature interaction features, carbon-humidity interaction features, and carbon volatile matter interaction features. The characteristics of the indoor and outdoor environmental differences include the characteristics of indoor and outdoor temperature difference and indoor and outdoor humidity difference, which are the differences in air temperature and relative humidity between indoors and outdoors, respectively; the multi-source heterogeneous comprehensive index includes the indoor comfort index and the activity intensity index.

6. The two-stage indoor occupancy detection method based on machine learning according to claim 1, characterized in that, S3 uses a two-level feature filtering strategy to filter high-dimensional physical feature matrices, including: The first-level screening involves calculating the Pearson correlation coefficient between each feature in the high-dimensional physical feature matrix and removing high-dimensional physical features whose absolute Pearson correlation coefficient is greater than a preset threshold. The second-level screening uses a recursive feature elimination algorithm to iteratively eliminate the high-dimensional physical feature matrix that has passed the first-level screening, and selects the best feature subset with the lowest feature dimension while maximizing the detection accuracy of the classification model.

7. The two-stage indoor occupancy detection method based on machine learning according to claim 6, characterized in that, In the second-level screening, the recursive feature elimination algorithm uses time series segmentation as a cross-validation strategy, and the screening process aims to maximize the accuracy of the classification model.

8. The two-stage indoor occupancy detection method based on machine learning according to claim 1, characterized in that, S4 include: S41. Construct a candidate model set; S42. Classify the confidence level of personnel existence through classification gating reasoning and generate binary decision; select the candidate model with the highest accuracy as the existence detection model; S43. Train each candidate model on the full training dataset with and without people to learn the complete continuous mapping from environmental perturbations to both empty and occupied environments; select the candidate model with the lowest mean absolute error as the people regression detection model.

9. The two-stage indoor occupancy detection method based on machine learning according to claim 8, characterized in that, Both the existence detection model and the number regression detection model were trained and evaluated using 5-fold time series cross-validation.

10. A two-stage indoor occupancy detection method based on machine learning according to claim 8, characterized in that, The people regression detection model uses a post-processing module that includes non-negative truncation and discretization rounding to ensure that the people detection results are non-negative integers.