A pig farm disease monitoring and early warning method and system based on machine learning
Through the pig farm disease monitoring and early warning method based on machine learning, the problem of low efficiency of disease early warning in existing pig farms has been solved, accurate early warning of pig farm diseases and prediction of the duration of negative transition have been achieved, and the accuracy of disease prevention and control has been improved. and timeliness.
Patent Information
- Application Number
- CN202411456567.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-10-18
AI Technical Summary
The existing pig farm disease warning depends on human experience and post-processing mode, which is inefficient and difficult to ensure the accuracy and timeliness of prediction and processing.
The machine learning-based pig farm disease monitoring and early warning method is used to achieve automated monitoring and early warning of pig farm diseases by acquiring multi-source data sets and building a parallel time-continuous prediction module and pig farm disease early warning module.
It provides accurate disease early warning information for non-infected pig farms and forecasts of the duration of diseased pig farms turning negative, which reduces the workload of pig farm staff, provides them with scientific decision-making basis, and improves the accuracy of disease prevention and control. and timeliness.
Smart Images

Figure CN119007412B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pig farm disease early warning, and more specifically, to a pig farm disease monitoring and early warning method and system based on machine learning. Background Art
[0002] With the continuous expansion of breeding scale and the increase of breeding density, the prevention and control of pig farm diseases has become increasingly important and complex. However, most pig farms are still highly dependent on human experience and post-processing mode in disease warning and treatment. This mode is not only inefficient, but also difficult to ensure the accuracy and timeliness of prediction and treatment. In addition, information communication and collaboration in the process of disease prevention and control mostly rely on manual methods such as chat software and same-call, which leads to poor information transmission and limited response speed, further affecting the early detection, diagnosis and treatment of diseases.
[0003] In view of the above problems, there is an urgent need for a system that can automatically guide the early warning of pig farm diseases, so as to achieve real-time monitoring, intelligent analysis and rapid response to the health status of pig farms. The present invention proposes a method that can automatically guide early warning of pig farm diseases. The method can output early warning information of non-diseased pig farms and the duration of negative conversion of infected pig farms to pig farm staff, providing guidance to pig farms. Summary of the invention
[0004] In order to solve the above technical problems, the present invention proposes a pig farm disease monitoring and early warning method and system based on machine learning, with the aim of providing disease warning information for non-diseased pig farms and prediction of the duration of disease conversion to negative in diseased pig farms through automated process design and intelligent analysis.
[0005] The first aspect of the present invention provides a method for monitoring and early warning of pig farm diseases based on machine learning, comprising:
[0006] Obtain production characteristic-related data of the target pig farm area and observation data within the specified observation period, construct a multi-source data set, divide it into training set and test set, and perform data preprocessing;
[0007] Constructing a parallel time duration prediction module and a pig farm disease early warning module based on a machine learning method, and using the training set and the test set to train the time duration prediction module and the pig farm disease early warning module;
[0008] Determine whether there is an illness in the target pig farm area within the preset observation period according to the multi-source data set, and if there is an illness, call the time duration prediction module to predict the remaining duration of the illness in the pig farm;
[0009] If there is no disease, the pig farm disease early warning module is called to predict the future disease probability based on the multi-source data set, and generate early warning information according to the future disease probability.
[0010] In this solution, a multi-source data set is constructed, divided into training set and test set, and data preprocessing is performed, specifically:
[0011] Divide the target pig farm area into regions according to the existing stalls, extract production feature-related data and observation data based on preset indicators during a specified observation period in each stall area, and match the production feature-related data and the observation data with the pig farm stall identification ID;
[0012] Collecting raw data and storing it based on a preset path, removing raw data whose duration does not meet preset requirements, aggregating the cleaned multi-source data to construct a multi-source data set, and determining the construction feature time range corresponding to the multi-source data set;
[0013] Preset a data set division time rule, divide the data samples in the multi-source data set according to the data set division time rule, and generate a training set and a test set;
[0014] In the training set, discrete data samples are encoded and corresponding codebooks are established. Continuous data samples are standardized. For those with opposing features, one-hot encoding is used for preprocessing.
[0015] In the test set, the codebook, mean, and standard deviation obtained from the training set are used for data preprocessing. If a discrete data sample is not in the codebook, the data sample is encoded as 0. For opposing features, one-hot encoding is used for preprocessing.
[0016] In this solution, the time duration prediction module is specifically:
[0017] Based on the LGBM Regressor model, a time-continuous prediction module is constructed. The model parameters of the LGBM Regressor model are obtained by optimizing the improved particle swarm algorithm. The particle swarm parameters are initialized and the fitness value of the current position is calculated. The optimal fitness value and the optimal position are updated.
[0018] The elite differential mutation is introduced to improve and optimize the particle swarm algorithm. The information exchange between elite individuals is strengthened through elite differential mutation, the fitness value of the new position of the particle is calculated and updated, and the global optimal position and fitness value are recorded. When the termination condition is met, the optimal parameters of the time duration prediction module are output;
[0019] The discrete features and continuous features of the training data samples in the training set are associated and spliced, and the spliced features are used to train the LGBM Regressor model to obtain the trained time-continuous prediction module.
[0020] In this solution, the time duration prediction module is supervised by regularized MSE loss, and its loss function is It is expressed as:
[0021] ,
[0022] in is the training set, To predict the remaining duration of the disease, is the remaining duration of the actual condition, is the regularization coefficient, is the model parameter.
[0023] In this solution, the pig farm disease early warning module is specifically:
[0024] The optimized and improved particle swarm algorithm is called to obtain the optimal model parameters of the LGBM Classifier model, and a pig farm disease early warning module is constructed based on the optimal model parameters. The characteristics related to pig farm diseases and the characteristics of the incidence are obtained according to the multi-source data set, and the pig farm disease early warning module is trained;
[0025] Clustering the disease-related characteristics and morbidity characteristics of the pig farm, matching the clusters in the clustering results with the pig farm disease categories, and performing data balancing processing on the clustered clusters;
[0026] The data samples after data balancing are associated and spliced, and the spliced features are used to train the LGBMClassifier model to obtain the trained pig farm disease warning module.
[0027] In this scheme, the clustering clusters are processed for data balancing, specifically:
[0028] Define a majority class sample set and a minority class sample set by the number of samples in the cluster, and select a data sample from the minority class samples as a root sample;
[0029] Selecting Euclidean distance as the metric function, obtaining K samples closest to the root sample to generate a neighbor sample set, and selecting one neighbor sample from the neighbor sample set as an auxiliary sample for sample synthesis;
[0030] A new sample is synthesized by performing random difference between the root sample and the auxiliary sample, and the new sample is added to a new synthetic data sample set, so as to increase the diversity of minority class samples through the new synthetic data sample set.
[0031] In this scheme, the pig farm disease warning module is trained by the Multiclass logloss loss function. The data set of data samples and disease categories, and its loss function It is expressed as:
[0032] ,
[0033] in is the indicator function, when the data sample Belongs to the disease category 1 if yes, 0 otherwise. For the prediction data sample Belongs to the disease category probability.
[0034] The second aspect of the present invention provides a pig farm disease monitoring and early warning system based on machine learning, the system comprising: a data input module, a sample generation module, a time duration prediction module, a pig farm disease early warning module and a prediction output module;
[0035] The data input module is used to input the production-related characteristic data of the pig farm, the pig farm identification ID and the observation period characteristic data based on the preset indicators in the specified observation period;
[0036] The sample generation module is used to divide the training set and the test set and pre-process the data to construct the model training sample;
[0037] The time duration prediction module training is based on the time duration prediction module of the LGBMRegressor model, which is used to predict the remaining duration of the disease in the pig farm where the disease occurs during the observation period;
[0038] The pig farm disease early warning module training is based on the LGBMClassifier model. For the pig farms with no disease during the observation period, the future disease probability is predicted, and whether the disease condition will occur is determined according to the future disease probability;
[0039] The prediction output module obtains the prediction output of the time duration prediction module and the pig farm disease early warning module according to the input data, and performs a visual display of the prediction output results.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] The method of the present invention provides accurate disease warning information for non-diseased pig farms and prediction of the duration of negative disease conversion in infected pig farms. The above not only reduces the workload of pig farm staff, but also provides them with a scientific basis for decision-making. Pig farm staff can quickly formulate and adjust prevention and control strategies based on the warning information and prediction results provided by the system, thereby improving work efficiency and prevention and control effects.
[0042] The method of the present invention realizes real-time monitoring and collection of pig farm environmental parameters and pig health data by integrating modern technologies such as the Internet of Things and sensors, ensuring the comprehensiveness and accuracy of the data. Based on these real-time data, combined with big data analysis and machine learning algorithms, the system can automatically identify abnormal data, predict potential disease risks, and send early warning information to sales staff at the early stage of the disease. The early warning mechanism greatly improves the accuracy and timeliness of disease prevention and control, and helps to take effective measures before the disease spreads and reduce economic losses. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments or exemplary embodiments of the present invention, the drawings required for use in the embodiments or exemplary descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained according to the drawings without paying creative work.
[0044] Figure 1 A flow chart of a pig farm disease monitoring and early warning method based on machine learning is shown;
[0045] Figure 2 A framework diagram of a time duration prediction module is shown;
[0046] Figure 3 The framework diagram of the pig farm disease early warning module is shown;
[0047] Figure 4 A block diagram of a pig farm disease monitoring and early warning system based on machine learning is shown. DETAILED DESCRIPTION
[0048] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0049] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0050] Figure 1 A flow chart of a pig farm disease monitoring and early warning method based on machine learning is shown.
[0051] like Figure 1 As shown, this embodiment provides a pig farm disease monitoring and early warning method based on machine learning, including:
[0052] S102, obtaining production characteristic-related data of the target pig farm area and observation data within a specified observation period, constructing a multi-source data set, dividing the data into a training set and a test set, and performing data preprocessing;
[0053] S104, constructing a parallel time duration prediction module and a pig farm disease early warning module based on a machine learning method, and training the time duration prediction module and the pig farm disease early warning module using the training set and the test set;
[0054] S106, judging whether there is an illness in the target pig farm area within the preset observation period according to the multi-source data set, and if there is an illness, calling the time duration prediction module to predict the remaining duration of the illness in the pig farm;
[0055] S108, if there is no disease, call the pig farm disease warning module to predict the future disease probability based on the multi-source data set, and generate warning information according to the future disease probability.
[0056] It should be noted that the target pig farm area is divided into regions according to the existing pens, and the production feature-related data and the observation data based on preset indicators during the specified observation period are extracted in each pen area, and the production feature-related data and the observation data are matched with the pig farm identification ID and the pen identification ID; the duration data of the pig farm where the disease first occurred during the specified observation period and multidimensional data such as production data and observation data are obtained as raw data, the raw data is collected and stored based on a preset path, the raw data whose duration does not meet the preset requirements is eliminated, the multi-source data after data cleaning are aggregated to construct a multi-source data set, and the construction feature time range corresponding to the multi-source data set is determined; a data set division time rule is preset, and the data samples in the multi-source data set are divided according to the data set division time rule to generate a training set And test set ; Preferably, the training set of the time duration prediction module is divided into time ranges , test set division time range ;in For the running time, take The samples of the first 100 days are used as the test set. Push the training set forward N days, The minimum time must not be less than the minimum time of the data set.
[0057] Use the training set and test set to preprocess the data. In the training set, encode the discrete data samples, count all the different feature values that appear in the discrete features, and correspond them to an integer id (starting from 1) to establish the corresponding code book;
[0058] For continuous data samples Perform standardization and calculate the mean of all feature values in the training set and standard deviation , and standardize it. The training set data samples after standardization It is expressed as: ;
[0059] For contradictory features, one-hot encoding is used for preprocessing. For example, for "rectified" and "unrectified", OneHot Encoder is used to define "rectified" as [1,0] and "unrectified" as [0,1].
[0060] The codebook obtained from the training set is used in the test set. , Standard Deviation Conduct data sampling Preprocessing, test set data samples after preprocessing It is expressed as: ;
[0061] If the discrete data sample is not in the codebook, the data sample is encoded as 0;
[0062] For contradictory features, one-hot encoding is used for preprocessing. For example, for "rectified" and "unrectified", OneHot Encoder is used to define "rectified" as [1,0] and "unrectified" as [0,1].
[0063] Preferably, the disease characteristics are indexed from the disease record table. This feature is divided into four categories (no disease, disease within 1-7 days, 8-14 days, and 15-21 days). The probability of no disease is negated to get the probability of disease within 1-21 days, which is used as the training output feature. Finally, the required features are indexed from positive data, production data, partition detection data, hardware facility data, geographic location information data, etc. The training set of the pig farm disease warning module is divided into time ranges , test set division time range , T1 is the right boundary of the training set time. Since it is necessary to predict the probability of disease occurrence in the next 21 days, in order to generate appropriate test samples, the right boundary of the test set time is set to T-21.
[0064] For continuous data samples Perform standardization and calculate the mean of all feature values in the training set and standard deviation , and standardize it. The training set data samples after standardization It is expressed as: ;
[0065] The codebook obtained from the training set is used in the test set. , Standard Deviation Conduct data sampling Preprocessing, test set data samples after preprocessing It is expressed as: ;
[0066] If the discrete data sample is not in the codebook, the data sample is encoded as 0.
[0067] Figure 2 A framework diagram of the time duration prediction module is shown.
[0068] It should be noted that the time-continuous prediction module is constructed based on the LGBM Regressor model. The model parameters of the LGBM Regressor model are obtained by optimizing the improved particle swarm algorithm, the particle swarm parameters are initialized and the fitness value of the current position is calculated, and the optimal fitness value and the optimal position are updated. The elite differential mutation is introduced to improve and optimize the particle swarm algorithm. The elite differential mutation is used to strengthen the information exchange between elite individuals, which is conducive to optimizing the search direction. The elite differential mutation is expressed as:
[0069] ,
[0070] in represents the evolved particle, represents the suboptimal solution and the third optimal solution of the particle, Represents a random number between 0 and 1.
[0071] Calculate the fitness value of the updated particle's new position, and record the global optimal position and fitness value. According to whether the maximum number of iterations meets the termination condition, output the optimal parameters of the time duration prediction module when the termination condition is met; associate and splice the discrete features and continuous features of the training data samples in the training set, use the spliced features to train the LGBMRegressor model, and obtain the trained time duration prediction module; construct prediction samples based on the characteristics of partition detection data, pig farm production mortality, production month-on-month characteristics, pig farm surrounding situation characteristics, etc., and judge whether the target pig farm area has an illness during the preset observation period based on the detection data indicators. If an illness exists, use the prediction sample as the input of the time duration prediction module to obtain the remaining duration of the pig farm disease.
[0072] The time duration prediction module is supervised by regularized MSE loss, and its loss function is It is expressed as:
[0073] ,
[0074] in is the training set, To predict the remaining duration of the disease, is the remaining duration of the actual condition, is the regularization coefficient, is the model parameter.
[0075] Figure 3 The framework diagram of the pig farm disease early warning module is shown.
[0076] It should be noted that a pig farm disease early warning module is constructed based on the LGBM Classifier model, and the optimized and improved particle swarm algorithm is called to obtain the optimal model parameters of the LGBM Classifier model. The pig farm disease early warning module is constructed based on the optimal model parameters, and the characteristics related to pig farm diseases and the characteristics of the incidence are obtained from indexes such as positive data, production data, partition detection data, hardware facility data, and geographic location information data, and the pig farm disease early warning module is trained;
[0077] The disease-related characteristics and morbidity characteristics of the pig farm are clustered, the clusters in the clustering results are matched with the pig farm disease categories, and the cluster clusters are subjected to data balancing processing; the majority class sample set and the minority class sample set are defined by the number of samples in the cluster clusters, and data samples are selected from the minority class samples as root samples; the Euclidean distance is selected as the metric function, and the K samples closest to the root sample are obtained to generate a neighbor sample set, and one neighbor sample is randomly selected from the neighbor sample set as an auxiliary sample for sample synthesis; a new sample is synthesized by performing random difference between the root sample and the auxiliary sample, and the new sample is added to the newly synthesized data sample set, and the diversity of the minority class samples is increased through the newly synthesized data sample set, the classification results of the minority class samples are improved, and the classification accuracy of the overall model is improved.
[0078] According to the data samples after data balancing processing, the associated splicing is performed, and the LGBMClassifier model is trained using the spliced features to obtain the trained pig farm disease warning module; for the pig farms with no disease as of the boundary of the observation period L-1 day, the prediction samples are constructed based on the positive disease situation of the pig farm, the zoning detection situation, the mortality situation of the pig farm, the production month-on-month characteristics, the characteristics of the surrounding situation of the pig farm and the time context characteristics, and the new disease risk on L+1~L+7 days, L+8~L+14 days, L+15~L+21 days and L+1~L+21 days is predicted, and the predicted disease probability is output in the form of probability. The pig farm disease warning module is trained using the Multiclass logloss loss function. The data set of data samples and disease categories, and its loss function It is expressed as:
[0079] ,
[0080] in is the indicator function, when the data sample Belongs to the disease category 1 if yes, 0 otherwise. For the prediction data sample Belongs to the disease category The LGBM Classifier model is trained using the Multiclass logloss loss function. In a multi-classification problem, each category has a probability prediction value, and Multiclass logloss is an indicator that measures the difference between the predicted probability distribution and the actual distribution.
[0081] Figure 4 A block diagram of a pig farm disease monitoring and early warning system based on machine learning is shown.
[0082] This embodiment provides a pig farm disease monitoring and early warning system based on machine learning, which includes: a data input module, a sample generation module, a time duration prediction module, a pig farm disease early warning module and a prediction output module;
[0083] The data input module is used to input the production-related characteristic data of the pig farm, the pig farm identification ID and the observation period characteristic data based on the preset indicators in the specified observation period;
[0084] The sample generation module is used to divide the training set and the test set and pre-process the data to remove data with a relatively short duration; index the characteristics of the disease from the historical disease record data, which are divided into four categories (no disease, disease within 1-7 days, 8-14 days, and 15-21 days), where the probability of no disease is the opposite of the probability of disease within 1-21 days, which is used as the training output feature; finally, the required features are indexed from the disease data, production data, partition detection data, hardware facility data, geographic location information data, etc., to construct the model training sample;
[0085] The time duration prediction module training is based on the LGBM Regressor model, which is used to predict the remaining duration of the disease in the pig farms where the disease occurs during the observation period, that is, the duration relative to the first onset of the disease;
[0086] The pig farm disease early warning module training is based on the LGBM Classifier model, which is used for pig farms that have not been sick during the observation period to predict whether they will be sick in the future. Specifically, for pig farms that have not been sick as of the observation period boundary L-1 day, the risk of new disease on L+1~L+7 days, L+8~L+14 days, L+15~L+21 days and L+1~L+21 days is predicted and displayed in the form of probability;
[0087] The prediction output module obtains the prediction output of the time duration prediction module and the pig farm disease warning module according to the input data, and performs a visual display of the prediction output results to help users understand the disease occurrence and risk warning information of the pig farm.
[0088] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0089] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0090] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0091] Those skilled in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.
[0092] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0093] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A pig farm disease monitoring and early warning method based on machine learning, characterized in that: The following steps are involved: Obtain production characteristic-related data of the target pig farm area and observation data within the specified observation period, construct a multi-source data set, divide it into training set and test set, and perform data preprocessing; Constructing a parallel time duration prediction module and a pig farm disease early warning module based on a machine learning method, and using the training set and the test set to train the time duration prediction module and the pig farm disease early warning module; Determine whether there is an illness in the target pig farm area within the preset observation period according to the multi-source data set, and if there is an illness, call the time duration prediction module to predict the remaining duration of the illness in the pig farm; If there is no disease, the pig farm disease early warning module is called to predict the probability of future disease based on the multi-source data set, and early warning information is generated according to the probability of future disease; The time duration prediction module is specifically: Based on the LGBM Regressor model, a time-continuous prediction module is constructed. The model parameters of the LGBM Regressor model are obtained by optimizing the improved particle swarm algorithm. The particle swarm parameters are initialized and the fitness value of the current position is calculated. The optimal fitness value and the optimal position are updated. The elite differential mutation is introduced to improve and optimize the particle swarm algorithm. The information exchange between elite individuals is strengthened through elite differential mutation, the fitness value of the new position of the particle is calculated and updated, and the global optimal position and fitness value are recorded. When the termination condition is met, the optimal parameters of the time duration prediction module are output; The discrete features and continuous features of the training data samples in the training set are associated and spliced, and the spliced features are used to train the LGBM Regressor model to obtain the trained time-continuous prediction module; The pig farm disease early warning module is specifically: The optimized and improved particle swarm algorithm is called to obtain the optimal model parameters of the LGBM Classifier model, and a pig farm disease early warning module is constructed based on the optimal model parameters. The characteristics related to pig farm diseases and the characteristics of the incidence are obtained according to the multi-source data set, and the pig farm disease early warning module is trained; Clustering the disease-related characteristics and morbidity characteristics of the pig farm, matching the clusters in the clustering results with the pig farm disease categories, and performing data balancing processing on the clustered clusters; The data samples after data balancing are associated and spliced, and the spliced features are used to train the LGBMClassifier model to obtain the trained pig farm disease warning module.
2. The method for monitoring and early warning of pig farm diseases based on machine learning according to claim 1, characterized in that: Construct a multi-source data set, divide it into training set and test set, and perform data preprocessing, specifically: Divide the target pig farm area into regions according to the existing stalls, extract production feature-related data and observation data based on preset indicators during a specified observation period in each stall area, and match the production feature-related data and the observation data with the pig farm stall identification ID; Collecting raw data and storing it based on a preset path, removing raw data whose duration does not meet preset requirements, aggregating the cleaned multi-source data to construct a multi-source data set, and determining the construction feature time range corresponding to the multi-source data set; Preset a data set division time rule, divide the data samples in the multi-source data set according to the data set division time rule, and generate a training set and a test set; In the training set, discrete data samples are encoded and corresponding codebooks are established. Continuous data samples are standardized. For those with opposing features, one-hot encoding is used for preprocessing. In the test set, the codebook, mean, and standard deviation obtained from the training set are used for data preprocessing. If a discrete data sample is not in the codebook, the data sample is encoded as 0. For opposing features, one-hot encoding is used for preprocessing.
3. The method for monitoring and early warning of pig farm diseases based on machine learning according to claim 1, characterized in that: The time duration prediction module is supervised by regularized MSE loss, and its loss function is It is expressed as: , in is the training set, To predict the remaining duration of the disease, is the remaining duration of the actual condition, is the regularization coefficient, is the model parameter.
4. The method for monitoring and early warning of pig farm diseases based on machine learning according to claim 1, characterized in that: The clusters are processed to balance the data, specifically: Define a majority class sample set and a minority class sample set by the number of samples in the cluster, and select a data sample from the minority class samples as a root sample; Selecting Euclidean distance as the metric function, obtaining K samples closest to the root sample to generate a neighbor sample set, and selecting one neighbor sample from the neighbor sample set as an auxiliary sample for sample synthesis; A new sample is synthesized by performing random difference between the root sample and the auxiliary sample, and the new sample is added to a new synthetic data sample set, so as to increase the diversity of minority class samples through the new synthetic data sample set.
5. The method for monitoring and early warning of pig farm diseases based on machine learning according to claim 1, characterized in that: The pig farm disease warning module is trained by the Multiclass logloss loss function. The data set of data samples and disease categories, and its loss function It is expressed as: , in is the indicator function, when the data sample Belongs to the disease category 1 if yes, 0 otherwise. For the prediction data sample Belongs to the disease category probability.
6. A pig farm disease monitoring and early warning system based on machine learning, characterized in that: The system includes: a data input module, a sample generation module, a time duration prediction module, a pig farm disease early warning module and a prediction output module; The data input module is used to input the production-related characteristic data of the pig farm, the pig farm identification ID and the observation period characteristic data based on the preset indicators in the specified observation period; The sample generation module is used to divide the training set and the test set and pre-process the data to construct the model training sample; The time duration prediction module training is based on the time duration prediction module of the LGBM Regressor model, which is used to predict the remaining duration of the disease in the pig farm where the disease occurs during the observation period; The pig farm disease early warning module training is based on the LGBM Classifier model. For the pig farms with no disease during the observation period, the future disease probability is predicted, and whether the disease condition will occur is determined according to the future disease probability; The prediction output module obtains the prediction output of the time duration prediction module and the pig farm disease early warning module according to the input data, and performs a visual display of the prediction output results; The time duration prediction module is specifically: Based on the LGBM Regressor model, a time-continuous prediction module is constructed. The model parameters of the LGBM Regressor model are obtained by optimizing the improved particle swarm algorithm. The particle swarm parameters are initialized and the fitness value of the current position is calculated. The optimal fitness value and the optimal position are updated. The elite differential mutation is introduced to improve and optimize the particle swarm algorithm. The information exchange between elite individuals is strengthened through elite differential mutation, the fitness value of the new position of the particle is calculated and updated, and the global optimal position and fitness value are recorded. When the termination condition is met, the optimal parameters of the time duration prediction module are output; The discrete features and continuous features of the training data samples in the training set are associated and spliced, and the spliced features are used to train the LGBM Regressor model to obtain the trained time-continuous prediction module; The pig farm disease early warning module is specifically: The optimized and improved particle swarm algorithm is called to obtain the optimal model parameters of the LGBM Classifier model, and a pig farm disease early warning module is constructed based on the optimal model parameters. The characteristics related to pig farm diseases and the characteristics of the incidence are obtained according to the multi-source data set, and the pig farm disease early warning module is trained; Clustering the disease-related characteristics and morbidity characteristics of the pig farm, matching the clusters in the clustering results with the pig farm disease categories, and performing data balancing processing on the clustered clusters; The data samples after data balancing are associated and spliced, and the spliced features are used to train the LGBMClassifier model to obtain the trained pig farm disease warning module.
Citation Information
Patent Citations
Fish disease early warning method and system
CN117611380A
Livestock abnormal behavior intelligent monitoring method and system based on time dimension, computing device and readable storage medium
CN118736665A