A method for predicting milk yield in dairy cows
By using a step-by-step method to predict milk production in dairy cows, and combining coarse and fine prediction models, the problem of low prediction accuracy in existing technologies has been solved, and efficient and accurate prediction of milk production in dairy cows has been achieved.
Patent Information
- Application Number
- CN202510555167.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-04-29
AI Technical Summary
Existing methods for predicting milk yield in dairy cows suffer from low prediction accuracy. In particular, genetic algorithms are prone to getting stuck in local minima, leading to premature maturity and failing to obtain the global optimal solution.
A two-step prediction method is adopted. First, a preliminary prediction is made using a pre-trained coarse prediction model for milk yield. Then, a precise prediction is made using a pre-trained fine prediction model for milk yield. The prediction accuracy is improved by feature segmentation, feature scoring, and feature fusion, respectively.
By employing a step-by-step prediction method, the factors influencing milk production in dairy cows are comprehensively considered, thereby improving the accuracy of milk production prediction and ensuring the rational utilization of the importance of different characteristics and the precision of the prediction results.
Smart Images

Figure CN120373567B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of milk yield prediction technology, and in particular to a method for predicting milk yield in dairy cows. Background Technology
[0002] In recent years, my country's dairy farming industry has flourished, entering a stage of large-scale and intensive farming. However, the milk yield per cow remains low, and the increase in milk production relies more on the increase in the number of cows. Therefore, how to improve milk production during the farming process has always been a key focus and goal pursued by industry professionals and researchers. Predicting the daily milk production of dairy cows can help determine the raw milk demand of various dairy companies in advance, providing data support for planning the scheduling of transportation vehicles. Therefore, dairy cow milk production prediction technology is particularly important for the dairy industry.
[0003] Currently, the prediction of daily milk yield per cow in dairy farms relies on experienced farmers identifying similar examples from past experiences and estimating the daily milk yield based on experience and the cow's growth and feeding conditions. However, a shortage of experienced farmers in dairy farms leads to low prediction efficiency, and human estimation can result in oversights, leading to low accuracy in milk yield prediction. With technological advancements, a Long Short-Term Memory (LSTM) algorithm based on genetic algorithms has been adopted to improve model accuracy. This method eliminates the need for manual estimation based on experience, improving both accuracy and efficiency. However, when using genetic algorithms for pre-optimization, preprocessing multimodal problems with multiple optimal solutions can easily lead to getting stuck in local minima and stopping the search, causing premature convergence and preventing the attainment of a globally optimal solution, thus affecting prediction accuracy. Summary of the Invention
[0004] The purpose of this invention is to address the problem of low prediction accuracy in existing dairy cow milk production prediction methods, and to propose a new method for predicting dairy cow milk production.
[0005] A method for predicting milk yield in dairy cows includes the following steps:
[0006] S1. Obtain the dataset of milk production characteristics of the dairy cows to be predicted;
[0007] The milk production characteristics of the dairy cow include: body height, chest width, body depth, udder depth, central suspensory ligament length, anterior teat position, anterior teat length, hind udder attachment height, hind teat position, number of days of lactation, parity, and hind udder attachment width.
[0008] S2. Normalize the milk production feature data of the dairy cows to be predicted to obtain the preprocessed milk production feature dataset of the dairy cows to be predicted.
[0009] S3. Input the preprocessed milk production feature dataset of the cows to be predicted into the trained coarse milk production prediction model to obtain the coarse predicted milk production of the cows to be predicted.
[0010] S4. Input the preprocessed milk production feature dataset of the cow to be predicted and the coarse predicted milk production of the cow to be predicted into the trained fine prediction model of milk production of the cow to obtain the predicted milk production of the cow.
[0011] Furthermore, the position of the anterior nipple in S1 is 1, 5, or 9; the position of the posterior nipple is 1, 5, or 9.
[0012] Further, in step S2, the milk production characteristic data of the dairy cows to be predicted is normalized to obtain a preprocessed dataset of milk production characteristic data of the dairy cows to be predicted, specifically as follows:
[0013]
[0014] in, It is after normalization It is the j-th feature in the i*-th sample of dairy cows to be tested, j∈[1,12], j is the feature label of the dairy cow to be predicted, and n* is the total number of dairy cows to be predicted.
[0015] Furthermore, the trained coarse prediction model for milk yield in S3 is obtained through the following method:
[0016] Step 1: Obtain the dairy cow milk production feature dataset and preprocess it to obtain the preprocessed dairy cow milk production feature dataset.
[0017] Step 2: Combine the preprocessed dairy cow milk production dataset with the milk yield on the t-th day of lactation. The dataset is divided into a training set and a test set. The training set is used to train a coarse prediction model for dairy cow milk production, and the trained coarse prediction model for dairy cow milk production is obtained.
[0018] Step 3: Test the trained coarse prediction model of milk production of dairy cows using the test set. If the accuracy of the trained coarse prediction model of milk production of dairy cows is lower than the preset threshold, return to Step 1; otherwise, output the trained coarse prediction model of milk production of dairy cows.
[0019] Further, the step one of obtaining the dairy cow milk production feature dataset and preprocessing the dairy cow milk production feature dataset to obtain the preprocessed dairy cow milk production feature dataset specifically involves:
[0020] Step 11: Obtain a dataset of dairy cow milk production characteristics;
[0021] X(t) = [X1(t), X2(t), ... X i(t),..,X n (t)]
[0022] X i (t)=[X i,H ,X i,W ,X i,D ,X i,RD ,X i,L ,X i,Qp ,X i,Ql ,X i,BH ,X i,BW ,X i,Bp ,X i,S ,t]
[0023] Among them, X i X(t) is the milk production feature vector of the i-th cow on the t-th day of lactation, and X(t) is the milk production feature dataset of the cows. i,H X is the height of the i-th cow. i,W The width of the chest of the i-th cow is X. i,D The body depth of the i-th cow is X. i,RD X is the udder depth of the i-th cow. i,L X is the length of the central suspensory ligament of the i-th cow. i,Qp X is the position of the front teat of the i-th cow. i,Ql X is the length of the front teat of the i-th cow. i,BH X is the attachment height of the hind udder of the i-th cow. i,Bp X is the position of the hind teat of the i-th cow, t is the number of days of lactation, and X i,S It is the i-th calf's parity, X i,BW is the width of the udder attachment of the i-th cow, and n is the total number of cows;
[0024] Steps 1 and 2: Normalize the data in the dairy cow milk production feature dataset to obtain the preprocessed dairy cow milk production feature dataset:
[0025]
[0026] Where, X′ ij It is the normalized X ij X ij It is the j-th feature in the i-th dairy cow sample, j∈[1,12], j is the feature number in the sample, and n is the total number of dairy cows.
[0027] Furthermore, in step two, the preprocessed dairy cow milk production dataset and the milk production on the t-th day of lactation are combined. The dataset is constructed by dividing it into a training set and a test set. The training set is used to train a coarse prediction model for dairy cow milk production, resulting in a well-trained coarse prediction model for dairy cow milk production. Specifically:
[0028] Step 2: 1. Combine the preprocessed dairy cow milk production dataset with the milk yield on the t-th day of lactation. The dataset is composed of a training set and a test set.
[0029] Step 22: Train a coarse prediction model for dairy cow yield using the training set;
[0030] The crude prediction model for milk production in dairy cows includes: a feature segmentation module, a feature scoring module, and a prediction module;
[0031] The feature segmentation module is used to divide the preprocessed dairy cow milk production dataset into body feature vectors, mammary gland feature vectors, and time feature vectors.
[0032] Body feature vector B i =[X i,H ,X i,W ,X i,D ];
[0033] Breast feature vector R i =[X i,RD ,X i,L ,X i,Qp ,X i,Ql ,X i,BH ,X i,BW ,X i,Bp ];
[0034] Time eigenvector S i =[X i,S ,t];
[0035] The feature scoring module is used to obtain the importance scores of the cow's body features, udder features, and time features; the feature scoring module includes: a body feature score acquisition unit, a udder feature score acquisition unit, and a time feature score acquisition unit;
[0036] The body feature scoring unit includes: an input layer, an attention layer, an activation function layer, a feature weighting layer, a fully connected layer, and an output layer;
[0037] The input layer is used to input the cow's body feature vector and then input the cow's body feature vector into the attention layer; the input layer has a dimension of 4.
[0038] The attention layer is used to assign weights to each feature in the cow body feature vector to obtain the cow body feature weight vector.
[0039] The activation function layer is used to normalize the weights of the cow's body features to obtain normalized weights of the cow's body features; the activation function layer is the softmax function.
[0040] The feature weighting layer is used to multiply each cow's body feature by its corresponding weight to obtain a body-weighted feature vector;
[0041] The fully connected layer is used to map the body-weighted feature vectors to the feature space;
[0042] The output layer is used to output the importance score of the cow's body feature vector.
[0043] The output layer uses the sigmoid activation function.
[0044] The structure of the breast feature scoring unit is the same as that of the body feature scoring unit; however, the input and output dimensions are 7; and the output is the breast feature importance score.
[0045] The structure of the time feature score acquisition unit is the same as that of the body feature score acquisition unit; however, the input and output dimensions are 2; the output is the time feature importance score.
[0046] The prediction module uses the importance scores of the cow's body features, udder features, and time features, along with the body feature vector, udder feature vector, and time feature vector, to obtain the milk yield on the t-th day of lactation.
[0047] Furthermore, the feature prediction module includes: a feature combination unit and a prediction unit;
[0048] The feature combination unit is used to concatenate the body feature vector with the body feature vector importance score, the breast feature vector with the breast feature vector importance score, and the time feature vector with the time feature vector importance score, and input the three concatenated vectors into the prediction unit.
[0049] The prediction unit is used to obtain the milk production on the t-th day of lactation using the concatenated vector.
[0050] The prediction unit includes: a data filling layer, a hidden layer, and an output layer;
[0051] The data padding layer is used to pad the three concatenated vectors with zeros to make them the same length, and then input the padded vectors into the hidden layer.
[0052] The input to the hidden layer is the output of the data filling layer;
[0053] The output layer is used to obtain the milk production on the t-th day of lactation based on the output of the hidden layer.
[0054] Furthermore, the trained precise prediction model for dairy cow milk yield is obtained through the following method:
[0055] A1. Obtain the dairy cow milk production feature dataset, and perform normalization preprocessing on the dairy cow milk production feature dataset to obtain the preprocessed dairy cow milk production feature dataset. Then, combine the preprocessed dairy cow milk production dataset, the coarse predicted dairy cow milk production value output by the dairy cow milk production coarse prediction model, and the milk production on the t-th day of lactation. A second dataset is created, and the second dataset is divided into a second training set and a second test set.
[0056] A2. Use the second training set to train the precise prediction model of dairy cow milk production and obtain the trained precise prediction model of dairy cow milk production.
[0057] A3. Test the milk yield prediction model of dairy cows using the second test set. If the accuracy of the trained milk yield prediction model is greater than the preset threshold, output the currently trained milk yield prediction model of dairy cows; otherwise, return to step A1.
[0058] Furthermore, the dairy cow milk production prediction model includes: a feature vector acquisition module, a feature fusion module, and a milk production prediction module;
[0059] The feature vector acquisition module is used to acquire the body feature vector, udder feature vector, and time feature vector of dairy cows based on the dairy cow milk production feature dataset.
[0060] Body feature vector B i =[X i,H ,X i,W ,X i,D ];
[0061] Breast feature vector R i =[X i,RD ,X i,L ,X i,Qp ,X i,Ql ,X i,BH ,X i,BW ,X i,Bp ];
[0062] Time eigenvector S i =[X i,S ,t];
[0063] The feature fusion module is used to fuse the body feature vector, udder feature vector, time feature vector, and coarse predicted milk yield of dairy cows to obtain the feature fusion result C. i :
[0064] C i =MCCA(B i ,R i ,S i M i )
[0065] Among them, M i This is a rough prediction of milk production from dairy cows;
[0066] The milk yield prediction module predicts milk production based on the feature fusion result C. i Obtain accurate prediction results for milk production from dairy cows.
[0067] Furthermore, the layers include a mapping vector acquisition layer, a mapping vector concatenation layer, a concatenation result transformation layer, and an output layer.
[0068] The mapping vector acquisition layer utilizes the feature fusion result C i To obtain the mapping vector, specifically:
[0069] Z i,l =φ(C i W i,l +b i,l ), l=1,...,L
[0070] Among them, Z i,l Let L be the l-th mapping vector of the i-th cow sample, L be the number of mapping vectors, φ() be the linear transformation function, and W be the linear transformation function. i,l It is the feature mapping weight matrix, b i,l It is a feature mapping bias;
[0071] The mapping vector concatenation layer is used to concatenate mapping vectors to obtain the concatenation result;
[0072] The splicing result transformation layer is used to perform nonlinear transformation on the splicing result to obtain an enhanced result, specifically:
[0073] H i,p =ξ([Z i,1 Z i,2 ,...,Z i,L W p +b p ), p=1,...,P
[0074] ξ()=tanh()
[0075] Where p is the booster node label, P is the total number of booster nodes, ξ() is the nonlinear activation function, and W p It is the weight matrix of the transformation layer of the concatenated result, b p It is the layer deviation of the splicing result, H i,p Z is the p-th augmentation result for the i-th cow sample. i,L It is the Lth mapping vector of the i-th cow sample;
[0076] The output layer uses the enhancement results and mapping vectors to obtain precise prediction results of milk yield from dairy cows, specifically as follows:
[0077]
[0078] Among them, Z i,L =[Z i,1 Z i,2 ,...Z i,L ], Z i,L H is the set of L feature mapping vectors of the i-th cow. i,P =[H i,1 H i,2 ,...H i,P ], H i,P It is the set of P enhancement results for the i-th cow, and W is the output layer weight matrix.
[0079] The beneficial effects of this invention are as follows:
[0080] This invention comprehensively considers the factors affecting dairy cow milk production, employing both a coarse-scale milk production prediction model and a precise milk production prediction model to predict milk yield. This invention performs a two-step prediction process, improving the accuracy of milk yield prediction. It determines the relative importance of different features to milk yield and performs a coarse prediction based on the importance of these features. Furthermore, this invention categorizes dairy cow milk production features into body characteristics, udder characteristics, and time characteristics, fusing these with the coarse prediction results. A precise prediction of milk yield is then performed based on the fused features, further enhancing the accuracy of milk yield prediction. Attached Figure Description
[0081] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0082] Specific Implementation Method 1: The specific process of this implementation method for predicting milk yield in dairy cows is as follows:
[0083] S1. Obtain the dataset of milk production characteristics of the dairy cows to be predicted;
[0084] The milk production characteristics of the dairy cow include: body height, chest width, body depth, udder depth, central suspensory ligament length, anterior teat position, anterior teat length, hind udder attachment height, hind teat position, number of days of lactation, parity, and hind udder attachment width.
[0085] S2. Normalize the milk production characteristic data of the dairy cows to be predicted to obtain the preprocessed milk production characteristic dataset of the dairy cows to be predicted, specifically:
[0086]
[0087] in, It is after normalization is the j-th feature in the i*-th sample of dairy cows to be tested, j∈[1,12], j is the feature label of the dairy cow to be predicted, and n* is the total number of dairy cows to be predicted;
[0088] S3. Input the preprocessed milk production feature dataset of the cows to be predicted into the trained coarse milk production prediction model to obtain the coarse predicted milk production of the cows to be predicted.
[0089] S4. Input the preprocessed milk production feature dataset of the cow to be predicted and the coarse predicted milk production of the cow to be predicted into the trained fine prediction model of milk production of the cow to obtain the predicted milk production of the cow.
[0090] The trained coarse model for predicting milk yield from dairy cows was obtained through the following method:
[0091] Step 1: Obtain the dairy cow milk production feature dataset and preprocess it to obtain the preprocessed dairy cow milk production feature dataset, specifically:
[0092] Step 11: Obtain a dataset of dairy cow milk production characteristics;
[0093] X(t) = [X1(t), X2(t), ... X i (t),..,X n (t)]
[0094] X i (t)=[X i,H ,X i,W ,X i,D ,X i,RD ,X i,L ,X i,Qp ,X i,Ql ,X i,BH ,X i,BW ,X i,Bp ,X i,S ,t]
[0095] Among them, X i X(t) is the milk production feature vector of the i-th cow on the t-th day of lactation, and X(t) is the milk production feature dataset of the cows. i,H X is the height of the i-th cow. i,W The width of the chest of the i-th cow is X. i,D The body depth of the i-th cow is X. i,RD X is the udder depth of the i-th cow. i,L X is the length of the central suspensory ligament of the i-th cow. i,Qp X is the position of the front teat of the i-th cow. i,Ql X is the length of the front teat of the i-th cow. i,BH X is the attachment height of the hind udder of the i-th cow. i,BpX is the position of the hind teat of the i-th cow, t is the number of days of lactation, and X i,S It is the i-th calf's parity, X i,BW is the width of the udder attachment of the i-th cow, and n is the total number of cows;
[0096] The milk production characteristics of the dairy cows include: body height X H Chest width X W Body depth X D Breast depth X RD Length of central suspensory ligament X L Anterior nipple position X Qp Anterior nipple length X Ql posterior breast attachment height X BH 1. Width of posterior breast attachment (X) BW Position of the posterior nipple X Bp Parity X S , number of days of lactation (t);
[0097] The chest width is the width of the chest base on the inner side of the two forelimbs;
[0098] The body depth is the ratio of the vertical distance from the lumbar vertebra at the last rib to the bottom of the abdomen to the vertical distance from the lumbar vertebra at the last rib to the ground.
[0099] The breast depth is the vertical distance from the bottom of the breast to the hock.
[0100] The length of the central suspensory ligament is the vertical distance between the base of the central suspensory ligament and the base of the breast.
[0101] The position of the anterior nipple is the relative position of the nipple base in the breast area; if it is greater than the first preset distance, it means that it is far away and the anterior nipple position is assigned a value of 1; if it is less than or equal to the first preset distance and greater than the second preset distance, it means that it is moderate and the anterior nipple position is assigned a value of 5; if it is less than or equal to the second preset distance, it means that it is close and the anterior nipple position is assigned a value of 9.
[0102] The posterior breast attachment height is the vertical distance between the uppermost edge of the breast tissue and the base of the vulva.
[0103] The breast attachment width is the width of the upper edge of the posterior breast mammary gland tissue;
[0104] The posterior nipple position is the relative position of the base of the posterior nipple in the mammary region. If the distance between the two nipples is greater than the third preset distance, it means that the posterior nipple position is far away and is assigned a value of 1. If the distance is less than or equal to the third preset distance and greater than the fourth preset distance, it means that the posterior nipple position is moderate and is assigned a value of 5. If the distance is less than or equal to the fourth preset distance, it means that the posterior nipple position is close and is assigned a value of 9.
[0105] Steps 1 and 2: Normalize the data in the dairy cow milk production feature dataset to obtain the preprocessed dairy cow milk production feature dataset:
[0106]
[0107] Where, X′ ij It is the normalized X ij X ij It is the j-th feature in the i-th dairy cow sample, j∈[1,12], j is the feature label in the sample, and n is the total number of dairy cows;
[0108] Step 2: Combine the preprocessed dairy cow milk production dataset with the milk yield on the t-th day of lactation. The dataset is constructed by dividing it into a training set and a test set. The training set is used to train a coarse prediction model for dairy cow milk production, resulting in a well-trained coarse prediction model for dairy cow milk production. Specifically:
[0109] Step 2: 1. Combine the preprocessed dairy cow milk production dataset with the milk yield on the t-th day of lactation. The dataset is composed of a training set and a test set.
[0110] Step 22: Train a coarse prediction model for dairy cow yield using the training set;
[0111] The crude prediction model for milk production in dairy cows includes: a feature segmentation module, a feature scoring module, and a prediction module;
[0112] The feature segmentation module is used to divide the preprocessed dairy cow milk production dataset into body feature vectors, mammary gland feature vectors, and time feature vectors.
[0113] Body feature vector B i =[X i,H ,X i,W ,X i,D ];
[0114] Breast feature vector R i =[X i,RD ,X i,L ,X i,Qp ,X i,Ql ,X i,BH ,X i,BW ,X i,Bp ];
[0115] Time eigenvector S i =[X i,S ,t];
[0116] The feature scoring module is used to obtain the importance scores of the cow's body features, udder features, and time features, and includes: a body feature score acquisition unit, a udder feature score acquisition unit, and a time feature score acquisition unit;
[0117] The body feature scoring unit includes: an input layer, an attention layer, an activation function layer, a feature weighting layer, a fully connected layer, and an output layer;
[0118] The input layer is used to input the cow's body feature vector and then input the cow's body feature vector into the attention layer; the input layer has a dimension of 4.
[0119] The attention layer is used to assign weights to each feature in the cow body feature vector to obtain the cow body feature weight vector.
[0120] The activation function layer is used to normalize the weights of the cow's body features to obtain normalized weights of the cow's body features; the activation function layer is the softmax function.
[0121] The feature weighting layer is used to multiply each cow's body feature by its corresponding weight to obtain a body-weighted feature vector;
[0122] The fully connected layer is used to map the body-weighted feature vectors to the feature space;
[0123] The output layer is used to output the importance score of the cow's body feature vector.
[0124] The output layer uses the sigmoid activation function.
[0125] The structure of the breast feature scoring unit is the same as that of the body feature scoring unit; however, the input and output dimensions are 7; and the output is the breast feature importance score.
[0126] The structure of the time feature score acquisition unit is the same as that of the body feature score acquisition unit; however, the input and output dimensions are 2; the output is the time feature importance score.
[0127] The prediction module includes: a feature combination unit and a prediction unit;
[0128] The feature combination unit is used to concatenate the body feature vector with the body feature vector importance score, the breast feature vector with the breast feature vector importance score, and the time feature vector with the time feature vector importance score, and input the three concatenated vectors into the prediction unit.
[0129] The prediction unit is used to obtain the milk production on the t-th day of lactation using the concatenated vector.
[0130] The prediction unit includes: a data filling layer, a hidden layer, and an output layer;
[0131] The data padding layer is used to pad the three concatenated vectors with zeros to make them the same length, and then input the padded vectors into the hidden layer.
[0132] The hidden layer is used to process the output of the data filling layer;
[0133] The output layer is used to obtain the milk production on the t-th day of lactation based on the output of the hidden layer. This invention employs a linear activation function;
[0134] Step 3: Test the trained coarse prediction model of milk production of dairy cows using the test set. If the accuracy of the trained coarse prediction model of milk production of dairy cows is lower than the preset threshold, return to Step 1; otherwise, output the trained coarse prediction model of milk production of dairy cows.
[0135] Specific Implementation Method Two: The trained precise prediction model for dairy cow milk yield is obtained through the following method:
[0136] A1. Obtain the dairy cow milk production feature dataset, and perform normalization preprocessing on the dairy cow milk production feature dataset to obtain the preprocessed dairy cow milk production feature dataset. Then, combine the preprocessed dairy cow milk production dataset, the coarse predicted dairy cow milk production value output by the dairy cow milk production coarse prediction model, and the milk production on the t-th day of lactation. A second dataset is created, and the second dataset is divided into a second training set and a second test set.
[0137] A2. Use the second training set to train the precise prediction model of dairy cow milk production and obtain the trained precise prediction model of dairy cow milk production.
[0138] The dairy cow milk production semen prediction model includes: a feature vector acquisition module, a feature fusion module, and a milk production semen prediction module;
[0139] The feature vector acquisition module is used to acquire the body feature vector, udder feature vector, and time feature vector of dairy cows based on the dairy cow milk production feature dataset.
[0140] The feature fusion module is used to fuse the body feature vector, udder feature vector, time feature vector, and coarse predicted milk yield of dairy cows to obtain the feature fusion result C. i :
[0141] C i =MCCA(B i ,R i ,S i M i )
[0142] Among them, M i This is a rough prediction of milk production from dairy cows;
[0143] The milk yield prediction module predicts milk production based on the feature fusion result C. iObtain precise prediction results of milk yield from dairy cows; the precise milk yield prediction module includes: a mapping vector acquisition layer, a mapping vector splicing layer, a splicing result transformation layer, and an output layer;
[0144] The mapping vector acquisition layer utilizes the feature fusion result C i To obtain the mapping vector, specifically:
[0145] Z i,l =φ(C i W i,l +b i,l ), l=1,...,L
[0146] Among them, Z i,l Let L be the l-th mapping vector of the i-th cow sample, L be the number of mapping vectors, φ() be the linear transformation function, and W be the linear transformation function. i,l It is the feature mapping weight matrix, b i,l It is a feature mapping bias;
[0147] The mapping vector concatenation layer is used to concatenate mapping vectors to obtain the concatenation result;
[0148] The splicing result transformation layer is used to perform nonlinear transformation on the splicing result to obtain an enhanced result, specifically:
[0149] H i,p =ξ([Z i,1 Z i,2 ,...,Z i,L W p +b p ), p=1,...,P
[0150] ξ()=tanh()
[0151] Where p is the booster node label, P is the total number of booster nodes, ξ() is the nonlinear activation function, and W p It is the weight matrix of the transformation layer of the concatenated result, b p It is the layer deviation of the splicing result, H i,p Z is the p-th augmentation result for the i-th cow sample. i,L It is the Lth mapping vector of the i-th cow sample;
[0152] The output layer uses the enhancement results and mapping vectors to obtain precise prediction results of milk yield from dairy cows, specifically as follows:
[0153]
[0154] Among them, Z i,L =[Z i,1 Z i,2 ,...Z i,L ], Z i,LH is the set of L feature mapping vectors of the i-th cow. i,P =[H i,1 H i,2 ,…H i,P ], H i,P It is the set of P enhancement results for the i-th cow, and W is the output layer weight matrix.
[0155] A3. Test the milk yield prediction model of dairy cows using the second test set. If the accuracy of the trained milk yield prediction model is greater than the preset threshold, output the currently trained milk yield prediction model of dairy cows; otherwise, return to step A1.
Claims
1. A method of predicting milk yield of a dairy cow, characterized by The method comprises the following steps: S1, obtaining a dairy cow milk production characteristic data set to be predicted; The dairy cow milk production characteristics include body height, chest width, body depth, udder depth, central suspensory ligament length, front teat position, front teat length, rear udder attachment height, rear teat position, lactation days, parity, and rear udder attachment width; S2, normalizing the dairy cow milk production characteristic data to be predicted to obtain a preprocessed dairy cow milk production characteristic data set to be predicted; S3, inputting the preprocessed dairy cow milk production characteristic data set to be predicted into a trained dairy cow milk production rough prediction model to obtain a rough prediction of the milk production of the dairy cow to be predicted; The trained dairy cow milk production rough prediction model in S3 is obtained by the following method: Step one, obtaining a dairy cow milk production characteristic data set and preprocessing the dairy cow milk production characteristic data set to obtain a preprocessed dairy cow milk production characteristic data set; Step two, the pretreated cow milk production dataset and the milk production of the first lactation period are combined into a dataset The dataset is divided into a training set and a test set, the training set is used to train a rough prediction model of cow production, and a trained rough prediction model of cow milk production is obtained, specifically as follows: Step two, dividing the preprocessed dairy cow milk production dataset and the first milk production of the lactation period composing a dataset, dividing the dataset into a training set and a test set; Step two, training the dairy cow milk production rough prediction model using a training set; The dairy cow milk production rough prediction model comprises a feature division module, a feature score module, and a prediction module; The feature division module is used to divide the preprocessed dairy cow milk production data set into a body feature vector, a udder feature vector, and a time feature vector; Body feature vector ; wherein, is the height of the only cow, is the chest width of the only cow, is the body depth of the only cow; breast feature vector ; wherein, is the depth of the udder of the only cow, is the length of the central suspensory ligament of the only cow, is the position of the front teat of the only cow, is the length of the front teat of the only cow, is the height of the rear udder attachment of the only cow, is the position of the rear teat of the only cow, is the width of the rear udder attachment of the only cow. time feature vector ; wherein, is days in milk, is the only cow parity; The feature score module is used to obtain a body feature importance score, a udder feature importance score, and a time feature importance score of the dairy cow; the feature score module comprises a body feature score acquisition unit, a udder feature score acquisition unit, and a time feature score acquisition unit; The body feature score acquisition unit comprises an input layer, an attention layer, an activation function layer, a feature weighting layer, a fully connected layer, and an output layer; The input layer is used to input the dairy cow body feature vector and input the dairy cow body feature vector into the attention layer; the dimension of the input layer is 4; The attention layer is used to assign a weight to each feature in the dairy cow body feature vector to obtain a dairy cow body feature weight vector; The activation function layer is used to normalize the dairy cow body feature weight to obtain a normalized dairy cow body feature weight; the activation function layer is a softmax function; The feature weighting layer is used to multiply each dairy cow body feature with the corresponding weight to obtain a body weighted feature vector; The fully connected layer is used to map the body weighted feature vector to a feature space; The output layer is used to output the importance score of the dairy cow body feature vector; The output layer adopts a sigmoid activation function; The structure of the udder feature score acquisition unit is the same as that of the body feature score acquisition unit; however, the dimension of the input and output layers is 7; and the udder feature importance score is outputted; The structure of the time feature score acquisition unit is the same as that of the body feature score acquisition unit; however, the dimension of the input and output layers is 2; and the time feature importance score is outputted; The prediction module obtains the milk yield for the first lactation day using the body feature importance score, the teat feature importance score, the time feature importance score, the body feature vector, the teat feature vector, and the time feature vector for the cow ; Step three, testing the trained dairy cow milk production rough prediction model using a test set; if the accuracy of the trained dairy cow milk production rough prediction model is lower than a preset threshold, returning to step one; otherwise, outputting the trained dairy cow milk production rough prediction model. S4, inputting the pretreated dairy cow milk production feature data set to be predicted and the coarse prediction milk production of the dairy cow to be predicted into the trained fine prediction model of dairy cow milk production, to obtain the milk production of the dairy cow to be predicted.
2. A method of predicting milk yield of a dairy cow according to claim 1, characterized in that: The front teat position in S1 is valued as 1, 5 or 9; and the rear teat position is valued as 1, 5 or 9.
3. A method of predicting milk yield of a dairy cow according to claim 2, characterized in that: In S2, the dairy cow milk production feature data to be predicted is normalized to obtain a pretreated dairy cow milk production feature data set to be predicted, specifically: wherein, is the normalized , is the jth feature in the ith sample of the dairy cow to be tested, is the jth feature in the ith sample of the dairy cow to be tested, , is the feature label of the dairy cow to be predicted, is the total number of dairy cows to be predicted.
4. A method of predicting milk yield of a dairy cow according to claim 3, characterized in that: In step one, the dairy cow milk production feature data set is obtained, and the dairy cow milk production feature data set is pretreated to obtain a pretreated dairy cow milk production feature data set, specifically: Step one, obtaining a dairy cow milk production feature data set; wherein, is the number of dairy cows, is the milk production feature vector of the tth lactation of the dairy cow, is the milk production feature data set of the dairy cow, is the number of dairy cows, is the body height of the dairy cow, is the number of dairy cows, is the chest width of the dairy cow, is the number of dairy cows, is the body depth of the dairy cow, is the number of dairy cows, is the udder depth of the dairy cow, is the number of dairy cows, is the length of central suspensory ligament of the dairy cow, is the number of dairy cows, is the position of the front teat of the dairy cow, is the number of dairy cows, is the length of the front teat of the dairy cow, is the number of dairy cows, is the height of rear udder attachment of the dairy cow, is the number of dairy cows, is the position of the rear teat of the dairy cow, is the number of lactation days, is the number of dairy cows, is the parity of the dairy cow, is the number of dairy cows, is the width of rear udder attachment of the dairy cow, is the total number of dairy cows; Step two, normalizing the data in the dairy cow milk production feature data set to obtain a pretreated dairy cow milk production feature data set: wherein, is the normalized , is the jth feature in the ith cow sample, , is the feature label in the sample, is the total number of cows.
5. A method of predicting milk yield of a dairy cow according to claim 4, characterized in that: The feature prediction module comprises a feature combination unit and a prediction unit. The feature combination unit is configured to respectively splice the body feature vector and the body feature vector importance score, the breast feature vector and the breast feature vector importance score, and the time feature vector and the time feature vector importance score, and input the three vectors obtained after splicing to the prediction unit. The prediction unit is configured to obtain the first milk yield for the first number of lactating days using the concatenated vector ; The prediction unit comprises a data padding layer, a hidden layer and an output layer. The data padding layer is configured to pad the three vectors after splicing to the same length, and input the padded vectors to the hidden layer. The input of the hidden layer is the output of the data padding layer. The output layer is configured to obtain the milk yield of the first lactation day based on the output of the hidden layer .
6. A method of predicting milk yield of a dairy cow according to claim 5, characterized in that: The trained fine prediction model of dairy cow milk production is obtained by the following method: A1, obtain a milk cow milk production feature dataset, and normalize and preprocess the milk cow milk production feature dataset to obtain a preprocessed milk cow milk production feature dataset, and combine the preprocessed milk cow milk production dataset, a milk cow milk production rough prediction value output by a milk cow milk production rough prediction model, and a milk production of the first lactation period to form a second dataset, and divide the second dataset into a second training set and a second test set; A2, training the fine prediction model of dairy cow milk production by using the second training set to obtain the trained fine prediction model of dairy cow milk production; A3, testing the fine prediction model of dairy cow milk production by using the second test set, if the accuracy of the trained fine prediction model of dairy cow milk production is greater than a preset threshold, outputting the current trained fine prediction model of dairy cow milk production; Otherwise, return to step A1.
7. A method of predicting milk yield of a dairy cow according to claim 6, characterized in that: The fine prediction model of dairy cow milk production comprises a feature vector acquisition module, a feature fusion module and a milk production fine prediction module. The feature vector acquisition module is configured to acquire the dairy cow body feature vector, the breast feature vector and the time feature vector according to the dairy cow milk production feature data set. Body feature vector ; breast feature vector ; time feature vector ; The feature fusion module is configured to fuse the body feature vector, the breast feature vector and the time feature vector, and the rough prediction value of the milk yield of the dairy cow to obtain a feature fusion result : wherein, is a rough prediction of milk yield of a dairy cow; The milk yield fine prediction module acquires the milk yield fine prediction result according to the feature fusion result The milk yield fine prediction result is acquired.
8. A method of predicting milk yield of a dairy cow according to claim 7, characterized in that: The milk production fine prediction module comprises a mapping vector acquisition layer, a mapping vector splicing layer, a splicing result transformation layer and an output layer. The mapping vector acquisition layer utilizes the feature fusion result The mapping vector is obtained, specifically as follows: wherein, is the i-th mapping vector of the l-th cow sample, is the number of mapping vectors, is a linear transformation function, is a feature mapping weight matrix, is a feature mapping bias; The mapping vector splicing layer is configured to splice the mapping vectors to obtain a splicing result. The splicing result transformation layer is configured to perform nonlinear transformation on the splicing result to obtain an enhanced result, specifically: wherein, is an enhanced node index, is the total number of enhanced nodes, is a non-linear activation function, is a concatenation result transform layer weight matrix, is a concatenation result transform layer bias, is the pthenhanced result of the ithcow sample, is the pthmapping vector of the ithcow sample, is the pthmapping vector of the ithcow sample. The output layer uses the enhanced result and the mapping vector to obtain the fine prediction result of dairy cow milk production, specifically: wherein, , is the ith cow a set of feature mapping vectors, , is the ith cow a set of enhanced results, is an output layer weight matrix.
Citation Information
Patent Citations
Dairy cow milk yield data processing and predicting method
CN116090651A
Dairy cow milk yield prediction method based on deep learning
CN117094446A