Cow Behavior Recognition and Prediction System
By using sensor technology and machine learning algorithms in cow behavior recognition and prediction systems, combined with Lagrangian conditional random field model and Viterbi algorithm, the problem of insufficient data acquisition and analysis capabilities of existing systems is solved, and the cows is realized Comprehensive monitoring and accurate prediction of behavior improve farm management efficiency and cow welfare.
Patent Information
- Application Number
- CN202410209740.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-26
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-02-26
AI Technical Summary
The existing dairy cow behavior recognition and prediction systems have limitations in terms of accuracy, real-timeness and applicability, and cannot fully collect dairy cow behavior data. The data analysis algorithm lacks in-depth understanding and modeling capabilities, making it difficult to provide accurate behavior predictions.
Using advanced sensor technology and machine learning algorithms, the Lagrangian conditional random field model and Viterbi algorithm are used to comprehensively collect multi-parameter behavior data, perform noise removal, feature extraction and state modeling, and realize accurate identification of dairy cow behavior and predict.
It provides real-time and accurate dairy cow behavior monitoring and management support, improves the production efficiency and welfare level of cattle herds, and promotes the intelligent and modern development of farm management.
Smart Images

Figure CN117975566B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of dairy cow breeding, and in particular relates to a dairy cow behavior recognition and prediction system. Background Art
[0002] With the development of modern agriculture, farm management is facing more and more challenges, one of which is how to effectively monitor and manage livestock behavior. In pasture management, accurately identifying and predicting the behavior of dairy cows is crucial to the health, production efficiency and welfare of the herd. Traditionally, farmers and veterinarians mainly rely on manual observation and experience to evaluate the behavior of the herd, which is time-consuming and laborious, and is easily affected by subjective factors, limiting the comprehensive understanding of the herd behavior.
[0003] In recent years, with the development of Internet of Things technology, sensor technology and machine learning algorithms, data-based smart agricultural management systems have begun to emerge. These systems can provide more accurate and real-time monitoring and management by collecting and analyzing livestock behavior data. However, the currently known dairy cow behavior recognition and prediction systems still have some limitations in terms of accuracy, real-time and applicability.
[0004] First, traditional sensor-based systems can only collect limited types of data, such as location and temperature, but cannot fully obtain detailed information about cow behavior. This leads to a lack of in-depth understanding of cow behavior, limiting the accuracy and practicality of the system.
[0005] Secondly, existing data analysis algorithms often lack the ability to deeply understand and model cow behavior patterns. Traditional statistical methods or simple machine learning algorithms may not be able to fully tap the potential patterns in behavioral data, resulting in low accuracy in identification and prediction.
[0006] In addition, for the prediction of cow behavior in the future, the existing system can usually only provide simple predictions based on historical data, and lacks the ability to effectively respond to complex scenarios. This makes it difficult for farmers to take effective measures to adjust the management of the herd in actual production.
[0007] Therefore, in order to overcome these problems, it is necessary to develop a system that can comprehensively collect cow behavior data, deeply understand behavior patterns, and make accurate predictions. This system needs to combine advanced sensor technology, data processing algorithms, and machine learning models to achieve comprehensive monitoring and intelligent management of cow behavior. Summary of the invention
[0008] The main purpose of the present invention is to provide a cow behavior recognition and prediction system. The present invention uses advanced sensor technology and machine learning algorithms to achieve comprehensive monitoring and prediction of cow behavior. By collecting multi-parameter behavior data and applying the Lagrangian conditional random field model, the present invention can accurately identify the behavior state of cows, and effectively identify and predict through the Viterbi algorithm, providing real-time and accurate decision support for farm managers. The present invention helps to improve the production efficiency and welfare level of cattle herds and promote the intelligent and modern development of farm management.
[0009] In order to solve the above technical problems, the present invention provides a cow behavior recognition and prediction system, which includes: a data acquisition unit, which is used to collect the behavior data of each cow at each moment, wherein the behavior data is a vector composed of multiple different types of cow behavior parameters, and the behavior data is subjected to noise removal to obtain a behavior sequence of each cow, wherein the elements of the behavior sequence are the behavior data after noise removal; a feature extraction unit, which performs feature extraction on each behavior data to obtain a feature sequence, wherein each element in the feature sequence is a feature vector of each behavior data; a data processing unit, which is used to define a state set of cow behavior, wherein each element in the state set is the state of the cow at each moment; a parameter set of a Lagrangian conditional random field is defined, wherein the parameter set includes a transformation The Lagrangian conditional random field is constructed by using the training data set and the maximum likelihood estimation to estimate the parameter set of the Lagrangian conditional random field. The recognition prediction unit uses the learned Lagrangian conditional random field to identify the most likely state corresponding to a given cow behavior sequence through a decoding algorithm as the recognition result. For the prediction of cow behavior at future moments, the learned Lagrangian conditional random field is used. Based on the given cow behavior sequence and the energy function of the learned Lagrangian conditional random field, the decoding algorithm is used to predict the state at the next moment as the prediction result.
[0010] Furthermore, the types of the behavior parameters include: position parameters, acceleration parameters, speed parameters, direction parameters, temperature parameters, heart rate parameters and posture parameters; the states in the behavior state set include at least: walking, standing still, grazing and running.
[0011] Furthermore, let the behavior sequence of each cow be X = x1, x2, ..., x N , where x i Represents the behavior data at the i-th moment; for the behavior data at the i-th moment, use the following formula to filter and denoise:
[0012]
[0013] Among them, m is the subscript, x i,m represents the mth element of the behavior data at the ith moment; J is the filter window size for filtering and denoising; is the mth element of the behavior data at the i-th moment after noise removal; the behavior data at the i-th moment after noise removal is obtained as
[0014] w m is the Gaussian weighting coefficient, calculated using the following formula:
[0015]
[0016] Furthermore, the following formula is used to calculate the behavior data after noise removal at the i-th moment: Extract features and obtain their corresponding feature vectors: Select multiple locally sensitive hash functions to extract the behavior data. Mapped into a high-dimensional space and retaining similarity; for each behavior data Apply the hash function to get its hash code. There are L hash functions, each of which is represented by h l (z), where l = 1, 2, ..., L; each hash function is mapped to a K-dimensional space, then each behavior data You will get a K×L hash code matrix H i ; For each hash code matrix H i , calculate its eigenvector in the direction of the mean value and the eigenvector in the direction of the standard deviation as the elements of the eigenvector to obtain the eigenvector.
[0017] Furthermore, the eigenvector in the mean direction Calculated using the following formula:
[0018]
[0019] Where log represents the natural logarithm, e is the base of the natural logarithm, and h il Represents the behavior data after noise removal at the i-th moment The hash code of the lth hash function;
[0020] Use the following formula to calculate the eigenvector in the standard deviation direction:
[0021]
[0022] Then, the following formula is used to obtain the behavior data after noise removal at the i-th moment: The eigenvector of:
[0023]
[0024] The feature vector of the behavior data at each moment is taken as an element in the feature sequence.
[0025] Furthermore, when the data processing unit constructs the state set S of each cow, it is assumed that M different states are defined, and the state type set is represented as S = s1, s2, ..., s M ; The i-th element S in the state set S i represents the state of the cow at the i-th moment; suppose the cow is in state s at time t i , at time t+1, it transfers to state s j The state transition probability is P(s t+1 =s j |s t =s i ) ; Integrate the transition probabilities into a state transition matrix T, where the element in the i-th row and j-th column represents the transition from state s i Transfer to state s j The size of the state transfer matrix is M×M. At the beginning, the state of the cow is unknown. The probability distribution of the initial state of the cow is defined as an initial state vector P0, where the i-th element represents the initial state of the cow as s i probability.
[0026] Furthermore, the data processing unit, when defining the parameter set of the Lagrangian conditional random field, defines the transfer characteristic parameter w included therein trans for:
[0027]
[0028] Among them, K is the transfer characteristic parameter w trans The dimension of is equal to the dimension of the high-dimensional space mapped by the hash function; the state characteristic parameter is w state :
[0029]
[0030] Among them, L is the dimension of the state characteristic parameter, and its value is equal to the number of hash functions; the Lagrange multiplier parameter is:
[0031] λ=[λ1,λ2,...,λ M ];
[0032] Among them, M is the dimension of the Lagrangian multiplier parameter, and its value is equal to the number of state types; the energy function of the Lagrangian conditional random field is expressed using the following formula:
[0033]
[0034] in, is the transition characteristic function, which is used to describe the conditional probability of transitioning from one state to another; is the state characteristic function, which is used to describe the characteristic vector observed under the current state at a given time t; g m (s) is the constraint function, which is calculated using the following formula:
[0035]
[0036] Furthermore, in the process of constructing the Lagrangian conditional random field and estimating the parameter set by using the maximum likelihood estimation, the data processing unit defines a log-likelihood function and maximizes the log-likelihood function through an optimization algorithm to obtain the parameter set, specifically including: the log-likelihood function is used to measure the degree of fit of the model under a given training data set. Assume that the training data set contains H samples, which is expressed as: where s (n) is a sequence of states of the nth sample, x (n) is the corresponding observed behavior sequence. The goal is to find the parameter set that maximizes the probability of the observed behavior sequence. According to the definition of conditional random fields, the likelihood function Expressed as the joint probability of all samples:
[0037]
[0038] By maximizing the likelihood function, we can obtain the estimated value of the parameter set, and take the logarithm of the likelihood function to obtain the log-likelihood function. for:
[0039]
[0040] Define x (n) About state sequence (n) The conditional probability of , in the conditional random field, this conditional probability is represented by the softmax function:
[0041]
[0042] Finally, the gradient descent optimization algorithm can be used to maximize the log-likelihood function to estimate the parameter set w trans 、w state and λ.
[0043] Furthermore, the decoding algorithm is a Viterbi algorithm.
[0044] The cow behavior recognition and prediction system of the present invention has the following beneficial effects: First, the present invention utilizes advanced sensor technology to comprehensively and accurately collect cow behavior data. Compared with the limitation that traditional systems can only collect limited types of data, the system of the present invention covers multiple parameters such as position, acceleration, speed, direction, temperature, heart rate, posture, etc., thereby providing more comprehensive data support for understanding cow behavior. This enables farm managers to have a more comprehensive understanding of the activities of cows, timely discover abnormal behaviors or health problems, and is conducive to improving the production efficiency and welfare level of the herd. Secondly, the present invention adopts advanced machine learning algorithms, such as Lagrangian conditional random fields, to analyze and model a large amount of collected cow behavior data. Compared with traditional statistical methods or simple machine learning algorithms, Lagrangian conditional random fields can better mine the potential laws in behavior data and achieve a deep understanding of cow behavior patterns. Through the model obtained by learning, the system can accurately identify the state of a given cow behavior sequence, providing more reliable data support for farm management. In addition, the present invention also proposes a decoding method based on the Viterbi algorithm, which can effectively decode the identified cow behavior state sequence. This allows farm managers to understand the behavior of the herd in a timely manner and take appropriate management measures. In addition, by using the learned model, the system can also predict the behavior of dairy cows in the future, providing more effective decision support for farm management. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0046] Figure 1 A schematic diagram of the system structure of a cow behavior recognition and prediction system provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The method of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments of the present invention.
[0048] Example 1: Reference Figure 1, a cow behavior recognition and prediction system, the system includes: a data acquisition unit, used to collect the behavior data of each cow at each moment, the behavior data is a vector composed of multiple different types of cow behavior parameters, the behavior data is subjected to noise removal to obtain a behavior sequence of each cow, and the elements of the behavior sequence are the behavior data after noise removal; a feature extraction unit, for extracting features from each behavior data to obtain a feature sequence, each element in the feature sequence is a feature vector of each behavior data; a data processing unit, for defining a state set of cow behavior, each element in the state set is the state of the cow at each moment; a parameter set of a Lagrangian conditional random field is defined, including a transfer feature parameter, a state parameter, and a state parameter. The state characteristic parameters and Lagrangian multiplier parameters are used to constrain the state transition and the correlation between states, and the Lagrangian conditional random field is constructed. The training data set is used to estimate the parameter set of the Lagrangian conditional random field by maximum likelihood estimation; the identification prediction unit, for a given cow behavior sequence, uses the learned Lagrangian conditional random field to identify its corresponding most likely state through a decoding algorithm as the identification result; for the prediction of cow behavior at future moments, the learned Lagrangian conditional random field is used, based on the given cow behavior sequence and the energy function of the learned Lagrangian conditional random field, a decoding algorithm is used to predict the state at the next moment as the prediction result.
[0049] Specifically, in the data processing unit, it is first necessary to define the state set of cow behavior. These states can be various behaviors that cows may exhibit, such as grazing, walking, resting, etc. It is very important to determine a reasonable set of states by observing and analyzing cow behavior, which directly affects the establishment of subsequent models and the accuracy of prediction results. Lagrangian conditional random field is a probabilistic graphical model used to describe the dependencies between various states in sequence data. In the data processing unit, a Lagrangian conditional random field model is constructed by defining the state set and the transition probability between states, as well as the correlation between state features. In the Lagrangian conditional random field, the transition probability between states describes the transition relationship between cow behavior at different times. These transition probabilities can be estimated based on actual data or set based on domain knowledge. For example, the probability that a cow transitions from a resting state to a grazing state may be higher than the probability that it transitions from a resting state to a walking state. In addition to the transition probability, the Lagrangian conditional random field also considers the correlation between state features. These features can be various attributes related to cow behavior, such as position, speed, posture, etc. By considering the correlation between these features, the model can more accurately capture the complexity of cow behavior. When constructing the Lagrangian conditional random field model, it is also necessary to introduce Lagrangian multiplier parameters to constrain state transitions and the correlation between states. These parameters can be estimated by methods such as maximum likelihood estimation, so that the model can better fit the training data and improve the accuracy of prediction. The data processing unit defines the state set and constructs the Lagrangian conditional random field model to transform the complex characteristics of cow behavior into a probabilistic graphical model, thus providing a basis for subsequent behavior recognition and prediction. This method based on the probabilistic graphical model can better capture the dependencies between cow behaviors and improve the predictive ability and robustness of the system.
[0050] Embodiment 2: The types of the behavior parameters include: position parameters, acceleration parameters, speed parameters, direction parameters, temperature parameters, heart rate parameters and posture parameters; the states in the behavior state set include at least: walking, standing still, grazing and running.
[0051] Specifically, the position parameter describes the position of the cow in space, usually expressed by longitude and latitude or position information in a coordinate system. The position parameter can reflect the activity range and regional preference of the cow. The acceleration parameter indicates the rate of change of the speed of the cow in a unit time. The acceleration parameter can reflect the movement state of the cow, such as acceleration, deceleration or uniform motion. The speed parameter describes the distance moved by the cow in a unit time. The speed parameter can reflect the movement speed of the cow and quantify the cow's walking, running and other behaviors. The direction parameter indicates the direction of the cow's movement, usually expressed by angle information. The direction parameter can help understand the cow's direction of travel and movement path. The temperature parameter records the temperature of the cow's surrounding environment. The temperature parameter can reflect the comfort of the cow's environment and has a certain indicative effect on the cow's behavior. The heart rate parameter records the changes in the cow's heart rate. The heart rate parameter can reflect the cow's physiological state, such as anxiety, excitement or calmness. The posture parameter describes the cow's body posture, such as standing, lying or prone. The posture parameter can reflect the cow's resting state and comfort.
[0052] The states in the behavior state set include at least: Walking: the state of the cow in the process of moving, usually accompanied by changes in position parameters, acceleration parameters and speed parameters. Stillness: the state of the cow stopping or resting, usually accompanied by the stability of position parameters and changes in heart rate parameters. Grazing: the state of the cow eating grass, usually accompanied by changes in posture parameters and the influence of temperature parameters. Running: the state of the cow moving at a faster speed, usually accompanied by significant changes in acceleration parameters and speed parameters, and an increase in heart rate parameters.
[0053] Example 3: Assume that the behavior sequence of each cow is X=x1, x2, ..., x N , where x i Represents the behavior data at the i-th moment; for the behavior data at the i-th moment, use the following formula to filter and denoise:
[0054]
[0055] Among them, m is the subscript, x i,m represents the mth element of the behavior data at the ith moment; J is the filter window size for filtering and denoising; is the mth element of the behavior data at the i-th moment after noise removal; the behavior data at the i-th moment after noise removal is obtained as w m is the Gaussian weighting coefficient, calculated using the following formula:
[0056]
[0057] Specifically, the weighted moving average method is used in the formula. By weighted averaging the data in the window, the data closer to the current moment has a higher weight, while the data farther from the current moment has a lower weight. This weighting method effectively suppresses the influence of noise, making the denoised data smoother and more stable. The size of the filter window J determines the degree of smoothing. A larger window can smooth the data in a longer period of time, making the changes in the cow behavior sequence more stable. This is very effective in removing instantaneous fluctuations and sudden noise in the behavior data, making the data more readable and analyzable. Although the filtering process will smooth the data, the use of Gaussian weighting coefficients makes the weighted averaging process more flexible and accurate, and can effectively retain the important features of the signal. Especially for relatively gentle signal changes, the filtered data can more realistically reflect the behavioral characteristics of the cow. Removing noise and smoothing data can improve the quality and reliability of cow behavior data, so that subsequent behavior recognition and prediction algorithms can more accurately analyze and judge the behavior of cows. This helps farmers better understand the status of cows, detect abnormal situations in time, and make management adjustments.
[0058] X=x1,x2,...,x N Here we define the behavior sequence of the cow, where x i represents the behavior data at the i-th moment, and N is the length of the sequence. J is the filter window size for filtering and denoising, which is used to determine the filter window size and affects the denoising effect. A larger J can smooth the data in a longer period of time, but it may also cause signal delay. m is the Gaussian weighting coefficient, which is used to weight the data in the window according to the formula Where (mi) represents the distance between the current moment and the moment in the window, and σ is the standard deviation of the Gaussian distribution. This coefficient makes the data closer to the current moment have a higher weight, while the data farther from the current moment has a lower weight, so as to remove noise more effectively. is the mth element of the behavior data at the i-th moment after filtering and denoising. By taking a weighted average of the data in the window, an estimated value of the behavior data at the current moment after denoising is obtained. is the behavior data at the i-th moment after noise removal, For all sets of m, this sequence will be used as denoised behavior data for subsequent feature extraction and behavior recognition.
[0059] Example 4: Use the following formula to calculate the behavior data after noise removal at the i-th moment Extract features and obtain their corresponding feature vectors: Select multiple locally sensitive hash functions to extract the behavior data. Mapped into a high-dimensional space and retaining similarity; for each behavior data Apply the hash function to get its hash code. There are L hash functions, each of which is represented by h l (x), where l = 1, 2, ..., L; each hash function is mapped to a K-dimensional space, then each behavior data You will get a K×L hash code matrix H i ; For each hash code matrix H i , calculate its eigenvector in the direction of the mean value and the eigenvector in the direction of the standard deviation as the elements of the eigenvector to obtain the eigenvector.
[0060] Specifically, a locality-sensitive hash function is a function that maps similar data to the same hash code. In this embodiment, multiple locality-sensitive hash functions are selected to increase the diversity of hash codes and improve the robustness and reliability of features. l (x) represents the lth hash function, which is used to convert the behavior data Mapped into high-dimensional space. Through the hash function, the behavior data is mapped into K-dimensional space. For each behavior data Apply L hash functions to obtain their hash codes, forming a K×L hash code matrix H i This matrix reflects the mapping results of behavior data under multiple hash functions, which can be understood as multiple feature expressions of behavior data. For each hash code matrix H i , calculate its eigenvectors in the direction of the mean and standard deviation as the elements of the eigenvector. The purpose of this is to capture the distribution characteristics of behavioral data in high-dimensional space, that is, to reflect the center and dispersion of the data.
[0061] A locality-sensitive hash function is a function that can map similar data to the same hash code. The purpose of selecting multiple locality-sensitive hash functions is to increase the diversity of features and improve the robustness and reliability of features. Doing so helps to retain the similarity information of the original data, so that the subsequent feature vectors can better reflect the relationship between the cow behavior data. The hash function maps the original behavior data into a high-dimensional space, making the data more distinguishable and separable. Using multiple hash functions can improve the diversity and expressiveness of the mapped data and better capture the local characteristics of the data. For each behavior data, the hash codes obtained after applying multiple hash functions form a hash code matrix. This matrix reflects the mapping results of the behavior data under different hash functions and provides a variety of different feature representations. In this way, the behavior data can be expressed and described from different angles. For each hash code matrix, its eigenvectors in the mean and standard deviation directions are calculated as the elements of the eigenvector. These eigenvectors can reflect the distribution of the behavior data in the high-dimensional space, that is, the central position and dispersion of the data. Such eigenvectors can more comprehensively describe the characteristics of the behavior data and provide richer information for subsequent behavior recognition and prediction.
[0062] Example 5: Eigenvectors in the mean direction Calculated using the following formula:
[0063]
[0064] Where log represents the natural logarithm, e is the base of the natural logarithm, and h il Represents the behavior data after noise removal at the i-th moment The hash code of the lth hash function;
[0065] The eigenvector in the direction of the mean value can help understand the overall trend in the data set. By calculating the mean of the hash code, the center position of the behavioral data in the high-dimensional space can be obtained, that is, the average distribution of the data set. This helps to understand the overall characteristics of the data, such as the average behavior pattern or behavioral tendency of cows. Calculating the mean value can effectively reduce the impact of noise in the data. Noise is usually random. By averaging the data, the interference of noise can be reduced, making the data more stable and reliable. The eigenvector in the direction of the mean value provides a description of the center position of the data set, which makes it easier to compare different data sets. By comparing the eigenvectors, the similarities or differences between different data sets can be quantified, and a deeper analysis and understanding can be carried out.
[0066] First, the hash code obtained by each hash function is processed and the average value of each hash code is calculated. This process is similar to aggregating the data set, and the average features corresponding to each hash function are obtained. The average of the average features obtained by all hash functions is averaged to obtain the average value in the entire feature space. This mean can be regarded as the center position of the data set, that is, the average distribution of the data set. The feature vector in the direction of the average value is composed of the average features obtained by all hash functions. Each element represents the average distribution of the data set in the feature space, reflecting the overall trend and characteristics of the data set.
[0067] Use the following formula to calculate the eigenvector in the standard deviation direction:
[0068]
[0069] The eigenvectors in the direction of the standard deviation can help understand the dispersion of the data in high-dimensional space. By calculating the sum of the squares of the differences between the hash code and the eigenvectors in the direction of the mean, and then taking the square root to get the standard deviation, the eigenvectors in the direction of the standard deviation of the data set can be obtained. This helps to understand the fluctuations of the data in different dimensions, that is, the dispersion of the data points relative to the mean. The eigenvectors in the direction of the standard deviation provide a quantitative description of the variability of the data set. By calculating the standard deviation, the dispersion between the data points can be assessed, that is, the average distance of the data points relative to the mean. This helps to understand the distribution of the data and identify the variability and anomalies in the data. The eigenvectors in the direction of the standard deviation can be used for anomaly detection. A larger standard deviation may mean that the data points are more different and there is a higher possibility of outliers. By analyzing the eigenvectors in the direction of the standard deviation, abnormal patterns and outliers in the data can be identified.
[0070] Calculate the sum of squares of the difference between the hash code and the eigenvector in the direction of the mean: First, process each hash code and calculate the sum of squares of the difference between the hash code and the eigenvector in the direction of the mean. This process can be used to measure the degree of dispersion of data points relative to the mean, that is, the fluctuation of data points in different dimensions. Sum the sum of squares of the differences of all hash codes and take the square root to get the standard deviation. This step is to get the standard deviation of the data set, that is, the average distance of the data points relative to the mean. The eigenvector in the standard deviation direction is composed of standard deviations. Each element represents the standard deviation of the data set in different dimensions, that is, the degree of fluctuation of the data in different dimensions.
[0071] Then, the following formula is used to obtain the behavior data after noise removal at the i-th moment: The eigenvector of:
[0072]
[0073] The feature vector of the behavior data at each moment is taken as an element in the feature sequence.
[0074] Example 6: When the data processing unit constructs the state set S of each cow, it is assumed that M different states are defined, and the state type set is represented by S = s1, s2, ..., s M ; The i-th element S in the state set S i represents the state of the cow at the i-th moment; suppose the cow is in state s at time t i , at time t+1, it transfers to state s j The state transition probability is P(s t+1 =s j |s t =s i ) ; Integrate the transition probabilities into a state transition matrix T, where the element in the i-th row and j-th column represents the transition from state s i Transfer to state s j The size of the state transfer matrix is M×M. At the beginning, the state of the cow is unknown. The probability distribution of the initial state of the cow is defined as an initial state vector P0, where the i-th element represents the initial state of the cow as s i probability.
[0075] Specifically, define a state set S: define all possible states that a cow may be in, such as walking, still, grazing, running, etc. The purpose of this is to classify and label the cow's behavior so that the system can understand and analyze the different behaviors of the cow. The definition of the state set provides the system with a basis for behavior classification. By dividing the cow's behavior into different states, the system can more accurately identify and understand the cow's behavior patterns, providing a basis for subsequent behavior prediction and management. Calculate the state transition probability P(s t+1 =s j ∣s t =s i ): indicates that the cow is in a certain state s i At the next moment, the cow transfers to state s jprobability. Such probability information can be used to predict changes in cow behavior. The state transition probability provides the system with an understanding of the evolution of cow behavior. By analyzing the state transition probability obtained from historical data, the system can infer the dynamic change law of cow behavior, thereby more accurately predicting the future behavioral state of cows. Define the initial state probability distribution P0: define the probability distribution of cows in various states at the beginning. Such a definition provides the system with an understanding of the starting state of cow behavior. The initial state probability distribution provides the system with preset information on the starting state of cow behavior. By defining the initial state probability distribution, the system can make a preliminary inference and prediction of the behavioral state of cows at the beginning. The role of Example 6 is to establish a state model. By defining the state set, state transition probability and initial state probability distribution, the system can more deeply understand and analyze the behavioral characteristics of cows. This provides the system with the ability to recognize cow behavior, so that the system can more accurately identify and predict the behavioral state of cows, thereby realizing the refinement and intelligence of cow management.
[0076] Embodiment 7: When defining the parameter set of the Lagrangian conditional random field, the data processing unit defines the transfer characteristic parameter w included therein trans for:
[0077]
[0078] Among them, K is the transfer characteristic parameter w trans The dimension of is equal to the dimension of the high-dimensional space mapped by the hash function; the state characteristic parameter is w state :
[0079]
[0080] Among them, L is the dimension of the state characteristic parameter, and its value is equal to the number of hash functions; the Lagrange multiplier parameter is:
[0081] λ=[λ1,λ2,...,λ M ];
[0082] Among them, M is the dimension of the Lagrangian multiplier parameter, and its value is equal to the number of state types; the energy function of the Lagrangian conditional random field is expressed using the following formula:
[0083]
[0084] in, is the transition characteristic function, which is used to describe the conditional probability of transitioning from one state to another; is the state characteristic function, which is used to describe the characteristic vector observed under the current state at a given time t; g m(s) is the constraint function, which is calculated using the following formula:
[0085]
[0086] Specifically, the Lagrangian conditional random field defined in Example 7 is a powerful tool for modeling the complex relationships of dairy cow behavior. In modern animal husbandry, accurate understanding and prediction of dairy cow behavior is crucial to help farmers improve the production efficiency and health of dairy cows. The role of this model goes far beyond simple data collection and analysis, but is to gain a deeper understanding of the dynamic laws behind dairy cow behavior in order to better manage and care for dairy cows.
[0087] Transfer characteristic parameter w trans and state characteristic parameter w state They describe the transition probability between states and the influence of observation features on states respectively. The setting of these parameters is based on a combination of in-depth understanding of cow behavior and empirical knowledge. The values of these parameters can be adjusted to adapt to different environments and situations. The Lagrange multiplier parameter λ is used to constrain the state transition and the correlation between states to ensure the stability and reliability of the model. These parameters together constitute the basic framework of the model, providing flexibility and adjustability for the model. Energy function E(s, x; w trans , w state ,λ) comprehensively considers the influence of transfer characteristics, state characteristics and constraints on the model, and is used to evaluate the probability of a given state sequence and feature vector sequence. The design of the energy function aims to make the model fit the given data as well as possible, thereby improving the accuracy and predictive ability of the model. By optimizing and adjusting the energy function, the model can be better adapted to the actual situation, thereby improving the accuracy and reliability of the recognition and prediction of dairy cow behavior. The Lagrangian conditional random field model defined in Example 7 provides a powerful tool that can help to deeply understand and analyze the complex relationship of dairy cow behavior. By optimizing and adjusting the parameters and energy functions, the behavioral state of dairy cows can be more accurately identified and predicted, thereby providing farmers with better methods for managing and caring for dairy cows. The application of this model will bring more opportunities and challenges to modern animal husbandry, and help farmers improve the production efficiency and health of dairy cows.
[0088] Transfer feature section: It means summing all the time instants t, and N is the length of the sequence.
[0089] Indicates that for each time t, the state transition characteristic function is calculated The weighted sum of is the corresponding transition characteristic parameter. This part is used to measure the transition between states at adjacent moments. Each transition characteristic function describes the conditional probability of going from one state to another, and the transition characteristic parameter It represents the weight of different transfer features and affects the probability of state transition.
[0090] Status characteristics section: Indicates that for each time t, the state characteristic function φstate is calculated l (s t , vt), where is the corresponding state characteristic parameter. This part is used to consider the influence of observation characteristics on the state. The state characteristic function describes the relationship between the state and observation characteristics at a given moment, and the state characteristic parameter It represents the weight of different state features and affects the influence of the feature vector on the state.
[0091] Constraints section: For all constraint functions g m The weighted sum of (s), where λ m is the corresponding Lagrange multiplier parameter. This part is used to constrain the legitimacy of the state sequence and the constraint function g m (s) describes the constraints that the state sequence s must satisfy, and the Lagrange multiplier parameter λ m It indicates the importance of different constraints.
[0092] Embodiment 8: In the process of constructing a Lagrangian conditional random field and estimating a parameter set by maximum likelihood estimation, the data processing unit defines a log-likelihood function and maximizes the log-likelihood function through an optimization algorithm to obtain a parameter set, specifically including: the log-likelihood function is used to measure the degree of fit of the model under a given training data set. Assume that the training data set contains H samples, which are expressed as: where s (n) is a sequence of states of the nth sample, x (n) is the corresponding observed behavior sequence. The goal is to find the parameter set that maximizes the probability of the observed behavior sequence. According to the definition of conditional random fields, the likelihood function Expressed as the joint probability of all samples:
[0093]
[0094] By maximizing the likelihood function, we can obtain the estimated value of the parameter set, and take the logarithm of the likelihood function to obtain the log-likelihood function. for:
[0095]
[0096] Define x (n) About state sequence (n) The conditional probability of , in the conditional random field, this conditional probability is represented by the softmax function:
[0097]
[0098] Finally, the gradient descent optimization algorithm can be used to maximize the log-likelihood function to estimate the parameter set w trans 、w state and λ.
[0099] Specifically, the definition of the likelihood function is based on the conditional random field model, which is a probabilistic graphical model used to describe sequence labeling problems. In this model, given an observation sequence x, the goal is to infer the most likely state sequence s. Likelihood function It measures the overall fit of the model under the conditions of the observation sequence and the corresponding state sequence in the given training data set. It is the joint probability of all training samples. The main function of the likelihood function is to help find the model parameter set that can best explain the observed data. By maximizing the likelihood function, the parameter combination that can maximize the probability of the observed behavior sequence can be found. Maximizing the likelihood function is equivalent to finding an optimal set of model parameters so that the model can get the best fit effect on the training data set. The model trained in this way can also have better generalization ability when facing new observation data, and can more accurately predict and classify states.
[0100] In actual calculations, especially when a large amount of data is involved, directly calculating the likelihood function may lead to numerical overflow or numerical instability. In order to avoid these problems and simplify the calculation process, the logarithm of the likelihood function is often taken. This is because the logarithmic function is monotonic and can convert multiplication into addition, thereby reducing the computational complexity. The log-likelihood function obtained after taking the logarithm of the likelihood function is the sum of the logarithmic conditional probabilities of all samples. It is used to measure the degree of fit of the model under a given training data set. The main function of the log-likelihood function is to simplify the optimization process of model parameters. By converting the likelihood function to a logarithmic form, optimization algorithms such as gradient descent can be used to maximize the log-likelihood function to find the optimal set of model parameters. Compared with the likelihood function, the log-likelihood function is easier to calculate and optimize, and is not affected by numerical overflow or numerical instability. This enables more efficient model training and faster finding of the optimal parameter combination. In addition, the log-likelihood function can also be used to evaluate the degree of fit of the model. By monitoring the value of the log-likelihood function, you can understand the performance of the model during the training process and whether the model is suitable for the given data set.
[0101] In a conditional random field, given an observation sequence x(n) , the goal is to calculate the corresponding state sequence s (n) The conditional probability of . This conditional probability represents the probability of each possible state sequence occurring under a given observation sequence. The calculation of conditional probability is based on the energy function of the conditional random field. The energy function reflects the relative goodness of each possible state sequence in the model, and the conditional probability is calculated based on these energy values. The softmax function is used to calculate the conditional probability, and its function is to convert the value of the energy function into the probability distribution of the corresponding state sequence. The advantage of this is that it can ensure that the sum of the probabilities of all possible state sequences is 1, thus obtaining a legal probability distribution. The numerator is the exponential form of the energy function, which represents the relative goodness of the corresponding state sequence. The use of the exponential function makes the probability of a state sequence with higher energy lower, and the probability of a state sequence with lower energy higher. The denominator is the sum of the exponential forms of all possible state sequences. It plays a normalization role, ensuring that a probability distribution is obtained, so that the sum of all probability values is 1.
[0102] Embodiment 9: The decoding algorithm is the Viterbi algorithm.
[0103] Specifically, for a given cow behavior sequence, the learned Lagrangian conditional random field model is first used to decode through the Viterbi algorithm to find the most likely state sequence. This state sequence is the recognition result, which represents the most likely cow behavior state sequence that the model considers for a given behavior sequence. The Viterbi algorithm recursively calculates the optimal state at each moment through dynamic programming, thereby obtaining the optimal state path of the entire sequence. The specific steps include calculating the optimal score of each state at each moment (based on the energy function of the conditional random field) and recording the optimal path of each state at each moment. For the prediction of cow behavior at future moments, the learned Lagrangian conditional random field model is used, based on the given cow behavior sequence and the learned energy function, and the Viterbi algorithm is used again to predict the state at the next moment. The prediction process is similar to the recognition process, except that the observed behavior sequence at the current moment needs to be used as input during prediction, and the state score at each moment is calculated using the learned model parameters and energy function, and then the most likely state is found as the prediction result through the Viterbi algorithm. The predicted state can be used as the prediction result of future cow behavior to guide pasture management or other applications.
[0104] Through the above implementation process, the recognition and prediction unit can use the learned Lagrangian conditional random field model to identify the state of a given cow behavior sequence and predict the behavior at future moments. This method can provide real-time and accurate cow behavior information for farm management based on historical data and knowledge learned from the model, which helps to improve the management efficiency of the ranch and the health and production level of the cows.
[0105] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that these specific embodiments are only illustrative, and those skilled in the art may omit, replace, and change the details of the above methods and systems in various ways without departing from the principles and essence of the present invention. For example, merging the above method steps so as to perform substantially the same functions in substantially the same manner to achieve substantially the same results is within the scope of the present invention. Therefore, the scope of the present invention is limited only by the appended claims.
Claims
1. Cow behavior recognition and prediction system, characterized in that: The system comprises: a data acquisition unit, which is used to collect the behavior data of each cow at each moment, wherein the behavior data is a vector composed of multiple different types of cow behavior parameters, and the behavior data is subjected to noise removal to obtain a behavior sequence of each cow, wherein the elements of the behavior sequence are the behavior data after noise removal; a feature extraction unit, which extracts features from each behavior data to obtain a feature sequence, wherein each element in the feature sequence is a feature vector of each behavior data; a data processing unit, which is used to define a state set of cow behavior, wherein each element in the state set is the state of the cow at each moment; and a parameter set of a Lagrangian conditional random field is defined, wherein the parameter set includes a transfer feature parameter, a state feature parameter and Lagrangian multiplier parameters, which are used to constrain state transitions and the correlation between states, construct Lagrangian conditional random fields, and use the training data set to estimate the parameter set of the Lagrangian conditional random field using maximum likelihood estimation; identification prediction unit, for a given cow behavior sequence, using the learned Lagrangian conditional random field, through a decoding algorithm to identify the most likely state corresponding to it as the identification result; for the prediction of cow behavior at future moments, using the learned Lagrangian conditional random field, based on the given cow behavior sequence and the energy function of the learned Lagrangian conditional random field, through a decoding algorithm to predict the state at the next moment as the prediction result; Use the following formula for Behavior data after noise removal at each moment Extract features and obtain their corresponding feature vectors: Select multiple locally sensitive hash functions to extract the behavior data. Mapped into a high-dimensional space and retaining similarity; for each behavior data , apply the hash function to get its hash code, given hash functions, each of which is represented by ,in ; Each hash function maps to dimensional space, then each behavior data You will get a The hash code matrix ; For each hash code matrix , calculate its eigenvector in the direction of the mean value and the eigenvector in the direction of the standard deviation as the elements of the eigenvector, and obtain the eigenvector; When defining the parameter set of the Lagrangian conditional random field, define the transfer characteristic parameters included in it for: ; in, Transfer feature parameters The dimension of is equal to the dimension of the high-dimensional space mapped by the hash function; the state characteristic parameter is : ; in, is the dimension of the state characteristic parameter, and its value is equal to the number of hash functions; the Lagrange multiplier parameter is: ; in, is the dimension of the Lagrangian multiplier parameter, and its value is equal to the number of state types; the energy function of the Lagrangian conditional random field is expressed using the following formula: ; in, is the transition characteristic function, which is used to describe the conditional probability of transitioning from one state to another; is the state characteristic function, used to describe the given moment The feature vector observed under the condition of the current state; is the constraint function, which is calculated using the following formula: 。 2. The cow behavior recognition and prediction system according to claim 1, characterized in that: The types of the behavior parameters include: position parameters, acceleration parameters, speed parameters, direction parameters, temperature parameters, heart rate parameters and posture parameters; the states in the behavior state set include at least: walking, standing still, grazing and running.
3. The cow behavior recognition and prediction system according to claim 2, characterized in that The behavior sequence of each cow is ,in Indicates Behavioral data at the moment; The behavior data at each moment is filtered and denoised using the following formula: ; in, is the subscript, Indicates The behavioral data of the moment elements; The filter window size for filtering and denoising; After noise removal, The behavioral data of the moment elements; in this way, we get the first The behavior data at that moment is ; is the Gaussian weighting coefficient, calculated using the following formula: 。 4. The cow behavior recognition and prediction system according to claim 3, characterized in that: Eigenvector in the direction of the mean Calculated using the following formula: ; in, represents the natural logarithm, is the base of natural logarithms; Indicates Behavior data after noise removal at each moment No. The hash code of a hash function; Use the following formula to calculate the eigenvector in the standard deviation direction: : ; Then, through the following formula, we get Behavior data after noise removal at each moment The eigenvector of: ; The feature vector of the behavior data at each moment is taken as an element in the feature sequence.
5. The cow behavior recognition and prediction system according to claim 4, characterized in that: The data processing unit builds a state set for each cow When , we define There are different states, and the state type set is represented as ; Status Collection The Elements Indicates that the cow is The state at a moment; Set at time Cows in state , at the time Transfer to state The state transition probability is ; Integrate the transition probabilities into the state transfer matrix , among which Line The elements of the column represent the state Transfer to state The probability of the state transition matrix is ; At the beginning, the state of the cow is unknown, and the probability distribution of the initial state of the cow is defined as an initial state vector , among which The element indicates that the initial state of the cow is probability.
6. The cow behavior recognition and prediction system according to claim 5, characterized in that: In the process of constructing the Lagrangian conditional random field and estimating the parameter set by maximum likelihood estimation, the data processing unit defines the log-likelihood function and maximizes the log-likelihood function through an optimization algorithm to obtain the parameter set. Specifically, the log-likelihood function is used to measure the degree of fit of the model under a given training data set. Assume that the training data set contains samples, expressed as: ,in It is A sequence of states of samples, is the corresponding observed behavior sequence. The goal is to find the parameter set that maximizes the probability of the observed behavior sequence. According to the definition of conditional random fields, the likelihood function Expressed as the joint probability of all samples: ; By maximizing the likelihood function, we can obtain the estimated value of the parameter set, and take the logarithm of the likelihood function to obtain the log-likelihood function. for: ; definition About state sequence The conditional probability of , in the conditional random field, this conditional probability is represented by the softmax function: ; Finally, the gradient descent optimization algorithm can be used to maximize the log-likelihood function to estimate the parameter set , and ; represents all possible state sequences, which are used to calculate the normalized terms of conditional probabilities. Contains all possible lengths A state sequence, where is the length of the observed behavior sequence, It consists of all possible state combinations, so it is a discrete state space.
7. The cow behavior recognition and prediction system according to claim 6, characterized in that: The decoding algorithm is the Viterbi algorithm.
