A beef cattle health anomaly detection method and system considering environmental factors
Patent Information
- Application Number
- CN202611502916.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-24
- Publication Date
- 2026-11-03
AI Technical Summary
Existing methods for detecting abnormal health in beef cattle are unable to distinguish between normal environmental responses and true health abnormalities when environmental changes occur, leading to inconsistent test results and misjudgments.
By recursively inferring the desired state of the environment through gradient boosting regression trees, and combining temporal convolutional networks and contrastive learning, a comparative sample set of source and target domains is constructed to generate a healthy state representation set. Deviations from the healthy state are filtered out and replaced with the desired state of the environment to identify abnormal indicator sequences and correct the healthy state representation set and normal health feature centers.
It improves the targeting and stability of abnormal beef cattle health detection, reduces the impact of environmental changes on detection results, and enhances the interpretability and localization ability of abnormality identification.
Smart Images

Figure CN123030936A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of beef cattle health monitoring technology, and in particular to a method and system for detecting abnormal health conditions in beef cattle that takes into account environmental factors. Background Technology
[0002] With the development of large-scale and digitalized beef cattle farming, beef cattle health monitoring is gradually shifting from manual inspections to continuous sensing and data analysis. Existing technologies typically utilize environmental parameters such as ambient temperature, relative humidity, and humidity index, as well as health indicators such as rumination duration, feed intake, activity level, body surface temperature, and respiratory rate, to characterize the physiological and behavioral states of beef cattle during continuous feeding. These technologies are combined with statistical analysis, machine learning, and time series modeling to establish discriminative relationships between normal and abnormal health states. Specifically, gradient boosting regression trees can be used to learn nonlinear relationships between multiple variables, temporal convolutional networks can be used to extract local and long-term variation features from continuous time series, contrastive learning can utilize the similarity relationships between samples to form feature representations, and domain-appropriate formula rules can be used to handle feature differences at different time stages or under different data distribution conditions. These technologies are increasingly being applied to livestock and poultry health monitoring and anomaly detection scenarios.
[0003] However, the rumination duration, feed intake, activity level, body surface temperature, and respiratory rate of beef cattle naturally fluctuate with changes in ambient temperature, relative humidity, and temperature-humidity index. Furthermore, beef cattle in the same rearing environment may exhibit similar environmental responses simultaneously. Existing methods for detecting health anomalies, if relying directly on absolute changes in health indicators or fixed characteristic boundaries formed by historical healthy samples, can easily misidentify normal changes explainable by environmental conditions as health anomalies. On the other hand, differences in data distribution between historical normal samples and the current testing stage can arise due to seasonal variations, changes in barn environment, and changes in the rearing stage, making existing normal health characteristic relationships unreliable in representing the normal health status under current environmental conditions. Therefore, environmentally induced normal health changes and actual individual abnormal changes can easily become mixed in the feature space, affecting the localization of abnormal health indicators and the consistency of continuous testing results. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides a method for detecting abnormal health in beef cattle that takes into account environmental factors, solving the problem that environmental changes cause a shift in health characteristics, making it difficult to distinguish between normal environmental responses and true health abnormalities in beef cattle.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0007] In a first aspect, the present invention provides a method for detecting health abnormalities in beef cattle that takes into account environmental factors, comprising,
[0008] The environmental parameters and health indicators of beef cattle are divided according to the sampling time sequence. The expected environmental state is recursively inferred by using a gradient boosting regression tree. The common environmental response is separated by combining the same state of the cattle herd, and a continuous health state window is generated.
[0009] The continuous health status window is divided into a historical source domain and a current target domain, and a source domain comparison sample set and a target domain comparison sample set are constructed by injecting trend anomalies and using time proximity relationships.
[0010] Temporal convolutional networks are used to extract temporal features from source domain and target domain comparison sample sets. Contrastive learning and gradient inversion are combined to constrain domain discrimination, thereby obtaining a health status representation set and normal health feature centers.
[0011] Based on the health status representation set, deviations from the health status are screened, the corresponding health indicators are replaced with the expected environmental status, and the time series features are re-extracted. The abnormal indicator sequence is determined based on the change in the feature center distance before and after the replacement.
[0012] Based on the abnormal indicator sequence, the normal windows for error judgment and the newly added normal windows are selected. The normal windows for error judgment are replaced according to the similarity of environmental parameters, and the health status representation set and normal health feature center are corrected to generate the abnormal health detection results of beef cattle.
[0013] As a preferred embodiment of the method for detecting abnormal health conditions in beef cattle that considers environmental factors according to the present invention, the step of using a gradient boosting regression tree to recursively deduce the desired environmental state specifically includes:
[0014] Environmental parameters and health indicators are arranged according to a unified sampling time. Adjacent sampling times are divided into continuous time windows. Gradient boosting regression trees of each health indicator are fitted using the initial health status, environmental status within the window, and environmental change process in the normal window confirmed by health status, to obtain a continuous health change sequence.
[0015] By sequentially connecting the health status at the previous sampling time with the continuous health change sequence according to the sampling order, the desired environmental state is obtained.
[0016] As a preferred embodiment of the method for detecting abnormal health in beef cattle considering environmental factors according to the present invention, the generation of a continuous health status window specifically includes:
[0017] By comparing the actual health status with the expected environmental status hourly, the differences in environmental response are obtained, and the median of the differences in environmental response of normal beef cattle in the same feeding environment during the same period is calculated to obtain the common environmental response of the herd.
[0018] By separating the common environmental response of the target beef cattle from the differences in environmental response, and arranging the remaining individual health changes in order of health indicators, a continuous health status window is obtained.
[0019] As a preferred embodiment of the method for detecting abnormal health conditions in beef cattle that considers environmental factors according to the present invention, the construction of the source domain comparison sample set and the target domain comparison sample set specifically includes:
[0020] Continuous health status windows with confirmed health status results are assigned to the historical source domain, while unconfirmed continuous health status windows corresponding to the current detection cycle and consecutive adjacent cycles are assigned to the current target domain.
[0021] Keeping the window length, the starting position of environmental correction and the correspondence of health indicators unchanged, the health changes at the back of the normal window in the source domain and the current window in the target domain continue to shift along the original direction of change to obtain the abnormal injection window;
[0022] A source domain confirmation window is selected as the baseline sample, another confirmation window is selected as the positive sample, and confirmation windows and abnormal injection windows are used as negative samples to form a source domain comparison sample set.
[0023] The current window of the target domain is selected as the baseline sample, the time-continuous adjacent windows are selected as positive samples, and the corresponding abnormal injection window is selected as the negative sample to form a target domain comparison sample set.
[0024] As a preferred embodiment of the method for detecting abnormal health in beef cattle considering environmental factors according to the present invention, the step of obtaining the health status representation set and the normal health feature center specifically includes:
[0025] A convolutional network with the same time step is used to extract the common change features of the source domain comparison sample set and the target domain comparison sample set along the sampling time sequence, so as to obtain the source domain health status representation and the target domain health status representation;
[0026] By using supervised contrastive learning, the feature distance between the source domain's confirmed normal windows is shortened and the feature distance between the source domain's confirmed abnormal windows and abnormal injection windows is expanded. By using self-supervised contrastive learning, the feature distance between the target domain's current window and its temporally adjacent windows is shortened and the feature distance between the target domain's current window and abnormal injection windows is expanded, thus obtaining the source domain's contrastive health status representation and the target domain's contrastive health status representation.
[0027] The source domain contrastive health state representation and the target domain contrastive health state representation are fed into the domain discriminator, and the temporal convolutional network is adjusted in reverse through the gradient inversion layer to obtain the health state representation set.
[0028] The health status representation of the source domain confirming normal windows is selected from the set of health status representations. The arithmetic mean is calculated dimension by dimension to form the normal health feature center. The square Euclidean distance between each source domain confirming normal window and the normal health feature center is calculated, and the maximum value is used as the distance boundary of the normal health feature region.
[0029] As a preferred embodiment of the method for detecting abnormal health conditions in beef cattle that considers environmental factors according to the present invention, the step of determining the abnormal indicator sequence specifically includes:
[0030] Calculate the feature center distance between the health status representation of the current target window and the normal health feature center in the current target domain. When the feature center distance is greater than the distance boundary of the normal health feature region, the corresponding current target window is determined as the health status window to be verified.
[0031] The actual health status of the window to be verified is replaced with the corresponding expected environmental state in the order of health indicators, while keeping the other health indicators and time positions unchanged, so as to obtain the replacement health status window corresponding to each health indicator.
[0032] Temporal convolutional networks are used to re-extract the temporal features of each replacement health state window to obtain the replacement health state representation. The feature center distance between the replacement health state representation and the normal health feature center is calculated to obtain the replacement feature center distance.
[0033] The distance reduction of each health indicator is obtained by subtracting the corresponding replacement feature center distance from the feature center distance of the window of the health status to be verified.
[0034] Health indicators are arranged from largest to smallest according to the distance reduction, and the actual health status and the expected environmental status are retained accordingly to obtain the abnormal indicator sequence.
[0035] As a preferred embodiment of the method for detecting abnormal health conditions in beef cattle that considers environmental factors according to the present invention, the steps of screening and judging normal windows and adding new normal windows specifically include:
[0036] From the current target window corresponding to the abnormal indicator sequence, the subsequent consecutive healthy state windows that are confirmed as normal healthy state are screened out to obtain the new normal window set;
[0037] Read the health status representation, normal health feature center, and distance boundary of the normal health feature region saved in the corresponding detection period when the health status confirmation result has not yet been obtained in the historical continuous health status window. When the feature center distance in the corresponding detection period is greater than the corresponding distance boundary and the subsequent health status confirmation result is normal health status, the historical continuous health status window is determined as the error-judged normal window, and the error-judged normal window set is obtained.
[0038] As a preferred embodiment of the method for detecting abnormal health conditions in beef cattle that considers environmental factors as described in this invention, the step of replacing the error-judgment window according to the similarity of environmental parameters specifically includes:
[0039] The number of windows in the newly added normal window set and the error-corrected normal window set is counted. When the number of newly added normal windows reaches the number of error-corrected normal windows, the differences in ambient temperature, relative humidity and temperature-humidity index corresponding to the error-corrected normal windows and the newly added normal windows are compared. The newly added normal windows corresponding to each error-corrected normal window are determined according to the similarity of the environmental parameters.
[0040] The corresponding error-detected normal windows are replaced sequentially with newly added normal windows that have not yet been replaced, while the remaining historical continuous healthy state windows are retained, to obtain the updated historical source domain.
[0041] As a preferred embodiment of the method for detecting abnormal health in beef cattle considering environmental factors according to the present invention, the modified health status representation set and the normal health feature center specifically include:
[0042] The source domain comparison sample set and target domain comparison sample set are reconstructed using the updated historical source domain and the current target domain. Then, temporal feature extraction, contrastive learning and gradient inversion domain discrimination are performed in sequence to obtain the corrected health status representation set and normal health feature center. The distance boundary of the normal health feature region is re-determined based on the square Euclidean distance between the normal window and the normal health feature center according to the updated historical source domain.
[0043] The current target window is selected based on the corrected health status representation set, the normal health feature center, and the distance boundary of the redefined normal health feature region. The corresponding health indicators are replaced one by one using the expected environmental state and the temporal features are re-extracted. The distance between the feature centers before and after the replacement is compared to obtain the updated abnormal indicator sequence.
[0044] When the distance reduction of the first health indicator in the updated abnormal indicator sequence is greater than 0, the first health indicator is identified as the main abnormal health indicator, and its actual health status and environmental expected status are retained.
[0045] When the distance reduction of the primary health indicator is not greater than 0, the corresponding current target window is retained as an abnormal window to be reviewed, and the beef cattle health abnormality detection result is generated.
[0046] Secondly, this invention provides a system for detecting abnormal health conditions in beef cattle that takes environmental factors into account, comprising,
[0047] The environmental correction module divides beef cattle environmental parameters and health indicators according to the sampling time sequence, uses gradient boosting regression trees to recursively deduce the expected environmental state, and combines the same state of the herd to separate common environmental responses and generate a continuous health state window.
[0048] The sample construction module divides the continuous health status window into a historical source domain and a current target domain, and constructs a source domain comparison sample set and a target domain comparison sample set through trend anomaly injection and time proximity relationship.
[0049] The feature learning module uses a temporal convolutional network to extract temporal features from the source domain comparison sample set and the target domain comparison sample set. It combines contrastive learning and gradient inversion to perform domain discrimination constraints, thereby obtaining a health status representation set and normal health feature centers.
[0050] The anomaly localization module filters out deviations from the healthy state based on the health state representation set, replaces the corresponding health indicators with the expected environmental state and re-extracts the temporal features, and determines the anomaly indicator sequence based on the change in the feature center distance before and after the replacement.
[0051] The sample update module filters out erroneous normal windows and adds new normal windows based on the abnormal indicator sequence, replaces erroneous normal windows according to the similarity of environmental parameters, and corrects the health status representation set and normal health feature center to generate the detection results of abnormal health in beef cattle.
[0052] The beneficial effects of this invention are as follows: By distinguishing between the desired environmental state, the herd's common environmental response, and individual health changes, normal physiological fluctuations in beef cattle caused by changes in environmental temperature, relative humidity, and temperature-humidity index are no longer directly treated as health abnormalities, thus improving the targeting of health abnormality identification in complex feeding environments; through comparative learning and domain discrimination constraints between the historical source domain and the current target domain, the health status representation deviation caused by seasonal changes, changes in the barn environment, and changes in the feeding stage is reduced, allowing the normal health feature relationship to adapt to the current detection conditions and reducing the impact of historical data distribution changes on the detection results; by evaluating the impact of different health indicators on abnormal states through the change in feature center distance after the replacement of the desired environmental state, the abnormality judgment can not only identify health status deviations, but also further distinguish the health indicators with more significant impact on abnormal states among rumination duration, feed intake, activity level, body surface temperature, and respiratory rate, improving the interpretability and localization ability of abnormal results; at the same time, by using newly added normal windows that are subsequently confirmed to be normal to correct the historical normal reference relationship, the normal health feature center can be continuously updated with the actual feeding environment, reducing misjudgments caused by long-term drift of normal states, thereby improving the consistency and stability of abnormal detection results during continuous health monitoring. Attached Figure Description
[0053] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 A flowchart for a method to detect abnormal health conditions in beef cattle that takes environmental factors into account.
[0055] Figure 2 A schematic diagram of the comparison samples between the source domain and the target domain is constructed.
[0056] Figure 3 A schematic diagram for learning health status characteristics and identifying abnormal indicators.
[0057] Figure 4 A schematic diagram is generated for historical source domain updates and health anomaly detection results. Detailed Implementation
[0058] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0059] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0060] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0061] Reference Figures 1-4 This is one embodiment of the present invention, which provides a method for detecting health abnormalities in beef cattle that takes into account environmental factors, including the following steps:
[0062] S1. Divide beef cattle environmental parameters and health indicators according to the sampling time sequence, use gradient boosting regression tree to recursively deduce the expected environmental state, and combine the same state of the cattle herd to separate the common environmental response and generate a continuous health state window.
[0063] S1.1. Establish the time correspondence between environmental parameters and health indicators according to a unified sampling time. Environmental parameters include ambient temperature, relative humidity, and temperature-humidity index. Ambient temperature, relative humidity, and temperature-humidity index are continuously recorded using environmental monitoring equipment deployed in the beef cattle feeding area. The temperature-humidity index retains the values synchronously output by the environmental monitoring equipment. Health indicators include rumination duration, feed intake, activity level, body surface temperature, and respiratory rate. Rumination duration is continuously recorded using an accelerometer worn by the beef cattle. Activity level is represented by the activity count output by the same accelerometer in each sampling interval. The activity count is obtained by accumulating the number of times the triaxial acceleration change exceeds the effective change threshold built into the device. Feed intake is recorded using an electronic feeding device with individual identification and weighing functions, recording the difference in feed quality between the beginning and end of each feeding session. Body surface temperature is recorded using an infrared thermal imaging device. Respiratory rate is recorded using a fixed camera device, recording the periodic undulations of the ventral side of the beef cattle in a static state, and determined according to the number of complete undulation cycles per unit time.
[0064] It should be noted that a 10-minute sampling period was used as the standard. The 10-minute sampling granularity is consistent with the recent continuous recording method of fattening beef cattle sensors. This method can maintain the temporal correspondence between environmental changes and health changes without changing the original meaning of health indicators. The rumination time within each 10-minute sampling interval is converted into minutes, and the feed intake corresponding to each feeding event is accumulated to the 10-minute feed intake. The activity level retains the activity count value output by the same accelerometer, the body surface temperature retains the Celsius temperature value, and the respiratory rate retains the number of breaths per minute. The ambient temperature, relative humidity, and temperature-humidity index are saved according to the same sampling time. This forms environmental parameters and health indicators with the same time base at each sampling time.
[0065] S1.2. Check the environmental parameters and health indicator records, and process duplicate, missing, and invalid records according to the sampling time. For multiple records of environmental temperature, relative humidity, temperature-humidity index, rumination duration, activity level, body surface temperature, and respiratory rate appearing at the same sampling time, retain the median of the valid records within the same sampling interval; for multiple feeding records within the same sampling interval, sum the feeding amounts of each feeding to form the feeding amount for the corresponding sampling interval; for records exceeding the range of the sampling equipment or with equipment malfunction status markers, treat the corresponding records as missing records, and do not directly delete health indicators with abnormal values but still within the effective range of the sampling equipment, so as to avoid prematurely excluding true health changes in subsequent processing.
[0066] When a single sampling time is missing but there are valid records at both the preceding and following sampling times, linear interpolation is performed using the adjacent valid records. When two consecutive sampling times are missing, gradient boosting regression tree fitting is not performed using the corresponding continuous time window.
[0067] After the record check is completed, every 6 consecutive 10-minute sampling intervals are divided into a 1-hour continuous time window. The continuous time windows are then filtered according to the health status confirmation results. Only the continuous time windows in which the corresponding beef cattle are confirmed to be in a normal health status throughout the entire continuous time window are retained as normal windows. Continuous time windows in which the health status is not confirmed or the health status confirmation result is not a normal health status are not included in the gradient boosting regression tree fitting, forming the normal windows used in subsequent gradient boosting regression trees.
[0068] It should be noted that the learning objects of the gradient boosting regression tree are limited by a complete normal window, so that the continuous health changes learned in subsequent learning correspond to the actual time relationship between environmental changes and health changes under normal health conditions, rather than treating the already confirmed abnormal health changes as the learning content of normal environmental response.
[0069] S1.3. Gradient boosting regression tree training records are established separately for each health indicator using a normal window. For any two adjacent sampling times, for a health indicator, the health status at the previous sampling time, the ambient temperature, relative humidity, and temperature-humidity index at the current sampling time are retained, and the changes in ambient temperature, relative humidity, and temperature-humidity index relative to the previous sampling time are calculated, forming 7 input data items. The change between the health status at the current sampling time and the health status at the previous sampling time is calculated as the output data for the corresponding training record. A 1-hour normal window forms 6 training records according to 6 consecutive sampling intervals. Rumination duration, feed intake, activity level, body surface temperature, and respiratory rate form their own training records, and output data are not mixed between different health indicators. According to the time sequence of the normal window, the first 80% of the training records are used for gradient boosting regression tree fitting, and the last 20% of the training records are used for validation, so that consecutive adjacent records do not appear simultaneously in the training and validation data due to random splitting.
[0070] For each health indicator, a gradient boosting regression tree is fitted. The gradient boosting regression tree uses squared error loss. First, an initial prediction is formed using the average value of the health indicator changes in the training records. Then, the residual between the actual health indicator changes in each training record and the current predicted health indicator changes is calculated. The first regression tree divides the residuals into nodes according to the 7 input data. Each node division selects input data and split positions that can reduce the squared error, and uses the average value of the training record residuals within the leaf node as the correction value for the corresponding leaf node. After completing a regression tree, the leaf node correction value is scaled with a learning rate of 0.1 to correct the previous round of health indicator change predictions. Then, the next regression tree is fitted for the residuals that are still not explained after correction, and so on for 100 boosting stages.
[0071] After each enhancement stage is completed, the squared error of the predicted change in the corresponding health indicator is calculated using validation data. The validation squared errors corresponding to 100 enhancement stages are compared, and the regression tree sequence that has been completed when the validation squared error is minimized is retained to form the gradient boosting regression tree for the corresponding health indicator. Gradient boosting regression trees for rumination duration, feed intake, activity level, body surface temperature, and respiratory rate are completed using the same process to obtain gradient boosting regression trees that can output the normal changes in health indicators for adjacent sampling times.
[0072] It should be noted that, compared to directly using a fixed historical health level as a normal reference, the method of fitting the changes in health indicators corresponding to adjacent environmental changes in round by round converts environmental changes into normal health changes on the same time scale, thus preserving the progressive relationship between environmental changes and health changes.
[0073] S1.4. The desired environmental state for the current continuous time window is recursively derived using gradient boosting regression trees for each health indicator. For the first sampling interval of the current continuous time window, the actual health state at the start of the continuous time window, the ambient temperature, relative humidity, and temperature-humidity index at the next sampling time, and the changes in ambient temperature, relative humidity, and temperature-humidity index between the two sampling times are selected and fed into the corresponding gradient boosting regression tree for the health indicator in the determined order of the seven data items. The seven data items are sequentially fed into the corresponding leaf nodes along the node segmentation paths determined by each regression tree. Each regression tree outputs a correction value for the leaf node, and the correction values are accumulated according to the boosting order determined during the training of the gradient boosting regression tree to obtain the change in health indicator corresponding to the first sampling interval. The change in health indicator corresponding to the first sampling interval is then connected with the actual health state at the start of the continuous time window to obtain the desired environmental state at the end of the first sampling interval.
[0074] For the second sampling interval, the expected environmental state at the end of the first sampling interval is used to replace the actual health state at the beginning of the continuous time window. At the same time, the changes in environmental temperature, relative humidity, temperature and humidity index, and three environmental parameters corresponding to the second sampling interval are used to enter the gradient boosting regression tree of the same health indicator to obtain the change in the health indicator corresponding to the second sampling interval. This change is then connected with the expected environmental state at the end of the first sampling interval to obtain the expected environmental state at the end of the second sampling interval. The remaining sampling intervals are processed continuously in the same time order until the 1-hour continuous time window is completed.
[0075] Rumination duration, feed intake, activity level, body surface temperature, and respiratory rate are all calculated using the same recursive process to obtain the desired environmental state for each sampling moment within the current continuous time window. Changes in each health indicator are correlated with their corresponding health states using the same units of measurement: changes in rumination duration are consistent with rumination duration in time units; changes in feed intake are consistent with feed intake in mass units; changes in activity level are expressed using dimensionless activity counts; changes in body surface temperature are consistent with body surface temperature in Celsius units; and changes in respiratory rate are consistent with respiratory rate in respiratory counts per minute units. This ensures that there is no mixing of units in the hourly recursion. The desired environmental state established at the previous sampling moment is used to calculate the next sampling moment, rather than recalculating from the actual health state at each sampling moment, thus maintaining a continuous recursive relationship for the desired environmental state within the continuous time window.
[0076] S1.5. Separate the common environmental response of target beef cattle using the desired environmental state. For each sampling time and each health indicator of the target beef cattle, the environmental response difference is obtained by subtracting the desired environmental state corresponding to the same sampling time from the actual health state. Other beef cattle in the same feeding environment that have been confirmed to be in normal health status are processed using the same time base and the same gradient boosting regression tree as in S1.1 to S1.4, and the same contemporaneous environmental response differences for each health indicator are also obtained. For the same sampling time and the same health indicator, the contemporaneous environmental response differences of other normal beef cattle are arranged in ascending order of value. When the number of records is odd, the environmental response difference in the middle position of the arrangement is selected. When the number of records is even, the average of the two middle environmental response differences is calculated to obtain the common environmental response of the herd. When there is no effective environmental response difference of other normal beef cattle at the same sampling time, the corresponding sampling time is not included in the formation of the continuous health state window to avoid using data lacking contemporaneous reference to replace the common environmental response of the herd.
[0077] For each health indicator of the target beef cattle, the environmental response difference is subtracted from the common environmental response of the herd at the same sampling time, and the remaining individual health changes are retained. The individual health changes at the same sampling time are arranged in a fixed order of rumination time, feed intake, activity level, body surface temperature and respiratory rate. Then, the individual health changes at each sampling time within 1 hour are arranged in the sampling time sequence, so that each row corresponds to a sampling time and each column corresponds to a health indicator, thus obtaining a continuous health status window.
[0078] S2. Divide the continuous health status window into the historical source domain and the current target domain, and construct the source domain comparison sample set and the target domain comparison sample set through trend anomaly injection and time proximity relationship.
[0079] S2.1. Treat the continuous health status window as a unified processing object. Each continuous health status window is 1 hour long and contains 6 sampling times according to the sampling order. At each sampling time, the individual health changes corresponding to rumination time, feed intake, activity level, body surface temperature and respiratory rate are stored in sequence. Therefore, each continuous health status window maintains a time sequence arrangement of 6 rows and 5 columns.
[0080] Check the health status confirmation result and the end sampling time corresponding to each continuous health status window. Continuous health status windows that have health status confirmation results before the current detection cycle are included in the historical source domain and marked as confirmed normal windows and confirmed abnormal windows according to the health status confirmation results. Starting from the continuous health status window corresponding to the current detection cycle, check the continuous health status windows that have not yet obtained health status confirmation results forward along the sampling time. Continuous health status windows that are consecutive in time and have not obtained health status confirmation results are included in the current target domain. The time range for ending the current target domain when encountering a continuous health status window that has already obtained health status confirmation results is determined.
[0081] The historical source domain must retain at least two confirmed normal windows and retain existing confirmed abnormal windows; the current target domain must retain at least one continuous health status window corresponding to the current detection period and one time-continuously adjacent window. If the historical source domain or the current target domain cannot satisfy the above window relationship, the subsequently formed continuous health status windows will continue to be retained, and trend anomaly injection will be performed only after the window relationship is satisfied.
[0082] It should be noted that the historical source domain and the current target domain are divided according to the health status confirmation results rather than the environmental parameter values. This allows the historical source domain to retain the health status distinction between the confirmation normal window and the confirmation abnormal window, while avoiding the use of the health status confirmation results of the current target domain, which have not yet been formed, to participate in the construction of subsequent comparison samples in advance.
[0083] S2.2. Trend anomaly injection is performed using the confirmed normal window in the historical source domain and the continuous health status window in the current target domain. For a continuous health status window to be injected with trend anomalies, the individual health changes in the first three sampling times of the continuous health status window remain unchanged, and the last three sampling times are used as the continuous subsequence for trend anomaly injection. The continuous subsequence corresponds exactly to the latter half of the 1-hour continuous health status window. Therefore, the length of the continuous health status window, the starting position of the environmental correction result, the number of sampling times, and the column positions of the five health indicators do not change.
[0084] The rumination duration, feed intake, activity level, body surface temperature, and respiratory rate were processed separately. First, the difference in health changes of three consecutive adjacent individuals between the first and fourth sampling times of the original continuous health status window was calculated, and the median of the three differences was taken. When the median was greater than 0, the original direction of change of the corresponding health indicator was determined to be the direction of increase; when the median was less than 0, the original direction of change of the corresponding health indicator was determined to be the direction of decrease.
[0085] When the median equals 0, the differences between all adjacent sampling times within the original continuous health status window are compared, and the difference with the largest absolute value among the non-zero differences is selected to determine the original direction of change. When all adjacent differences for a certain health indicator are 0, the corresponding health indicator remains unchanged, and other health indicators with non-zero directions of change are processed. Thus, the trend anomaly injection uses the health changes that have already occurred within the continuous health status window itself to determine the offset direction, without specifying a change direction unrelated to the health status of the beef cattle.
[0086] After determining the original direction of change, the median of the absolute values of the three consecutive adjacent differences is taken as the continuous offset of a single sampling interval. For the last three sampling times, 1, 2 and 3 continuous offsets are added sequentially along the original direction of change to the original individual health change value, so that the last three sampling times maintain the original sequential relationship and form a continuous offset.
[0087] When the median of the absolute values of the three consecutive adjacent differences of a certain health indicator is 0, the median of the absolute values of the non-zero differences at all adjacent sampling times is used as the continuous offset. After completing the check of 5 health indicators, as long as at least one health indicator has a non-zero change direction, an abnormal injection window with the same 6-row, 5-column structure as the original continuous health status window is obtained; when the offset value exceeds the effective range of the corresponding acquisition device, the offset value is limited to the boundary of the effective range of the corresponding acquisition device to avoid the generation of trend abnormal injection data that the acquisition device cannot obtain.
[0088] S2.3. Select the confirmed normal windows in the historical source domain one by one as the reference sample. Compare the time interval between other confirmed normal windows and the reference sample according to the sampling time. Select the confirmed normal window with the smallest time interval from the other confirmed normal windows as the positive sample. When the time interval between the reference sample and other confirmed normal windows is the same, select the confirmed normal window with the earlier sampling time as the positive sample, so as to ensure that each reference sample corresponds to a certain confirmed normal positive sample.
[0089] The first negative sample is selected from the confirmed anomaly window in the historical source domain with the smallest time interval between the end sampling time and the end sampling time of the benchmark sample. The second negative sample is selected from the anomaly injection window formed for the same benchmark sample. A supervised comparison triplet is formed by the benchmark sample, the positive sample and the first negative sample respectively. Another supervised comparison triplet is formed by the same benchmark sample, the same positive sample and the second negative sample.
[0090] Following the same process, the confirmed normal windows in the historical source domain are traversed, and the resulting supervised comparison triples are kept in sync with the original confirmed normal windows, confirmed abnormal windows, and abnormal injection windows at the sampling time, thus forming a source domain comparison sample set.
[0091] It should be noted that the source domain comparison sample set retains both types of negative samples: confirmation anomaly window and trend anomaly injection window. This allows for the simultaneous use of historical health status confirmation results and the relationship between anomalies formed according to continuous health changes, without needing to change the original health status confirmation results of the historical source domain.
[0092] S2.4. Select consecutive healthy state windows in the current target domain as benchmark samples according to the sampling time. Compare the time intervals between other consecutive healthy state windows in the current target domain and the benchmark samples. Select consecutive healthy state windows that are directly adjacent in time as positive samples. If the benchmark sample has both a preceding and a following consecutive adjacent window, select the consecutive adjacent window with the earlier sampling time as the positive sample. If the benchmark sample has only one consecutive adjacent window, use the existing consecutive adjacent window as the positive sample. Use the abnormal injection window formed for the same benchmark sample as the negative sample, so that the benchmark sample, the consecutively adjacent windows in time, and the abnormal injection window form a self-supervised comparison triplet.
[0093] Since there are no health status confirmation results in the current target domain, the target domain comparison triplet does not use health status confirmation results to select positive and negative samples. Instead, it utilizes the temporal continuity of the adjacency relationship to maintain that the baseline sample and the positive sample belong to a continuous health change process, and uses the same baseline sample to provide negative samples through an anomaly injection window formed by trend anomaly injection. After processing the continuous health status window in the current target domain according to the sampling time sequence, the formed self-supervised comparison triplet maintains the original arrangement relationship of 6 sampling times and 5 health indicators with the corresponding original continuous health status window, forming the target domain comparison sample set.
[0094] S2.5. For the source domain comparison sample set, check one by one whether the baseline sample and positive sample of each supervised comparison triplet both come from the historical source domain confirmed normal window, whether the first negative sample comes from the historical source domain confirmed abnormal window, and whether the second negative sample is the abnormal injection window formed by the corresponding baseline sample; if any correspondence is not satisfied, the corresponding supervised comparison triplet is not used, and the corresponding window is reselected.
[0095] For the target domain comparison sample set, check one by one whether the baseline sample and positive sample of each self-supervised comparison triplet belong to the current target domain and the sampling time is continuous, and whether the negative sample is formed by the same baseline sample through trend anomaly injection; if any correspondence is not satisfied, the corresponding self-supervised comparison triplet is not used, and the corresponding window is reselected.
[0096] The supervised comparison triples that have been verified maintain the historical source domain health status confirmation relationship, and the self-supervised comparison triples that have been verified maintain the current target domain time proximity relationship. All continuous health status windows continue to maintain a 6-row, 5-column data structure, resulting in the source domain comparison sample set and the target domain comparison sample set.
[0097] S3. Temporal convolutional networks are used to extract temporal features of the source domain comparison sample set and the target domain comparison sample set. By combining contrastive learning and gradient inversion, domain discrimination constraints are applied to obtain the health status representation set and normal health feature centers.
[0098] S3.1. A convolutional network at the same time is used to extract the common change features of the source domain comparison sample set and the target domain comparison sample set. Each continuous health state window in the source domain comparison sample set and the target domain comparison sample set is arranged according to 6 sampling times. The individual health changes corresponding to rumination duration, feed intake, activity level, body surface temperature and respiratory rate are used as 5 input channels respectively, so that each continuous health state window maintains 6 time positions and 5 health indicator positions.
[0099] The temporal convolutional network employs two layers of dilated causal convolutions to process six time points consecutively. Both layers have a kernel length of 3, with the first layer having a dilation rate of 1 and the second layer a dilation rate of 2. Zeros are padded at the beginning of each time series to maintain the number of time points after convolution processing at 6. Residual connections are used to add the result of the dilated causal convolution to the input result at the same time point. The temporal convolutional network has 5 output channels, matching the number of 5 input channels. Each output channel of the dilated causal convolution simultaneously receives values from the 5 input channels within their corresponding time range, thereby extracting features that co-exist with the sampling time sequence among health indicators.
[0100] The receptive field of the two layers of dilated causal convolution is determined according to the existing receptive field relationship of dilated causal convolution, and the expression is:
[0101] ;
[0102] in, This indicates the number of sampling times that the temporal convolutional network can cover. Indicates the kernel length. Indicates the expansion rate of the first layer. This indicates the expansion rate of the second layer.
[0103] Pick , , hour, Since the number of sampling times is greater than the 6 sampling times contained in the continuous health state window, the second layer of dilated causal convolution can cover the entire 1-hour continuous health state window at the end of the continuous health state window.
[0104] After completing two layers of dilated causal convolution, the 5-dimensional output value corresponding to the 6th sampling time is extracted as the health state representation of the entire continuous health state window. The source domain contrast sample set and the target domain contrast sample set are processed separately using a convolutional network at the same time to obtain the source domain health state representation and the target domain health state representation.
[0105] It should be noted that, compared to directly expanding a 6-row, 5-column continuous health status window and comparing the values of each health indicator, the two-layer dilated causal convolution restricts the feature propagation direction along the sampling sequence and uses a receptive field that can cover the complete continuous health status window to extract common change features. Therefore, the subsequent contrastive learning compares the health status representation formed by continuous health changes, rather than the discrete health indicators at a single sampling time.
[0106] S3.2. Supervised contrastive learning and self-supervised contrastive learning are performed using the source domain health state representation and the target domain health state representation, respectively. For each supervised contrastive triplet, a convolutional network at the same time is used to process the baseline sample, positive sample, and negative sample, respectively. The health state representation corresponding to the baseline sample is denoted as... The health status corresponding to the positive sample is denoted as The health status corresponding to the negative sample is denoted as In the source domain supervised comparison triplet, the baseline and positive samples both come from the confirmation window for normal status, while the negative samples come from the confirmation window for abnormal status or the abnormal injection window. Therefore, the health status confirmation result directly determines the supervised comparison relationship.
[0107] The squared Euclidean distance is used to compare the feature distance between two health state representations. The expression is:
[0108] ;
[0109] in, Indicates health status and health status The characteristic distance between them and These represent two 5-dimensional health states, respectively, indicating the state at the 5th dimension. The values of each dimension The dimension number representing the health status.
[0110] The supervised comparison loss is calculated based on the source domain supervised comparison triplet, and the expression is as follows:
[0111] ;
[0112] in, Indicates source domain supervised comparison loss. This indicates the number of source domain supervised comparison triples participating in the current computation. , and They represent the first The health status representations of the baseline samples, positive samples, and negative samples in each supervised comparison triplet; The feature distance interval, representing the source domain supervised contrastive loss, is used to define the minimum distance difference that the feature distance between the reference sample and the negative sample needs to maintain relative to the feature distance between the reference sample and the positive sample. In this embodiment, we take... ; 0 indicates the lower limit of the supervised comparison loss, and does not represent the health status label or feature distance judgment value.
[0113] when When the value is greater than 0, the corresponding calculation result is retained as the supervised comparison loss. When the value is less than or equal to 0, the supervision comparison loss of the corresponding supervision comparison triplet is set to 0.
[0114] When the loss of the source domain supervised contrast triplet is greater than 0, the parameters of the temporal convolutional network are adjusted inversely according to the supervised contrast loss. The health status representations and corresponding feature distances of the baseline sample, positive sample, and negative sample are recalculated, so that the feature distance between the baseline sample and the positive sample tends to decrease, and the feature distance between the baseline sample and the negative sample tends to increase. When the feature distances of the two classes meet the aforementioned source domain feature distance interval, the loss of the corresponding supervised contrast triplet is reduced to 0. Supervised contrast triplets are formed for the confirmation anomaly window and the anomaly injection window respectively. Therefore, the two classes of negative samples participate in the adjustment of the temporal convolutional network parameters one by one according to the same supervised contrast loss to obtain the source domain contrast health status representation.
[0115] For each self-supervised contrastive triplet, a temporal convolutional network is also used to process the current target domain benchmark sample, the temporally continuous adjacent window, and the anomaly injection window, and the corresponding health status is denoted as follows: , and Since there are no health status confirmation results in the current target domain, health status labels are not used to determine the comparison relationship. Instead, the established temporal proximity relationship is used, with consecutively adjacent windows in time as positive samples and abnormal injection windows formed by the same baseline sample as negative samples.
[0116] The expression for the target domain self-supervised contrastive loss is:
[0117] ;
[0118] in, This represents the self-supervised contrast loss in the target domain. This indicates the number of self-supervised comparison triples in the target domain participating in the current computation. Indicates the first The health status representation of the current target domain benchmark sample This represents the health status of consecutive adjacent windows at the corresponding time. This indicates the health status of the corresponding exception injection window; The feature distance interval, representing the self-supervised contrastive loss of the target domain, is used to limit the minimum difference in feature distance between the current target domain benchmark sample and the anomaly injection window relative to the feature distance between the current target domain benchmark sample and temporally adjacent windows. Since both the source domain contrastive health state representation and the target domain contrastive health state representation are mapped to the same feature space by the same temporal convolutional network, the self-supervised contrastive loss of the target domain and the supervised contrastive loss of the source domain in this embodiment use the same feature distance interval.
[0119] To clarify the feature distance scale, this embodiment does not perform additional normalization on the 5-dimensional health state representation output by the temporal convolutional network. The source domain, target domain, and replacement health state window are all generated by the temporal convolutional network with the same parameters, and the squared Euclidean distance is used for comparison. The feature distance interval of the source domain supervised contrastive loss adopts the same training and validation process for the three candidate values of 0.5, 1.0, and 1.5, and the candidate value with the smallest verification supervised contrastive loss is taken as the final value. In this embodiment, 1.0 is used. The same feature distance interval is used for the target domain self-supervised contrastive loss.
[0120] Adjusting the convolutional network at the same time according to the self-supervised contrastive loss of the target domain shortens the feature distance between the current target window and the temporally adjacent windows, while increasing the feature distance between the current target window and the abnormal injection window, thus obtaining a contrastive health status representation of the target domain.
[0121] It should be noted that source domain supervised contrastive learning calls upon the existing health status confirmation results of the historical source domain, while target domain self-supervised contrastive learning calls upon the existing temporal proximity relationships of the current target domain. The two contrastive relationships jointly constrain the convolutional network at the same time, and there is no need to manually supplement the health status label for the current target domain that has not yet obtained the health status confirmation result.
[0122] S3.3. The source domain health status representation and the target domain health status representation are fed into the same domain discriminator. The domain discriminator adopts a binary classification fully connected structure, mapping the 5-dimensional health status representation to a binary classification output, and using the Sigmoid function to convert the binary classification output into historical source domain probabilities; the domain label of the historical source domain health status representation is recorded as 1, and the domain label of the current target domain health status representation is recorded as 0.
[0123] The domain discriminant loss is calculated using binary cross-entropy, and its expression is:
[0124] ;
[0125] in, The domain indicates the loss. Indicates the first The health status is represented by the comparison of each source domain. Indicates the first The target domain is compared with the health status. This indicates the probability that the domain discriminator determines the domain to belong to the historical source domain. The domain discriminator determines the probability of belonging to the historical source domain.
[0126] In the domain discrimination loss calculation stage, the number of source domains and the number of target domains in the formula represent the number of source domain comparison health status representations and the number of target domain comparison health status representations that are actually input to the domain discriminator in the current domain discrimination calculation, respectively.
[0127] A gradient inversion layer is placed between the temporal convolutional network and the domain discriminator. When the source domain comparison health state representation and the target domain comparison health state representation pass forward through the gradient inversion layer, their values remain unchanged, and the domain discriminator adjusts its binary classification parameters according to the domain discrimination loss. When the domain discrimination loss is backpropagated to the temporal convolutional network, the gradient inversion layer changes the sign of the domain discrimination gradient, and then the temporal convolutional network is adjusted according to the domain discrimination gradient with the changed sign.
[0128] It should be noted that the domain discriminator improves the distinguishing ability between the historical source domain and the current target domain by reducing the domain discrimination loss, while the temporal convolutional network adjusts the health state representation in the opposite direction, reducing the feature differences between the source domain-contrast health state representation and the target domain-contrast health state representation that can directly distinguish the temporal origin. Supervised contrastive learning, self-supervised contrastive learning, and domain discrimination constraints are executed consecutively on the same temporal convolutional network. Therefore, health state confirmation relationships, temporal proximity relationships, and distributional differences between the historical source domain and the current target domain simultaneously participate in the adjustment of the health state representation.
[0129] S3.4. Arrange the supervised comparison triples according to the sampling time corresponding to the benchmark samples in the source domain comparison sample set. Use the first 80% of the supervised comparison triples for training the temporal convolutional network and the last 20% for validation. Since there are no health status confirmation results in the target domain comparison sample set, the entire target domain comparison sample set participates in self-supervised comparison learning and domain discrimination constraints. The health status that has not yet been confirmed in the current target domain is not used to form validation labels.
[0130] In each training epoch, the temporal convolutional network is first adjusted using supervised contrastive loss, then the same temporal convolutional network is adjusted using self-supervised contrastive loss, followed by adjustment of the domain discriminator using domain discriminant loss, and finally, the temporal convolutional network is adjusted in reverse using a gradient inversion layer. After each training epoch, the supervised contrastive loss is recalculated using validation-supervised contrastive triples, and the validation-supervised contrastive loss for the corresponding training epoch is recorded.
[0131] In this embodiment, 20 training epochs are executed, and the validation-supervision-contrast loss corresponding to the 20 training epochs is compared. The temporal convolutional network parameters corresponding to the minimum validation-supervision-contrast loss are retained. When the validation-supervision-contrast loss is the same in two training epochs, the temporal convolutional network parameters of the earliest training epoch are retained to avoid parameter changes that do not improve with continued training.
[0132] The original continuous health state windows of the historical source domain and the current target domain are reprocessed using a time-preserving convolutional network. The health state representations corresponding to each continuous health state window in the historical source domain and each continuous health state window in the current target domain are obtained respectively. The health state representations are saved according to the original window sampling time to obtain a health state representation set.
[0133] S3.5. Select the health status representation corresponding to the historical source domain's confirmed normal window from the health status representation set. Since the historical source domain has at least two confirmed normal windows, the normal health feature center is not determined using a single confirmed normal window. For each dimension of the 5-dimensional health status representation, calculate the arithmetic mean of the dimension values corresponding to all source domain confirmed normal windows, and then arrange the 5 arithmetic means in the original order of the 5 dimensions to form the normal health feature center.
[0134] The squared Euclidean distance between the health status representation of each source domain's confirmed normal window and the normal health feature center is recalculated using normal health feature centers, while preserving the feature distance relationship between the health status representation of the source domain's confirmed normal window and the normal health feature center. Supervised contrastive learning has already shortened the feature distance between confirmed normal windows; therefore, the normal health feature center is jointly determined by the health status representation of the confirmed normal window after supervised contrastive learning and domain discrimination constraints, and confirmed abnormal windows and abnormal injection windows are not used in the calculation of the normal health feature center.
[0135] It should be noted that, compared to directly using a single historical normal window as a normal reference, the normal health feature center simultaneously calls multiple normal window health status representations that have been confirmed to be healthy; compared to performing only source domain supervised learning, the gradient inversion layer has already implemented reverse constraints on the temporal source differences between the historical source domain and the current target domain before the normal health feature center is determined. Therefore, the normal health feature center and the current target domain health status representation are located in the feature space formed by the convolutional network at the same time.
[0136] S4. Based on the health status representation set, filter out deviations from the healthy status, replace the corresponding health indicators with the environmental expectation status, and re-extract the time series features. Determine the abnormal indicator sequence based on the change in the feature center distance before and after the replacement.
[0137] S4.1. The characteristic distance relationship between the normal health status representation of the source domain and the normal health feature center is confirmed by using the retained source domain. The square Euclidean distance corresponding to the normal window of each source domain is obtained respectively, and the maximum value is selected from the square Euclidean distances corresponding to all the normal windows of the source domain as the distance boundary of the normal health feature region.
[0138] The normal health feature region refers to the feature space range where the square Euclidean distance between the health status representation and the normal health feature center is no greater than the distance boundary. Therefore, the distance boundary of the normal health feature region is directly determined by the historical continuous health status window that has been confirmed to be in a normal health status, without setting a fixed value separately.
[0139] The feature center distance between the health status representation of the current target window and the normal health feature center in the current target domain is calculated using the squared Euclidean distance method. If the feature center distance of the current target window is not greater than the distance boundary of the normal health feature region, the current target window is retained within the normal health feature region and will not proceed to subsequent health indicator replacement processing; if the feature center distance of the current target window is greater than the distance boundary of the normal health feature region, the current target window and its corresponding feature center distance are retained as the health status window to be verified.
[0140] For multiple current target windows, the above comparisons are performed sequentially according to the sampling time in the current target domain. Each health status window to be verified retains the corresponding 6 sampling times, 5 health indicator positions, and the distance between feature centers before replacement, so as to maintain the time correspondence when subsequent health indicators are replaced one by one.
[0141] It should be noted that the distance boundaries of the normal health characteristic region are derived from the confirmed normal health status representation, rather than directly using fixed numerical limits for rumination duration, feed intake, activity level, body surface temperature, and respiratory rate. Therefore, the current target window is first filtered according to the health status representation after environmental correction, contrastive learning, and domain discrimination constraints.
[0142] S4.2. For a health status window to be verified, process each health indicator in a fixed order: rumination duration, feed intake, activity level, body surface temperature, and respiratory rate, replacing only one health indicator at a time. Based on the six sampling times included in the health status window to be verified, and the corresponding saved actual health status and environmental expected status for the same period, replace the actual health status of the selected health indicator at each of the six sampling times with the environmental expected status corresponding to the same sampling time. The actual health status and sampling time for the other four health indicators remain unchanged.
[0143] Since the continuous health status window used stores individual health changes, after replacing the actual health status, the individual health changes corresponding to the selected health indicators are re-determined according to the same environmental correction process. Specifically, the actual health status of the selected health indicators has been replaced with the expected environmental status at the same sampling time. The difference in the environmental response of the selected health indicators at the corresponding sampling time is the difference between the replaced health status and the expected environmental status, i.e., 0. Then, the difference between 0 and the already determined common environmental response of the cattle herd at the same sampling time is taken as the individual health change after the replacement of the selected health indicators. The remaining four health indicators continue to retain the original individual health changes in the health status window to be verified.
[0144] The individual health changes after rearranging and replacing the original positions of the 6 sampling times and 5 health indicators are used to obtain the replacement health status windows corresponding to the selected health indicators. After replacing rumination time, feed intake, activity level, body surface temperature and respiratory rate one by one, one health status window to be verified corresponds to 5 replacement health status windows. The 5 replacement health status windows have the same 6-row, 5-column data structure, and each replacement health status window has only one health indicator that is re-determined according to the expected environmental state to correspond to the individual health changes.
[0145] It should be noted that the health indicator replacement does not use historical average health status or health indicator values from other beef cattle. Instead, it uses the expected environmental status derived hourly for the same beef cattle, the same sampling time, and the same environmental changes. Compared to directly deleting a health indicator and then performing anomaly detection, the above process maintains the data dimension, sampling location, and other health indicators of the continuous health status window unchanged. Therefore, the change in the feature center distance before and after replacement can correspond to the replaced health indicator itself.
[0146] S4.3. The five replacement health status windows are fed into the same temporal convolutional network after preserving parameters, according to the replacement order of rumination duration, food intake, activity level, body surface temperature and respiratory rate. The temporal convolutional network is not retrained, nor are its two-layer dilated causal convolutional structure, kernel length, dilation rate, residual connection mode and input channel arrangement changed.
[0147] For each replacement health status window, the system sequentially enters two layers of dilated causal convolution at 6 sampling times. Rumination duration, food intake, activity level, body surface temperature, and respiratory rate continue to correspond to 5 input channels. After completing the two layers of dilated causal convolution, the 5-dimensional output value corresponding to the 6th sampling time is extracted to obtain the replacement health status representation of the corresponding health indicator.
[0148] Using the established squared Euclidean distance calculation method, the characteristic center distances between the five alternative health status representations and the normal health characteristic center were calculated respectively. The distances were saved in the order of replacement of rumination duration, feed intake, activity level, body surface temperature and respiratory rate, resulting in five replacement characteristic center distances.
[0149] The parameters of the temporal convolutional network and the normal health feature centers remain unchanged during the five health indicator replacement processes. Therefore, the distances of the feature centers after each replacement and the distances of the feature centers before the replacement are located in the same feature space and use the same distance scale, which allows for direct subsequent comparisons.
[0150] S4.4. For rumination duration, the difference between the feature center distance of the retained health status window to be verified and the feature center distance after rumination duration replacement is taken as the distance reduction amount corresponding to rumination duration; for feed intake, activity level, body surface temperature and respiratory rate, the same treatment is applied to obtain the distance reduction amount corresponding to each of the five health indicators.
[0151] When the distance reduction is greater than 0, it means that after replacing the health indicator with the corresponding environmental expected state, the distance between the replaced health indicator and the normal health characteristic center is less than the distance before replacement, and the corresponding health indicator recovers towards the normal health characteristic center; when the distance reduction is equal to 0, it means that the distance between the corresponding health indicator and the normal health characteristic center before and after replacement has not changed; when the distance reduction is less than 0, it means that the distance between the corresponding health indicator and the normal health characteristic center after replacement has increased, and the replacement of the environmental expected state of the corresponding health indicator has not caused the health state window to be verified to recover towards the normal health characteristic center.
[0152] The distance reduction is directly determined by the difference in feature center distance before and after the replacement of the same health state window to be verified. Therefore, the distance reduction of the five health indicators has the same feature distance scale. No additional health indicator contribution parameters are set, nor is the already formed feature space changed.
[0153] It should be noted that the distance reduction of a single health indicator is not the abnormal contribution value directly output by the temporal convolutional network, but rather the actual distance change obtained after completing the process of "replacing the expected environmental state—re-extracting temporal features—recalculating the feature center distance". Compared to directly using the internal parameters of the temporal convolutional network to interpret the importance of health indicators, the above processing uses the expected environmental state to perform a reproducible single-item replacement on the original continuous health state window, and then uses the same temporal convolutional network to test the degree of recovery of the health state representation, so that there is a clear operational correspondence between health indicators and abnormal state changes.
[0154] S4.5. Arrange the five distance reduction values corresponding to rumination duration, feed intake, activity level, body surface temperature, and respiratory rate in descending order of value, with health indicators with larger distance reduction values placed before those with smaller distance reduction values; when the distance reduction values of two health indicators are the same, determine the order according to the fixed order of rumination duration, feed intake, activity level, body surface temperature, and respiratory rate, so as to ensure that the same continuous health state window forms a unique arrangement result under the same health state representation set and normal health characteristic center.
[0155] Based on the health indicator ranking, the actual health status, expected environmental status, and distance reduction of each health indicator within the health status window to be verified are retained, forming an abnormal indicator sequence. The order of health indicators in the abnormal indicator sequence reflects the degree to which the health status representation recovers to the center of normal health characteristics after replacing the health indicator with the corresponding expected environmental status. Among them, the health indicator with the largest distance reduction is located at the beginning of the abnormal indicator sequence.
[0156] For health status windows to be verified where the distance reduction of all five health indicators is not greater than 0, an abnormal indicator sequence is still formed according to the distance reduction from largest to smallest. However, this abnormal indicator sequence is only used to retain the relative order of each health indicator. The health indicator at the top of the sequence is not directly identified as the main abnormal health indicator, and the corresponding health status window to be verified is marked as an abnormal window to be reviewed.
[0157] S5. Based on the abnormal indicator sequence, filter the error-judged normal window and add a new normal window, replace the error-judged normal window according to the similarity of environmental parameters, and correct the health status representation set and normal health feature center to generate the beef cattle health abnormality detection results.
[0158] S5.1. For the current target window that forms an abnormal indicator sequence, continue to save the subsequent health status confirmation results according to the beef cattle identifier and the end sampling time of the continuous health status window. Before subsequent health status confirmation results are formed, the abnormal indicator sequence and the corresponding current target window maintain the current target domain state and do not participate in the selection of new normal windows; when the subsequent health status confirmation results confirm that the corresponding current target window is in a normal health state, the corresponding current target window, along with the ambient temperature, relative humidity, temperature and humidity index, and the corresponding health status confirmation results, are retained to form a new normal window. Process the subsequent confirmed normal health status current target windows in the same way to obtain the set of new normal windows.
[0159] The process involves checking previously saved historical source domains for the newly added normal window selection. For each historical continuous health status window, the health status representation, normal health feature center, and distance boundary of the normal health feature region saved for the corresponding detection period before a health status confirmation result was obtained are read, and the feature center distance for the corresponding detection period is rechecked. A historical continuous health status window is designated as an error-corrected normal window if the feature center distance for the corresponding detection period is greater than the distance boundary of the normal health feature region for the corresponding detection period, and if subsequent health status confirmation results confirm a normal health status. If any condition is not met, the historical continuous health status window is not included in the error-corrected normal window set. This check is performed sequentially according to the end sampling time of each historical continuous health status window to obtain the error-corrected normal window set.
[0160] The newly added normal window set only saves normal windows obtained from subsequent confirmations of the current target window, while the error-detected normal window set is only obtained from historical continuous health status windows that have been saved before this filtering, thus avoiding the same continuous health status window from entering both the newly added normal window set and the error-detected normal window set at the same time.
[0161] It should be noted that a "correctly identified normal window" does not refer to an error in the health status confirmation result. Rather, it refers to a continuous health status window that, before any health status confirmation result was available, was located outside the normal health characteristic area based on its health status representation, but was subsequently confirmed to be in a normal health status by the health status confirmation result. Compared to directly appending all subsequently confirmed normal windows to the historical source domain, establishing a corresponding replacement relationship between the "correctly identified normal window" and the newly added normal window ensures that subsequent corrections to the historical source domain focus on normal health statuses that have already exhibited health status representation deviations.
[0162] S5.2. Count the number of consecutive healthy windows contained in the newly added normal window set and the error-checked normal window set respectively. When the number of newly added normal windows is less than the number of error-checked normal windows, keep the historical source domain unchanged before this screening, and continue to retain the newly added normal window set and the error-checked normal window set; as the current target window obtains a health status confirmation result, continue to add new normal window sets until the number of newly added normal windows reaches the number of error-checked normal windows. When the number of newly added normal windows is equal to or greater than the number of error-checked normal windows, start the process of determining the proximity of environmental parameters.
[0163] For each error-detected normal window and each newly added normal window, the corresponding ambient temperature, relative humidity, and temperature-humidity index are read from the environmental parameters according to the 6 sampling times contained in the window. The ambient temperature at each of the 6 sampling times is arranged in numerical order and the median is taken as the ambient temperature of the corresponding continuous healthy state window. The relative humidity and temperature-humidity index of the corresponding continuous healthy state window are obtained in the same way, so that each error-detected normal window and each newly added normal window corresponds to one ambient temperature, one relative humidity, and one temperature-humidity index.
[0164] Because the values of ambient temperature, relative humidity, and temperature-humidity index (THI) vary, before comparing the similarity of environmental parameters, the maximum and minimum values of ambient temperature, relative humidity, and THI are statistically analyzed in both the set of correctly identified windows and the set of newly added normal windows. For any correctly identified window and any newly added normal window, the absolute differences in ambient temperature, relative humidity, and THI are obtained. The absolute difference in ambient temperature is compared with the difference between the maximum and minimum ambient temperatures of all candidate windows to form the difference in ambient temperature within the range of 0 to 1. Relative humidity and THI are converted in the same way. When the maximum and minimum values of a certain environmental parameter are the same across all candidate windows, it indicates that there are no discernible differences in the corresponding environmental parameter among all candidate windows, and the difference in the corresponding environmental parameter is recorded as 0.
[0165] The sum of the differences in the converted ambient temperature, relative humidity, and temperature-humidity index is taken as the difference in environmental parameters between the error-judgment normal window and the newly added normal window. The smaller the difference in environmental parameters, the closer the environmental parameters of the two are.
[0166] It should be noted that the above comparison does not set fixed thresholds for ambient temperature, relative humidity, or temperature and humidity index. Instead, it uses a uniform numerical scale within the current window to be replaced. Therefore, the matching result will not be determined by any one of the environmental parameters due to the different numerical ranges of Celsius temperature, percentage, and temperature and humidity index.
[0167] S5.3. Arrange the error-correcting normal windows in order of their end sampling time. For the first error-correcting normal window after arrangement, compare the differences in environmental parameters between the calculated first error-correcting normal window and all newly added normal windows. Select the newly added normal window with the smallest difference in environmental parameters as the corresponding newly added normal window, and mark the corresponding newly added normal window as having participated in the replacement.
[0168] For the second correctly identified window after sorting, only the newly added normal windows that have not yet been replaced are compared, and the newly added normal window with the smallest difference in environmental parameters is selected. The remaining correctly identified windows are processed in the same way until each correctly identified window corresponds to one newly added normal window that has not yet been replaced. When two newly added normal windows that have not yet been replaced have the same difference in environmental parameters, the time interval between the end sampling time of the newly added normal window and the end sampling time of the correctly identified window is compared, and the newly added normal window with the smaller time interval is selected; if the time intervals are still the same, the newly added normal window with the earlier end sampling time is selected, thus forming a unique correspondence.
[0169] After establishing the mapping, the corresponding error-detected normal windows are deleted from the historical source domain. Newly added normal windows are written into the historical source domain according to their actual sampling time. Simultaneously, the health status confirmation results of the newly added normal windows, the continuous health status windows, and the corresponding ambient temperature, relative humidity, and temperature-humidity index are retained. All historical continuous health status windows that were not identified as error-detected normal windows are retained. These windows are then rearranged according to the end sampling time to obtain the updated historical source domain.
[0170] When the number of newly added normal windows exceeds the number of windows that were flagged as errors, the newly added normal windows that were not replaced after the one-to-one replacement was completed will remain in the set of newly added normal windows and will not participate in this historical source domain replacement.
[0171] It should be noted that, compared to directly replacing historical normal windows with newly added normal windows based on the latest sampling time, the proximity of environmental parameters means that the continuous health status windows before and after the replacement have similar environmental temperatures, relative humidity, and temperature-humidity index. Therefore, the locations where changes occur in the historical source domain are concentrated in the normal windows where the health status indicates that the results were inconsistent with the subsequent health status confirmations, rather than changing all normal healthy samples.
[0172] S5.4. After completing the historical source domain replacement, check the current target domain. Continuous health status windows that have obtained health status confirmation results are no longer retained in the current target domain. Only continuous health status windows that have not obtained health status confirmation results within the current detection period and consecutive adjacent periods are retained to form the current target domain used during retraining. This avoids the newly added normal windows that have been written into the updated historical source domain from participating in subsequent processing as the current target domain windows.
[0173] The updated historical source domain is used to reselect the normal and abnormal confirmation windows. The updated historical source domain normal confirmation windows and the current target domain continuous health status windows are processed according to the trend abnormal injection process. Supervised comparison triples and self-supervised comparison triples are re-formed to obtain the reconstructed source domain comparison sample set and target domain comparison sample set.
[0174] The reconstructed source domain contrast sample set and target domain contrast sample set continue to use the same temporal convolutional network structure, without changing the kernel length, dilation rate, residual connections, and the relationship of the five input channels in the two layers of dilated causal convolution. The supervised contrast loss continues to use the source domain supervised contrast loss and the source domain feature distance interval, and the self-supervised contrast loss continues to use the determined target domain self-supervised contrast loss and the target domain feature distance interval. The source domain contrast health status representation and the target domain contrast health status representation continue to enter the domain discriminator and are then reverse-adjusted by the gradient inversion layer.
[0175] The parameters were adjusted using the same training and validation data and 20 training epochs. The parameters of the temporal convolutional network were then preserved during the training epochs with the minimum comparison loss under validation supervision. The temporal convolutional network with preserved parameters was then used to reprocess the original continuous health state windows in the updated historical source domain and the current target domain to form a corrected health state representation set.
[0176] The updated historical source domain is selected from the corrected health status representation set to confirm the health status representation corresponding to the normal window. The arithmetic mean of the five dimensions is calculated and arranged in the original dimension order to redetermine the normal health feature center.
[0177] Compared to simply changing the normal health feature center while keeping the original health state representation unchanged, the updated historical source domain re-participates in supervised contrastive learning, self-supervised contrastive learning, and gradient inversion domain discrimination, so that the newly added normal window not only enters the calculation of the normal health feature center, but also participates in the feature relationship adjustment of the temporal convolutional network.
[0178] S5.5. Select the updated historical source domain from the set of corrected health status representations to confirm the health status representation corresponding to the normal window, calculate the square Euclidean distance between the confirmed normal window and the center of normal health features, and take the maximum square Euclidean distance as the distance boundary of the corrected normal health feature region.
[0179] Read the health status representation of the current target window in the corrected health status representation set, and calculate the feature center distance between the current target window's health status representation and the corrected normal health feature center. If the feature center distance of the current target window is greater than the boundary of the corrected normal health feature region, the current target window is redefined as the health status window to be verified.
[0180] For the newly determined health status windows to be verified, the actual health status of one health indicator was replaced with the corresponding environmental expected state each time, following the determined order of rumination duration, feed intake, activity level, body surface temperature and respiratory rate. The other four health indicators and six sampling times remained unchanged. The individual health changes of the replaced health indicators were reconstructed according to the environmental correction relationship, resulting in five replacement health status windows.
[0181] Five alternative health state windows are sequentially fed into a temporal convolutional network with preserved parameters to obtain five alternative health state representations. The distances between the five alternative health state representations and the corrected normal health feature centers are calculated. The difference between the distance of the feature center before replacement and the corresponding distance after replacement for the current target window is taken to form the distance reduction for rumination duration, feed intake, activity level, body surface temperature, and respiratory rate. The five health indicators are arranged in descending order of distance reduction. If the distance reduction is the same, the order is determined by a fixed sequence of rumination duration, feed intake, activity level, body surface temperature, and respiratory rate to obtain the updated abnormal indicator sequence.
[0182] When the distance reduction of the first health indicator in the updated abnormal indicator sequence is greater than 0, the first health indicator is identified as the primary abnormal health indicator. The actual health status of the primary abnormal health indicator at six sampling times is read from the current target window, along with the expected environmental status formed for the same six sampling times. The primary abnormal health indicator, actual health status, and expected environmental status are then saved accordingly. When the distance reduction of the first health indicator is not greater than 0, no health indicator is identified as the primary abnormal health indicator. The current target window and its abnormal indicator sequence are retained as an abnormal window to be reviewed, and together they generate the beef cattle health abnormality detection result.
[0183] This embodiment also provides a beef cattle health abnormality detection system that considers environmental factors, including: an environmental correction module, which divides beef cattle environmental parameters and health indicators according to the sampling time sequence, uses a gradient boosting regression tree to recursively deduce the expected environmental state, and combines the same state of the herd to separate common environmental responses and generate a continuous health state window;
[0184] The sample construction module divides the continuous health status window into a historical source domain and a current target domain, and constructs a source domain comparison sample set and a target domain comparison sample set through trend anomaly injection and time proximity relationship.
[0185] The feature learning module uses a temporal convolutional network to extract temporal features from the source domain comparison sample set and the target domain comparison sample set. It combines contrastive learning and gradient inversion to perform domain discrimination constraints, thereby obtaining a health status representation set and normal health feature centers.
[0186] The anomaly localization module filters out deviations from the healthy state based on the health state representation set, replaces the corresponding health indicators with the expected environmental state and re-extracts the temporal features, and determines the anomaly indicator sequence based on the change in the feature center distance before and after the replacement.
[0187] The sample update module filters out erroneous normal windows and adds new normal windows based on the abnormal indicator sequence, replaces erroneous normal windows according to the similarity of environmental parameters, and corrects the health status representation set and normal health feature center to generate the detection results of abnormal health in beef cattle.
[0188] In summary, this invention distinguishes between the desired environmental state, the herd's shared environmental response, and individual health changes. This prevents normal physiological fluctuations in beef cattle caused by changes in environmental temperature, relative humidity, and temperature-humidity index from being directly treated as health anomalies, thus improving the targeting of health anomaly detection in complex feeding environments. Through comparative learning and domain discrimination constraints between the historical source domain and the current target domain, it weakens the shifts in health status representation caused by seasonal changes, changes in barn environment, and changes in feeding stages, allowing normal health characteristic relationships to adapt to current detection conditions and reducing the impact of historical data distribution changes on detection results. By evaluating the impact of different health indicators on abnormal states through changes in the feature center distance after replacing the desired environmental state, anomaly detection can not only identify health state deviations but also further distinguish health indicators with more significant impact on abnormal states, such as rumination duration, feed intake, activity level, body surface temperature, and respiratory rate, improving the interpretability and localization ability of anomaly results. Simultaneously, by using newly added normal windows that are subsequently confirmed as normal to correct historical normal reference relationships, the normal health characteristic centers can be continuously updated with the actual feeding environment, reducing misjudgments caused by long-term drift of normal states, thereby improving the consistency and stability of anomaly detection results during continuous health monitoring.
[0189] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for detecting health abnormalities in beef cattle considering environmental factors, characterized in that: include, The environmental parameters and health indicators of beef cattle are divided according to the sampling time sequence. The expected environmental state is recursively inferred by using a gradient boosting regression tree. The common environmental response is separated by combining the same state of the cattle herd, and a continuous health state window is generated. The continuous health status window is divided into a historical source domain and a current target domain, and a source domain comparison sample set and a target domain comparison sample set are constructed by injecting trend anomalies and using time proximity relationships. Temporal convolutional networks are used to extract temporal features from source domain and target domain comparison sample sets. Contrastive learning and gradient inversion are combined to constrain domain discrimination, thereby obtaining a health status representation set and normal health feature centers. Based on the health status representation set, deviations from the health status are screened, the corresponding health indicators are replaced with the expected environmental status, and the time series features are re-extracted. The abnormal indicator sequence is determined based on the change in the feature center distance before and after the replacement. Based on the abnormal indicator sequence, the normal windows for error judgment and the newly added normal windows are selected. The normal windows for error judgment are replaced according to the similarity of environmental parameters, and the health status representation set and normal health feature center are corrected to generate the abnormal health detection results of beef cattle.
2. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 1, characterized in that: The method of using gradient boosting regression trees to recursively deduce the desired state of the environment specifically includes: Environmental parameters and health indicators are arranged according to a unified sampling time. Adjacent sampling times are divided into continuous time windows. Gradient boosting regression trees of each health indicator are fitted using the initial health status, environmental status within the window, and environmental change process in the normal window confirmed by health status, to obtain a continuous health change sequence. By sequentially connecting the health status at the previous sampling time with the continuous health change sequence according to the sampling order, the desired environmental state is obtained.
3. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 2, characterized in that: The generation of the continuous health status window specifically includes: By comparing the actual health status with the expected environmental status hourly, the differences in environmental response are obtained, and the median of the differences in environmental response of normal beef cattle in the same feeding environment during the same period is calculated to obtain the common environmental response of the herd. By separating the common environmental response of the target beef cattle from the differences in environmental response, and arranging the remaining individual health changes in order of health indicators, a continuous health status window is obtained.
4. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 3, characterized in that: The construction of the source domain comparison sample set and the target domain comparison sample set specifically includes: Continuous health status windows with confirmed health status results are assigned to the historical source domain, while unconfirmed continuous health status windows corresponding to the current detection cycle and consecutive adjacent cycles are assigned to the current target domain. Keeping the window length, the starting position of environmental correction and the correspondence of health indicators unchanged, the health changes at the back of the normal window in the source domain and the current window in the target domain continue to shift along the original direction of change to obtain the abnormal injection window; A source domain confirmation window is selected as the baseline sample, another confirmation window is selected as the positive sample, and confirmation windows and abnormal injection windows are used as negative samples to form a source domain comparison sample set. The current window of the target domain is selected as the baseline sample, the time-continuous adjacent windows are selected as positive samples, and the corresponding abnormal injection window is selected as the negative sample to form a target domain comparison sample set.
5. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 4, characterized in that: The acquisition of the health status representation set and normal health feature centers specifically includes: A convolutional network with the same time step is used to extract the common change features of the source domain comparison sample set and the target domain comparison sample set along the sampling time sequence, so as to obtain the source domain health status representation and the target domain health status representation; By using supervised contrastive learning, the feature distance between the source domain's confirmed normal windows is shortened and the feature distance between the source domain's confirmed abnormal windows and abnormal injection windows is expanded. By using self-supervised contrastive learning, the feature distance between the target domain's current window and its temporally adjacent windows is shortened and the feature distance between the target domain's current window and abnormal injection windows is expanded, thus obtaining the source domain's contrastive health status representation and the target domain's contrastive health status representation. The source domain contrastive health state representation and the target domain contrastive health state representation are fed into the domain discriminator, and the temporal convolutional network is adjusted in reverse through the gradient inversion layer to obtain the health state representation set. The health status representation of the source domain confirming normal windows is selected from the set of health status representations. The arithmetic mean is calculated dimension by dimension to form the normal health feature center. The square Euclidean distance between each source domain confirming normal window and the normal health feature center is calculated, and the maximum value is used as the distance boundary of the normal health feature region.
6. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 5, characterized in that: The determination of the abnormal indicator sequence specifically includes: Calculate the feature center distance between the health status representation of the current target window and the normal health feature center in the current target domain. When the feature center distance is greater than the distance boundary of the normal health feature region, the corresponding current target window is determined as the health status window to be verified. The actual health status of the window to be verified is replaced with the corresponding expected environmental state in the order of health indicators, while keeping the other health indicators and time positions unchanged, so as to obtain the replacement health status window corresponding to each health indicator. Temporal convolutional networks are used to re-extract the temporal features of each replacement health state window to obtain the replacement health state representation. The feature center distance between the replacement health state representation and the normal health feature center is calculated to obtain the replacement feature center distance. The distance reduction of each health indicator is obtained by subtracting the corresponding replacement feature center distance from the feature center distance of the window of the health status to be verified. Health indicators are arranged from largest to smallest according to the distance reduction, and the actual health status and the expected environmental status are retained accordingly to obtain the abnormal indicator sequence.
7. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 6, characterized in that: The filtering of error-corrected normal windows and the addition of new normal windows specifically include: From the current target window corresponding to the abnormal indicator sequence, the subsequent consecutive healthy state windows that are confirmed as normal healthy state are screened out to obtain the new normal window set; Read the health status representation, normal health feature center, and distance boundary of the normal health feature region saved in the corresponding detection period when the health status confirmation result has not yet been obtained in the historical continuous health status window. When the feature center distance in the corresponding detection period is greater than the corresponding distance boundary and the subsequent health status confirmation result is normal health status, the historical continuous health status window is determined as the error-judged normal window, and the error-judged normal window set is obtained.
8. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 7, characterized in that: The process of replacing the error-detecting normal window based on the similarity of environmental parameters specifically includes: The number of windows in the newly added normal window set and the error-corrected normal window set is counted. When the number of newly added normal windows reaches the number of error-corrected normal windows, the differences in ambient temperature, relative humidity and temperature-humidity index corresponding to the error-corrected normal windows and the newly added normal windows are compared. The newly added normal windows corresponding to each error-corrected normal window are determined according to the similarity of the environmental parameters. The corresponding error-detected normal windows are replaced sequentially with newly added normal windows that have not yet been replaced, while the remaining historical continuous healthy state windows are retained, to obtain the updated historical source domain.
9. The method for detecting abnormal health in beef cattle considering environmental factors as described in claim 8, characterized in that: The modified health status representation set and the normal health feature center specifically include: The source domain comparison sample set and target domain comparison sample set are reconstructed using the updated historical source domain and the current target domain. Then, temporal feature extraction, contrastive learning and gradient inversion domain discrimination are performed in sequence to obtain the corrected health status representation set and normal health feature center. The distance boundary of the normal health feature region is re-determined based on the square Euclidean distance between the normal window and the normal health feature center according to the updated historical source domain. The current target window is selected based on the corrected health status representation set, the normal health feature center, and the distance boundary of the redefined normal health feature region. The corresponding health indicators are replaced one by one using the expected environmental state and the temporal features are re-extracted. The distance between the feature centers before and after the replacement is compared to obtain the updated abnormal indicator sequence. When the distance reduction of the first health indicator in the updated abnormal indicator sequence is greater than 0, the first health indicator is identified as the main abnormal health indicator, and its actual health status and environmental expected status are retained. When the distance reduction of the primary health indicator is not greater than 0, the corresponding current target window is retained as an abnormal window to be reviewed, and the beef cattle health abnormality detection result is generated.
10. A system for detecting abnormal health conditions in beef cattle that considers environmental factors, based on the method for detecting abnormal health conditions in beef cattle that considers environmental factors according to any one of claims 1 to 9, characterized in that: include, The environmental correction module divides beef cattle environmental parameters and health indicators according to the sampling time sequence, uses gradient boosting regression trees to recursively deduce the expected environmental state, and combines the same state of the herd to separate common environmental responses and generate a continuous health state window. The sample construction module divides the continuous health status window into a historical source domain and a current target domain, and constructs a source domain comparison sample set and a target domain comparison sample set through trend anomaly injection and time proximity relationship. The feature learning module uses a temporal convolutional network to extract temporal features from the source domain comparison sample set and the target domain comparison sample set. It combines contrastive learning and gradient inversion to perform domain discrimination constraints, thereby obtaining a health status representation set and normal health feature centers. The anomaly localization module filters out deviations from the healthy state based on the health state representation set, replaces the corresponding health indicators with the expected environmental state and re-extracts the temporal features, and determines the anomaly indicator sequence based on the change in the feature center distance before and after the replacement. The sample update module filters out erroneous normal windows and adds new normal windows based on the abnormal indicator sequence, replaces erroneous normal windows according to the similarity of environmental parameters, and corrects the health status representation set and normal health feature center to generate the detection results of abnormal health in beef cattle.
