Pig house environment anomaly detection method and system based on multi-scale variable fusion time series

By adopting a multi-scale variable fusion timing network Transformer model in pig house environmental monitoring, the problem that existing technology is difficult to deeply analyze and predict pig house environmental data is solved, and more efficient and accurate environmental anomaly detection is achieved to ensure the health of pigs and Productivity.

CN118734237BActive Publication Date: 2025-02-07SOUTH CHINA AGRICULTURAL UNIVERSITY +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411230383.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2025-02-07
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

Existing pig house environmental monitoring technologies are difficult to analyze environmental data in depth and predict future environmental changes. Traditional methods perform poorly when dealing with complex and missing data, making it difficult to capture long-term dependence and periodic characteristics.

Method used

Using a pig house environment anomaly detection method based on multi-scale variable fusion timing, multi-dimensional environmental parameters were collected through preset sensors, and disassembled into a univariate time series. Trend and seasonal components were extracted using STL decomposition method to construct multi-scale variable fusion timing The network Transformer model captures complex relationships and multi-scale variation characteristics in time series, extracts prediction results and judges abnormal alarms.

Benefits of technology

It improves the accuracy and efficiency of environmental abnormality detection in pig houses, can more accurately predict the changing trends of parameters such as temperature, humidity and exhaust gas concentration, adapt to data gaps, and have a high degree of integration to ensure the health and production efficiency of pigs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734237B_ABST
    Figure CN118734237B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for detecting anomalies in a pig house environment based on a multi-scale variable fusion time series, including: using preset sensors to collect multi-dimensional environmental parameters in a pig house environment to construct a multi-variable time series data set, using the STL decomposition method to extract trend components and seasonal components, constructing a multi-scale variable fusion time series network Transformer model, capturing environmental parameter characteristics of different change periods in the time series, extracting the prediction results of the single variable time series corresponding to different main environmental parameters; comparing the abnormality score between the predicted value and the actual observed value calculated for each variable, and judging the generation of abnormal alarms. The present invention realizes accurate monitoring, intelligent management and efficient decision-making of the pig breeding environment, improves the intelligence level of detecting abnormal environmental parameters, improves environmental quality, provides a better growth environment for pigs, and effectively prevents the adverse effects of environmental factors on pig growth efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of time series analysis and intelligent environment detection, and more specifically, to a method and system for detecting anomalies in a pig house environment based on multi-scale variable fusion time series. Background Art

[0002] Existing studies have shown that the pig house environment has a certain impact on pig appetite, pig herd morbidity, fertility and other breeding production indicators. Existing pig house environment monitoring is mainly carried out through traditional temperature and humidity gas sensors, which can collect key parameters such as temperature, humidity and gas concentration in the pig house in real time. Although this method can provide real-time environmental data, it is impossible to conduct in-depth analysis and processing of these data to predict future environmental changes. For example, in abnormal situations such as when the temperature is about to change significantly or the concentration of harmful gases may exceed the standard, traditional sensors cannot issue early warnings.

[0003] Multi-scale variable time series prediction is a hot topic in the field of data mining and machine learning. With the development of big data and deep learning, its research resources are becoming increasingly abundant. Traditional methods perform poorly when dealing with complex and missing data, and it is difficult to capture long-term dependencies and periodic characteristics. Trend decomposition techniques also have difficulty in accurately separating features of different time scales, affecting prediction accuracy. During model pre-training, existing methods often ignore the problem of missing data, resulting in performance degradation. In addition, there is a lack of effective mechanism for auxiliary variable selection, which may introduce irrelevant or redundant variables. Furthermore, these methods often ignore the position information in the time series and cannot fully utilize the dependencies in the series. Therefore, in order to address the above challenges, especially in the selection of auxiliary variables, capturing time series relationships, utilizing position information, and processing multi-scale change features, it is urgent to develop a pig house environment anomaly detection method based on a multi-scale variable fusion time series network Transformer model. Summary of the invention

[0004] In order to solve the above technical problems, the present invention proposes a pig house environment anomaly detection method and system based on multi-scale variable fusion time series. The purpose is to more accurately capture the complex relationships, position dependencies and multi-scale change characteristics in the environmental parameter time series through advanced model architecture and algorithms, thereby improving the accuracy and efficiency of time series anomaly detection, and then providing protection for the growth environment of pigs.

[0005] The first aspect of the present invention provides a method for detecting anomalies in a pig house environment based on multi-scale variable fusion time series, comprising:

[0006] Using preset sensors to collect multidimensional environmental parameters in the pig house environment, preprocessing the multivariate time series corresponding to the multidimensional environmental parameters, and disassembling them into single variable time series, wherein the multidimensional environmental parameters include temperature, humidity, and exhaust gas concentration;

[0007] The STL decomposition method is used on the disassembled univariate time series to extract trend components and seasonal components, and the seasonal components are used for model pre-training;

[0008] Construct a multi-scale variable fusion time series network Transformer model to capture the characteristics of different change periods in the time series and extract the prediction results of different univariate time series;

[0009] Compare the abnormality score between the predicted value and the actual observed value calculated for each variable, compare it with the preset abnormality score threshold, and determine whether to generate an abnormality alert.

[0010] In this solution, the multivariate time series corresponding to the multidimensional environmental parameters is preprocessed and decomposed into a univariate time series, specifically:

[0011] For temperature variables, humidity variables and exhaust gas concentration variables, all parameter values ​​and corresponding timestamps are extracted to form temperature time series, humidity time series and exhaust gas concentration time series;

[0012] Use the Hampel identifier to detect outliers in each time series. For each time series, traverse each data point , calculate the median of its front and back neighbors and absolute median difference Standardized score of , ,in represents a constant, Indicates the timestamp, Represents environment parameter variables;

[0013] A standardized score threshold is preset. If the standardized score of a data point is greater than the preset standardized score threshold, the data point is considered an outlier;

[0014] Use linear interpolation to fill in outliers and missing values ​​in the original data. For each position that needs to be filled , get the known data points before and after and , perform linear interpolation calculation based on the value of the known data point to obtain the filling value , expressed as:

[0015] ;

[0016] in, Represents the number of data point location items.

[0017] In this solution, the STL decomposition method is used to extract the trend component and seasonal component from the disassembled univariate time series, and the seasonal component is used for model pre-training, specifically:

[0018] The STL decomposition method is used to decompose the univariate time series to obtain seasonal components and trend components. The mask mechanism is used to mark the missing values ​​of the seasonal components, where the positions of the missing values ​​are 1 and the other positions are 0, which is expressed as:

[0019] ;

[0020] in represents the seasonal component, Represents the mask vector;

[0021] The MAE Transformer model is pre-trained using the seasonal components and the generated mask vectors. And the corresponding mask vector As input, predict the masked part based on the unmasked part through iterative learning;

[0022] The MAE Transformer model is trained with the goal of minimizing the loss function, and the pre-trained model is used to predict the missing values ​​in the seasonal component to provide preset parameters for the multi-scale variable fusion time series network Transformer model.

[0023] In this solution, a multi-scale variable fusion time series network Transformer model is constructed, specifically:

[0024] Construct a multi-scale variable fusion time series network Transformer model, including a GRU gating module and a multi-scale time series prediction module. In the GRU gating module, each univariate time series is selected as the main variable one by one, and the remaining univariate time series are used as auxiliary variables, and weighted fusion is performed through the GRU unit;

[0025] For each time point, the main variable and the auxiliary variable are input into the GRU unit, and the GRU unit calculates a weight for each auxiliary variable, and fuses the weighted auxiliary variable with the main variable;

[0026] Select humidity seasonal series separately , temperature seasonal series and seasonal series of exhaust gas concentration As the main variable, the remaining sequences are fused as auxiliary variables to obtain three fused sequences, namely, the fused sequence with temperature as the main variable , Fusion sequence with humidity as the main variable And the fusion sequence with exhaust gas concentration as the main variable .

[0027] In this solution, the multi-scale time series prediction module is specifically:

[0028] In the multi-scale time series prediction module, a multi-scale Transformer is used to obtain the seasonal pattern characteristics of each time series;

[0029] Select the fusion sequence with temperature as the main variable Converted to patches of different scales, represented as ,in Indicates the length of the patch. Indicates the number of patches. represents the step length;

[0030] The patch is passed through a trainable linear projection Mapped to dimension In the multi-scale Transformer latent space, a learnable position encoding is added to each patch , the position-encoded patch is represented as: ;

[0031] Introducing a multi-scale attention mechanism, for an input patch sequence of length M, using parameters Controlling the sequence range that each attention head can observe and capturing diverse seasonal component patterns, the attention head in the multi-scale attention mechanism is expressed as:

[0032] ;

[0033] ;

[0034] in, Indicates head, Indicates Locations, represents a function that extracts the context of a given position, represents the query vector, , represents the key vector, , represents a value vector, , represents the parameter matrix.

[0035] In this scheme, a flattening layer and a linear head are used in the multi-scale time series prediction module to obtain the prediction results of the fused series with temperature as the main variable. , ,in It indicates the linearized representation of the temperature prediction value;

[0036] Select the fusion sequence with humidity as the main variable and the fusion sequence with exhaust gas concentration as the main variable As the main variable, the multi-scale variable fusion time series network Transformer model is used to perform multi-scale time series prediction to obtain the prediction results of the three time series of humidity, temperature and exhaust gas concentration. , and .

[0037] In this solution, the abnormality score between the predicted value and the actual observed value of each variable is compared, and the preset abnormality score threshold is compared to determine the generation of abnormal alarms, specifically:

[0038] For each temperature variable, humidity variable, and exhaust gas concentration variable, calculate the abnormality score between the predicted value and the actual observed value. It represents the distance of the data point relative to the mean and standard deviation of the actual observation sequence in which it is located, expressed as: ,in, represents the current data point, represents the mean of the series, represents the standard deviation of the series;

[0039] An abnormality score threshold is preset for the time series of the temperature variable, the humidity variable and the exhaust gas concentration variable. If the abnormality score is greater than the abnormality score threshold, an abnormality alarm is triggered.

[0040] The second aspect of the present invention provides a pig house environment anomaly detection system based on multi-scale variable fusion time series, including: an intelligent environment monitoring module, a prediction module, an alarm module and an intelligent environment control module;

[0041] The intelligent environment monitoring module is used to monitor and collect key environmental parameters of the pig house environment in real time, including thermal environment data and exhaust gas concentration data, and store the collected data locally or in a cloud server, and display the environmental data in the pig house through a visual interface;

[0042] The prediction module predicts the changing trend of key environmental parameters based on the multi-scale variable fusion time series network Transformer model, providing data basis for intelligent abnormal warning of pig house environment;

[0043] The alarm module compares the predicted results of key environmental parameters with the actual observed values, detects anomalies through preset thresholds and statistical methods, generates alarm information based on the anomalies of key environmental parameters, and sends the alarm information using a preset method;

[0044] The intelligent environmental control module generates an environmental control plan based on the alarm information of abnormal key environmental parameters, and adjusts the environmental parameters of the pig house according to the environmental control plan.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] (1) High prediction accuracy: Through multi-scale attention mechanism and trend decomposition, the system can accurately predict the temperature, humidity and exhaust gas concentration of the pig house, thereby improving the prediction accuracy.

[0047] (2) Adapting to data gaps: Using mask and MAE strategies for pre-training enables the model to make accurate predictions when the data is incomplete, alleviating the problem of data gaps.

[0048] (3) High level of integration: Design a system for efficient pig house environment anomaly detection to achieve accurate monitoring, intelligent management and intelligent decision-making of the pig house environment, ensure the health and welfare of pigs, and improve production efficiency and economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions in the embodiments or exemplary embodiments of the present invention, the drawings required for use in the embodiments or exemplary descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained according to the drawings without paying creative work.

[0050] Figure 1 A flow chart of a pig house environment anomaly detection method based on multi-scale variable fusion time series is shown;

[0051] Figure 2 The structural diagram of data preprocessing and model pre-training is shown;

[0052] Figure 3 The structure diagram of the multi-scale variable fusion time series network Transformer model is shown;

[0053] Figure 4 The framework diagram of the pig house environment anomaly detection system based on multi-scale variable fusion time series is shown. DETAILED DESCRIPTION

[0054] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0056] Figure 1 A flowchart of a pig house environment anomaly detection method based on multi-scale variable fusion time series is shown.

[0057] like Figure 1 As shown, this embodiment provides a pig house environment anomaly detection method based on multi-scale variable fusion time series, including:

[0058] S102, using a preset sensor to collect multidimensional environmental parameters in the pig house environment, preprocessing the multivariate time series corresponding to the multidimensional environmental parameters, and disassembling them into a single variable time series, wherein the multidimensional environmental parameters include temperature, humidity, and exhaust gas concentration;

[0059] S104, using the STL decomposition method to extract trend components and seasonal components from the disassembled univariate time series, and using the seasonal components to perform model pre-training;

[0060] S106, construct a multi-scale variable fusion time series network Transformer model to capture the characteristics of different change periods in the time series and extract the prediction results of different single variable time series;

[0061] S108, comparing the abnormality score between the predicted value and the actual observed value calculated for each variable, comparing with the preset abnormality score threshold, and determining and generating an abnormality alarm.

[0062] It should be noted that the growth environment data of the pig farm was collected for multiple consecutive days through various types of sensors, with the data collection interval being 15 minutes, that is, a total of 192 time period data sets. The multidimensional environmental parameters include multiple variables such as temperature, humidity, and exhaust gas concentration. Each variable changes over time, constructing a multidimensional data set. In order to conduct more in-depth analysis and processing, these multivariate data are disassembled into univariate sequences, and the outliers in each sequence are processed separately.

[0063] Figure 2 The structural diagram of data preprocessing and model pre-training is shown.

[0064] Specifically, the original data set is a table containing multiple fields, each field corresponds to a variable (such as temperature, humidity, exhaust gas concentration, etc.), and the decomposition process is to extract each variable to form a separate time series.

[0065] For the temperature variable, extract all parameter values ​​and corresponding timestamps to form a temperature time series :

[0066] ;

[0067] in, Indicates timestamp, Indicates The temperature value corresponding to the timestamp;

[0068] Similarly, similar extraction operations are performed on humidity and exhaust gas concentration variables to form humidity time series And exhaust gas concentration time series :

[0069] ;

[0070] ;

[0071] in, and Respectively represent The humidity value and exhaust gas concentration value corresponding to the timestamp.

[0072] Use the Hampel identifier to detect outliers in each time series. For each time series, traverse each data point , calculate the median of its front and back neighbors and absolute median difference Standardized score of , ,in represents a constant, Indicates the timestamp, Represents an environmental parameter variable; a standardized score threshold is preset. If the standardized score of a data point is greater than the preset standardized score threshold, the data point is considered an outlier.

[0073] Once the outliers are detected, linear interpolation is used to fill in the missing values ​​in the original data. For each position that needs to be filled, the known data points before and after it are found, and then linear interpolation is performed based on the values ​​of these two points to obtain the filled value.

[0074] Use linear interpolation to fill in outliers and missing values ​​in the original data. For each position that needs to be filled , get the known data points before and after and , perform linear interpolation calculation based on the value of the known data point to obtain the filling value , expressed as:

[0075] ;

[0076] in, Represents the number of data point location items.

[0077] It should be noted that considering that the trends of the same type of information at the corresponding time are often similar, the seasonal component represents the periodic changes in the data, and the trend component represents the long-term trend of the data. The STL decomposition method is used to decompose the univariate time series to obtain the seasonal component and the trend component. For example:

[0078] ;

[0079] ;

[0080] Where AvgPool represents the moving average operation, and Represented as the decomposed trend component and seasonal component respectively.

[0081] Due to the problem of sensors with missing data, after obtaining the seasonal component, it is necessary to process the missing values ​​that may exist in it. To this end, a mask mechanism will be applied to identify these missing values ​​and prepare data for pre-training of the MAE Transformer model. The seasonal component is marked with missing values ​​using a mask mechanism, where the position of the missing value is 1 and the other positions are 0, expressed as:

[0082] ;

[0083] in represents the seasonal component, Represents a mask vector, which is used to indicate which positions are masked (i.e., the vacant positions in the original data), so that the processing strategy or training target can be adjusted accordingly. The MAE Transformer model is pre-trained using the seasonal component and the generated mask vector to learn the ability to predict vacant values. And the corresponding mask vector As input, the masked part is predicted based on the unmasked part through iterative learning; the training goal is to minimize the MAE (mean absolute error) between the predicted value and the actual value of the masked part. Its formula is as follows:

[0084] ;

[0085] in, Represents the model at a time point The predicted value of Indicates the actual value (the value after padding).

[0086] Through multiple iterations and optimizations, the MAE Transformer model is trained with the goal of minimizing the loss function. The pre-trained model is used to predict the missing values ​​in the seasonal component, providing preset parameters for the multi-scale variable fusion time series network Transformer model to enhance the generalization performance of the model.

[0087] Figure 3 The structural diagram of the multi-scale variable fusion temporal network Transformer model is shown.

[0088] It should be noted that the multi-scale variable fusion time series network Transformer model is constructed, including a GRU gating module and a multi-scale time series prediction module.

[0089] The GRU gating module is a recurrent neural network (RNN) variant that controls the flow of information by introducing a gating mechanism, thereby effectively capturing long-term dependencies in sequence data and integrating information from multiple univariate seasonal series. Here, each univariate time series is selected as the main variable in the GRU gating module, and the remaining univariate time series are selected as auxiliary variables, and weighted fusion is performed through the GRU unit;

[0090] For each time point, the main variable and the auxiliary variable are input into the GRU unit, and the GRU unit calculates the weight for each auxiliary variable, and the weighted auxiliary variable is fused with the main variable; first, the humidity seasonal series is selected As the main variable. Temperature seasonal series and seasonal series of exhaust gas concentration As an auxiliary variable, t , the main variable and auxiliary variables , Input into GRU. GRU calculates a weight for each auxiliary variable according to its internal mechanism, and then fuses these weighted auxiliary variables with the main variable. This process can be expressed as:

[0091] ;

[0092] in, Indicates the fused sequence at time point t The value of , , Represents the weights calculated by the GRU unit, reflecting the importance of different variables in the fusion process. These weights are automatically learned by the model during training. and Respectively represent the temperature seasonal series and seasonal series of exhaust gas concentration The output obtained by inputting into the corresponding GRU network, wherein the GRU network is used to extract useful information in the auxiliary variables.

[0093] Repeat the above process and select humidity seasonal series , temperature seasonal series and seasonal series of exhaust gas concentration As the main variable, the remaining sequences are fused as auxiliary variables to obtain three fused sequences, namely, the fused sequence with temperature as the main variable , Fusion sequence with humidity as the main variable And the fusion sequence with exhaust gas concentration as the main variable .

[0094] When establishing the seasonal component model, considering the different seasonal patterns in the time series of humidity, temperature and exhaust gas, a multi-scale Transformer is used here to explore the seasonal pattern characteristics of each time series and thus predict the seasonal component.

[0095] First, select the fusion sequence with temperature as the main variable Converted to patches of different scales, represented as ,in Indicates the length of the patch. Indicates the number of patches. represents the step length; using patch as input can transform a single time point into a fragment, thereby increasing the amount of information and enabling the model to better focus on anomaly detection in the fragment. At the same time, this process reduces the length of the input vector from Reduced to , thereby reducing memory usage and computational complexity.

[0096] Given the various patterns in the seasonal components, a single-scale self-attention mechanism may not be able to adequately capture all the diverse patterns. A multi-scale Transformer encoder is used to alleviate this problem by passing the patch through a trainable linear projection. Mapped to dimension In the multi-scale Transformer latent space, a learnable position encoding is added to each patch , the position-encoded patch is represented as: ;

[0097] Introducing a multi-scale attention mechanism, for an input patch sequence of length M, using parameters Controlling the sequence range that each attention head can observe and capturing diverse seasonal component patterns, the attention head in the multi-scale attention mechanism is expressed as:

[0098] ;

[0099] ;

[0100] in, Indicates head, Indicates Locations, represents a function that extracts the context of a given position, represents the query vector, , represents the key vector, , represents a value vector, , represents the parameter matrix;

[0101] Using this multi-scale attention mechanism, we can implement an attention mechanism with multi-scale perception heads. Each head works at a different scale. The self-attention of each head, multi-scale Transformer, is , which is expressed as follows:

[0102] ;

[0103] in represents the parameter matrix;

[0104] Compared with ordinary multi-head self-attention, the variable Controlling the range of sequences that each attention head can observe enables different heads to capture diverse seasonal component patterns.

[0105] A flattening layer and a linear head are used in the multi-scale time series forecasting module to obtain the forecast results of the fused series with temperature as the main variable. , ,in It indicates the linearized representation of the temperature prediction value;

[0106] Select the fusion sequence with humidity as the main variable and the fusion sequence with exhaust gas concentration as the main variable As the main variable, the multi-scale variable fusion time series network Transformer model is used to perform multi-scale time series prediction to obtain the prediction results of the three time series of humidity, temperature and exhaust gas concentration. , and .

[0107] It should be noted that for each temperature variable, humidity variable and exhaust gas concentration variable, the abnormality score between the predicted value and the actual observed value is calculated. It represents the distance of the data point relative to the mean and standard deviation of the actual observation sequence in which it is located, expressed as: ,in, represents the current data point, represents the mean of the series, represents the standard deviation of the series;

[0108] According to the actual situation of the data and the sensitivity requirements of anomaly detection, the abnormality score threshold is preset for the time series of temperature variables, humidity variables and exhaust gas concentration variables. If the abnormality score is greater than the abnormality score threshold, an abnormal alarm is triggered. Relevant personnel need to check the system status in time, confirm the cause of the abnormality, and take corresponding measures to deal with the intelligent environment control module, including adjusting equipment parameters, replacing faulty parts, cleaning the environment, etc. After the abnormality is handled, the processing results need to be fed back to the system so that the prediction model can be corrected and optimized. The model can be retrained by collecting processed data to improve the accuracy of the model's prediction of future abnormal situations.

[0109] Figure 4 The framework diagram of the pig house environment anomaly detection system based on multi-scale variable fusion time series is shown.

[0110] This embodiment provides a pig house environment anomaly detection system based on multi-scale variable fusion time series, including: an intelligent environment monitoring module, a prediction module, an alarm module and an intelligent environment control module;

[0111] The intelligent environment monitoring module is used to monitor and collect key environmental parameters of the pig house environment in real time, including thermal environment data and exhaust gas concentration data, and store the collected data locally or in a cloud server, and display the environmental data in the pig house through a visual interface;

[0112] The prediction module predicts the changing trend of key environmental parameters based on the multi-scale variable fusion time series network Transformer model, providing data basis for intelligent abnormal warning of pig house environment;

[0113] The alarm module compares the predicted results of key environmental parameters with the actual observed values, detects anomalies through preset thresholds and statistical methods, generates alarm information based on the anomalies of key environmental parameters, and sends the alarm information using a preset method;

[0114] The intelligent environmental control module generates an environmental control plan based on the alarm information of abnormal key environmental parameters, and adjusts the environmental parameters of the pig house according to the environmental control plan.

[0115] The intelligent environmental control module mainly includes a variety of sensors for real-time monitoring of environmental parameters, and then transmits the data collected by the sensors to the central processor for analysis, and determines whether the environmental parameters need to be adjusted based on the preset thresholds and algorithms. When the environmental parameters need to be adjusted, the central processor will send instructions to the actuator, such as turning on or off ventilation equipment, adjusting heating or cooling equipment, controlling lighting and controlling water curtain equipment, etc. When the environmental parameters in the pig house exceed the preset threshold, the alarm module will issue an alarm, including sound alarm, light flash alarm, mobile phone APP push, etc., to ensure that the breeders can receive the alarm information in time and remind the breeders to take timely measures.

[0116] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0117] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0118] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0119] Those skilled in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.

[0120] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0121] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A pig house environment anomaly detection method based on multi-scale variable fusion time series, characterized in that: The following steps are involved: Using preset sensors to collect multidimensional environmental parameters in the pig house environment, preprocessing the multivariate time series corresponding to the multidimensional environmental parameters, and disassembling them into single variable time series, wherein the multidimensional environmental parameters include temperature, humidity, and exhaust gas concentration; The STL decomposition method is used on the disassembled univariate time series to extract trend components and seasonal components, and the seasonal components are used for model pre-training; Construct a multi-scale variable fusion time series network Transformer model to capture the characteristics of different change periods in the time series and extract the prediction results of different univariate time series; Compare the abnormality score between the predicted value and the actual observed value calculated for each variable, compare it with the preset abnormality score threshold, and determine whether an abnormality alarm is generated; Construct a multi-scale variable fusion time series network Transformer model, specifically: Construct a multi-scale variable fusion time series network Transformer model, including a GRU gating module and a multi-scale time series prediction module. In the GRU gating module, each univariate time series is selected as the main variable one by one, and the remaining univariate time series are used as auxiliary variables, and weighted fusion is performed through the GRU unit; For each time point, the main variable and the auxiliary variable are input into the GRU unit, and the GRU unit calculates a weight for each auxiliary variable, and fuses the weighted auxiliary variable with the main variable; Select humidity seasonal series separately , temperature seasonal series and seasonal series of exhaust gas concentration As the main variable, the remaining sequences are fused as auxiliary variables to obtain three fused sequences, namely, the fused sequence with temperature as the main variable , Fusion sequence with humidity as the main variable And the fusion sequence with exhaust gas concentration as the main variable ; The multi-scale time series prediction module is specifically: In the multi-scale time series prediction module, a multi-scale Transformer is used to obtain the seasonal pattern characteristics of each time series; Select the fusion sequence with temperature as the main variable Converted to patches of different scales, represented as ,in Indicates the length of the patch. Indicates the number of patches. represents the step length; The patch is passed through a trainable linear projection Mapped to dimension In the multi-scale Transformer latent space, a learnable position encoding is added to each patch , the position-encoded patch is represented as: ; Introducing a multi-scale attention mechanism, for an input patch sequence of length M, using parameters Controlling the sequence range that each attention head can observe and capturing diverse seasonal component patterns, the attention head in the multi-scale attention mechanism is expressed as: , , in, Indicates head, Indicates Locations, represents a function that extracts the context of a given position, represents the query vector, , represents the key vector, , represents a value vector, , represents the parameter matrix; A flattening layer and a linear head are used in the multi-scale time series forecasting module to obtain the forecast results of the fused series with temperature as the main variable. , ,in It indicates the linearized representation of the temperature prediction value; Select the fusion sequence with humidity as the main variable and the fusion sequence with exhaust gas concentration as the main variable As the main variable, the multi-scale variable fusion time series network Transformer model is used to perform multi-scale time series prediction to obtain the prediction results of the three time series of humidity, temperature and exhaust gas concentration. , and .

2. According to claim 1, a method for detecting anomalies in pig house environment based on multi-scale variable fusion time series is characterized in that: The multivariate time series corresponding to the multidimensional environmental parameters is preprocessed and decomposed into a univariate time series, specifically: For temperature variables, humidity variables and exhaust gas concentration variables, all parameter values ​​and corresponding timestamps are extracted to form temperature time series, humidity time series and exhaust gas concentration time series; Use the Hampel identifier to detect outliers in each time series. For each time series, traverse each data point , calculate the median of its front and back neighbors and absolute median difference Standardized score of , ,in represents a constant, Indicates the timestamp, Represents environment parameter variables; A standardized score threshold is preset. If the standardized score of a data point is greater than the preset standardized score threshold, the data point is considered an outlier; Use linear interpolation to fill in outliers and missing values ​​in the original data. For each position that needs to be filled , get the known data points before and after and , perform linear interpolation calculation based on the value of the known data point to obtain the filling value , expressed as: , in, Represents the number of data point location items.

3. According to claim 1, a method for detecting anomalies in pig house environment based on multi-scale variable fusion time series is characterized in that: The STL decomposition method is used for the disassembled univariate time series to extract trend components and seasonal components, and the seasonal components are used for model pre-training, specifically: The STL decomposition method is used to decompose the univariate time series to obtain seasonal components and trend components. The mask mechanism is used to mark the missing values ​​of the seasonal components, where the positions of the missing values ​​are 1 and the other positions are 0, which is expressed as: , in represents the seasonal component, Represents the mask vector; The MAE Transformer model is pre-trained using the seasonal components and the generated mask vectors. And the corresponding mask vector As input, predict the masked part based on the unmasked part through iterative learning; The MAE Transformer model is trained with the goal of minimizing the loss function, and the pre-trained model is used to predict the missing values ​​in the seasonal component to provide preset parameters for the multi-scale variable fusion time series network Transformer model.

4. The method for detecting anomaly in a pig house environment based on multi-scale variable fusion time series according to claim 1 is characterized in that: Compare the abnormality scores between the predicted values ​​and the actual observed values ​​calculated for each variable, and compare them with the preset abnormality score threshold to determine the generation of abnormality alerts, specifically: For each temperature variable, humidity variable, and exhaust gas concentration variable, calculate the abnormality score between the predicted value and the actual observed value. It represents the distance of the data point relative to the mean and standard deviation of the actual observation sequence in which it is located, expressed as: ,in, represents the current data point, represents the mean of the series, represents the standard deviation of the series; An abnormality score threshold is preset for the time series of the temperature variable, the humidity variable and the exhaust gas concentration variable. If the abnormality score is greater than the abnormality score threshold, an abnormality alarm is triggered.

5. A pig house environment anomaly detection system based on multi-scale variable fusion time series, characterized in that: Implementing the pig house environment anomaly detection method based on multi-scale variable fusion time series as described in any one of claims 1 to 4, the system comprises: an intelligent environment monitoring module, a prediction module, an alarm module and an intelligent environment control module; The intelligent environment monitoring module is used to monitor and collect key environmental parameters of the pig house environment in real time, including thermal environment data and exhaust gas concentration data, and store the collected data locally or in a cloud server, and display the environmental data in the pig house through a visual interface; The prediction module predicts the changing trend of key environmental parameters based on the multi-scale variable fusion time series network Transformer model, providing data basis for intelligent abnormal warning of pig house environment; The alarm module compares the predicted results of key environmental parameters with the actual observed values, detects anomalies through preset thresholds and statistical methods, generates alarm information based on the anomalies of key environmental parameters, and sends the alarm information using a preset method; The intelligent environmental control module generates an environmental control plan based on the alarm information of abnormal key environmental parameters, and adjusts the environmental parameters of the pig house according to the environmental control plan.

Citation Information

Patent Citations

  • Abnormality detection method based on time series data prediction

    CN118171214A