Crab aggressive classification method based on kmeans clustering and support vector machine
By combining KMeans clustering and SVM models, the problems of accuracy and efficiency in crab aggression assessment were solved, enabling efficient classification of crab aggressive behavior and selection of superior varieties. This simplified the crab aggression assessment indicators and improved detection efficiency and breeding accuracy.
Patent Information
- Application Number
- CN202410657293.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-25
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-05-25
AI Technical Summary
Existing technologies lack efficient methods for assessing aggression in crab farming, which makes crabs prone to cannibalism in limited space and resource competition, affecting growth rate and farming yield. Furthermore, human factors can lead to variations in animal behavior studies, making it difficult to accurately assess and predict crab aggression.
We employed a method based on KMeans clustering and support vector machine (SVM) to record and quantify crab aggressive behavior through mirror experiments and multiple fighting experiments. By combining KMeans clustering analysis and the SVM model, we optimized the classification model to assess crab aggression.
This paper presents an efficient method for classifying crab aggression, which simplifies evaluation indicators, improves detection efficiency and breeding accuracy, reduces economic losses, and promotes the breeding of superior crab varieties and the automated evaluation of aggressive behavior.
Smart Images

Figure CN118864918B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of aquatic product breeding, and particularly relates to a method for crab aggressiveness classification based on KMeans clustering and support vector machine (SVM). BACKGROUND
[0002] Aggressiveness is the attack response of animals to individuals of the same species, and different individuals show low to high attack phenotypes. Crabs generally have strong aggressiveness, and vision, touch and chemical information can all be used as sensory signals for individual fighting. Individuals will not only fight for resources such as food, mates and shelters, but also fight occasionally when they meet. However, in the study of animal personality, the current direction mainly focuses on the quantitative analysis of behavior and the correlation study between different behavior indicators, and is mainly seen in terrestrial vertebrates, and the study of aquatic invertebrates is relatively limited. Moreover, in the study of animal personality, due to the involvement of subjective factors, animal behavior research often has human differences. Therefore, eliminating the influence of subjective factors and solving the classification standard problem have become the key to the study of animal personality and environmental adaptation.
[0003] With the development of research, the method of aquatic animal behavior research has made great progress. At the same time, the development of modern science and technology also provides a technical basis for the study of aquatic animal behavior. Machine learning is an important method for objectively mining data results, which can fully utilize the statistical characteristics of data and obtain more scientific results based on the internal law of data. K-Means clustering is a vector quantization method, which is an unsupervised learning method in machine learning. This research method has been widely used in the study of behavior. Studies have shown that mirror experiments can be used to measure the aggressiveness of individuals, which has been confirmed in the study of zebra fish and three-spined stickleback. In the study of crustaceans, due to differences in morphology and living habits, there are great differences in the measurement methods of the same personality index of different species. In order to ensure that the research species and experimental methods are matched, when selecting experimental methods, repeated measurement experiments are usually conducted to determine the consistency of experimental results in time. At the same time, different measurement methods are selected for the same index to test the correlation between different measurement results, so as to verify the accuracy and stability of the experimental results.
[0004] In traditional pond aquaculture, crabs frequently face challenges such as limited space, food availability, and fluctuating group composition. This makes them more prone to intraspecific cannibalism than in their natural environment, leading to appendage mutilation and even death. Mutilated individuals have greater difficulty feeding, which often hinders their growth, resulting in decreased farmed quality and yield. Efficient aggression assessment techniques can improve detection efficiency, enhance animal welfare, and reduce economic losses. Therefore, this invention utilizes a combination of K-Means clustering and support vector machines to qualitatively assess and predict crab aggression. Summary of the Invention
[0005] The purpose of this invention is to provide a method for classifying crab aggression based on KMeans clustering and support vector machine (SVM) using machine learning, providing an efficient determination method for the future breeding of superior crab varieties.
[0006] To achieve the above-mentioned objectives, the present invention employs the following technical solution:
[0007] A method for classifying crab aggression based on KMeans clustering and Support Vector Machine (SVM) is characterized by the following steps:
[0008] Step 1: Repeat the determination of aggressive behavior of crabs through mirror experiments, with a sample size of no less than 100 crabs;
[0009] Step 2, record and quantify the crab's aggressive behavior:
[0010] First, the aggressive behavior indicators measured by the mirror experiment were divided into two categories: aggressive indicators and non-aggressive indicators. Aggressive indicators included attacking the mirror, the frequency of cheliped display, the cumulative duration of cheliped display, approaching the mirror, and retreating. Non-aggressive indicators included relative movement distance—the ratio of movement distance to carapace width, the frequency of stillness, and the cumulative duration of stillness. Then, the number of occurrences and cumulative time of the above indicators in the mirror experiment were recorded.
[0011] Step 3: Perform time autocorrelation analysis on the measurement results of attack indicators and non-attack indicators to verify the accuracy of the mirror experiment measurement results.
[0012] Step 4: Use KMeans clustering analysis to select the optimal classification value K, and classify and label the crab's aggressiveness:
[0013] 1. The feature vectors of KMeans clustering analysis are set to the five attack indicators determined by the mirror experiment, including attack mirror, chelicerate display, cumulative duration of chelicerate display, approach and retreat;
[0014] 2. First, the raw data is processed by minimax normalization, which is used as the feature values for subsequent analysis;
[0015] 3. Then, draw the elbow chart to screen the optimal classification value K. Select different classification values K, K = 1:10, and perform clustering analysis on the characteristic values by the KMeans function. Draw the elbow chart with the classification values K, K = 1:10 as the horizontal coordinates and the error sum of squares as the vertical coordinates. The K value corresponding to the inflection point of the elbow chart is the optimal solution;
[0016] 4. Classify and label the aggressiveness of crabs according to the optimal classification value K.
[0017] Step 5, perform multiple pair-wise fighting experiments on the experimental crabs;
[0018] Step 6, measure and quantify the fighting behavior of crabs:
[0019] Record and quantify the fighting behavior through the video, including approaching - the experimental individual actively approaching the matched individual, retreating - separating after the interaction between individuals, demonstration - frequency of chelicera display, defense - cumulative duration of chelicera display, cumulative duration of stillness, total number of fighting rounds - the total number of times of fighting between individuals, fighting probability - the ratio of the number of experiments with fighting to all pair-wise experiments, fighting intensity score; the fighting intensity of the individual is the mean value of repeated experiments as the final result;
[0020] Step 7, analyze the differences in fighting behavior between different aggressiveness categories to verify the reliability of the KMeans clustering result;
[0021] Step 8, use support vector machine (SVM) to preliminarily build an aggressiveness classification model for crabs;
[0022] Step 9, optimize the aggressiveness classification model through K-fold cross-validation and grid search;
[0023] Step 10, evaluate the model by the accuracy, sensitivity and specificity of the predicted value;
[0024] Step 11, apply the model to the classification of crab aggressiveness behavior:
[0025] 1. Through 3-5 mirror experiments on a crab, measure three non-aggression indicators in the aggressiveness evaluation indicators, including moving distance - used to calculate the relative moving distance, stillness frequency and cumulative duration of stillness;
[0026] 2. Take the average of the original data of the above three aggressiveness evaluation indicators as the input variables of the aggressiveness classification model;
[0027] 3. Input the variables into the aggressiveness classification model, and the output result is the aggressiveness category of the crab.
[0028] In step 1, the mirror experiment is performed in the following manner:
[0029] Select an observation tank with an opaque white inner wall. Fix the camera directly above the observation tank. Take two mirrors with a width equal to the inner diameter of the observation tank and place them vertically in the middle of the observation tank with their backs touching so that the two sides can be mirrored simultaneously. Insert a partition into each side of the mirror in the observation tank. Place two crabs in the partitions on one side of the partitions, separating the crabs from the mirrors. After acclimatizing for 10 minutes, gently remove the partitions to expose the crabs to the mirrors. Film for 20 minutes and then stop. After each set of films, change the seawater in the observation tank and clean the observation tank.
[0030] In step 1, the filming was conducted under completely dark conditions, and the seawater temperature and salinity were controlled to be consistent with the temporary holding conditions during the experiment.
[0031] In step 1, before performing the mirror experiment...
[0032] 1. Isolate and temporarily keep the crab in an aquarium for two weeks;
[0033] 2. Select no fewer than 100 healthy crabs with intact appendages and in the intermolting stage for the photography experiment;
[0034] 3. After fasting for 24 hours, perform a mirror experiment.
[0035] In step 1, after performing one mirror experiment...
[0036] Return the crabs to the temporary aquarium to recover for 24 hours before conducting the next measurement. Repeat the photography 3-5 times.
[0037] In step 2, the crab's aggressive behavior is recorded and quantified using behavioral analysis software as follows:
[0038] The detection sampling rate is set to 8 frames / second, and the detection method is either dynamic silhouette or grayscale gradient. Lost frame correction and smooth trajectory settings are enabled. The trajectory smoothing configuration is as follows:
[0039] a. Smoothing is performed based on 10 samples before and after each sampling point;
[0040] b. If the moving distance is less than 3 cm, the sampling point will still be set to the previous position;
[0041] c. If the maximum distance moved is greater than 20 cm, the sampling point will be set as missing.
[0042] In step 3, a correlation analysis was performed on the measurement results of attack indicators and non-attack indicators as follows:
[0043] Correlation analysis was used to examine the temporal autocorrelation of crab aggressive behavior. P< 0.05 as the significance level, the correlation coefficient r is in the range of [-1, 1], when r > 0, it means positive correlation between the two, when r < 0, it means negative correlation between the two.
[0044] In step 5, multiple pairing fighting experiments are performed on the experimental crabs, including the following steps:
[0045] After the mirror experiment, select no less than 30% of the experimental crabs to be randomly matched with 3-5 different opponents with similar specifications to perform one-on-one fighting experiments. The carapace width of the matched crabs and the experimental crabs does not differ by more than 10%, and the same matched crab can fight with different experimental crabs; After fasting for 24 hours, place one experimental crab and a matched crab on both sides of the observation tank partition for 10 minutes, add an equal amount of soft body extract of philippine clams to the observation tank as an inducer for fighting behavior, gently remove the partition, and start filming. After continuous filming for 20 minutes, end the filming. After each group of filming is completed, replace the seawater in the observation tank and clean the observation tank; Place the experimental crabs and matched crabs back into the temporary breeding aquarium for 24 hours before the next round of fighting.
[0046] In step 5, red plastic tags are used to mark the backs of all experimental crabs for identification during behavior analysis. Filming is conducted uniformly in a light-free environment, and the seawater temperature and salinity during the experiment are controlled to be consistent with the temporary breeding conditions.
[0047] In step 6, the fighting intensity is divided into 4 levels: 1. Very weak: one individual approaches another and shows aggression, the other shows submission and no physical contact, contact behavior = 0, score 1; 2. Weak: both individuals show aggression, physical contact occurs, until the winner successfully climbs on the other or the loser continuously retreats, pinning + pushing = 0 and hitting + climbing > 0, score 2; 3. Moderate: the fight between the two individuals escalates to pinning and pushing, the loser retreats but constantly demonstrates with chelae, pinning + pushing > 0 and total number of fighting rounds < 5, score 3; 4. Strong: the loser retreats but constantly restarts the fighting process, pinning + pushing > 0; total number of fighting rounds >= 5, score 4.
[0048] In step 6, the fighting behavior of crabs is recorded and quantified using behavior analysis software, and detection and setting are consistent with step 2.
[0049] In step 7, analyze the differences in fighting behavior between different aggression categories and verify the reliability of the KMeans clustering results, including the following steps:
[0050] 1. Fighting behavior indicators include approaching, retreating, showing, defending, stationary cumulative duration, total number of fighting rounds, probability of fighting, and fighting intensity;
[0051] 2. Differences in fighting behavior indicators of crabs in K different aggression categories are compared by SPSS 25.0, with P <0.05 as the significance level;
[0052] 3. If more than 60% of the fighting behavior indicators are significantly different between different aggression categories, it indicates that the KMeans clustering result is reliable as an aggression classification evaluation indicator.
[0053] In step 8, the support vector machine (SVM) is used to preliminarily construct the aggression classification model of crabs, including the following steps:
[0054] 1. In order to simplify the classification process of aggression, the non-aggression indicators (relative movement distance, stationary frequency (the number of times all visible movements stop for more than 5s), and stationary cumulative duration) measured in the mirror experiment and the KMeans clustering result are used as feature vectors for model construction;
[0055] 2. First, the original data of non-aggression indicators of each crab is averaged, and randomly divided into training set and test set, of which 80% or more is used for training, and the rest is used for testing;
[0056] 3. The “svm” function in the R package is used to train the feature vector, and the model effects of 12 combinations of 3 “Type” parameters (C-classification, nu-classification, and one-classification) and 4 kernel functions (linear, polynomial, radial, and sigmoid) in the “svm” function are comprehensively compared, and the optimal combination is selected to preliminarily construct the aggression classification model.
[0057] In step 9, the aggression classification model is optimized by K-fold cross-validation and grid search, including the following steps:
[0058] 1. In the training set, K-fold cross-validation and grid search (K ≥ 10) are established by R language to screen the optimal parameters of the model, including the coefficient of the kernel function (gamma) and the penalty coefficient C (cost);
[0059] 2. The optimal parameters gamma and cost are used to optimize the aggression classification model.
[0060] In step 10, the model is evaluated by the accuracy, sensitivity, and specificity of the predicted value, including the following steps:
[0061] 1. In the test set, apply the optimized aggressive classification model to classify the feature vector using the "predict" function;
[0062] 2. Calculate the accuracy, sensitivity and specificity of the predicted value to evaluate the model;
[0063] 3. When the model accuracy reaches 90% or above, it indicates that the model is good and can be used for aggressive classification; otherwise, go back to step 9 and re-optimize.
[0064] The beneficial effects of the present application are:
[0065] 1. The present application first applies machine learning to the aggressive classification of crabs, combines KMeans clustering and support vector machines, and builds a more convenient and efficient method for individual aggression evaluation.
[0066] 2. The present application also simplifies the qualitative evaluation index of crab aggression, selects the relative moving distance, stationary frequency and stationary cumulative duration to predict the crab aggression category, and provides a behavioral method for crab excellent variety breeding. BRIEF DESCRIPTION OF DRAWINGS
[0067] Figure 1 The flowchart of the method of the present application.
[0068] Figure 2 The schematic diagram for collecting aggressive behavior.
[0069] Figure 3 The top view for collecting aggressive behavior.
[0070] Figure 4 The schematic diagram for collecting fighting behavior.
[0071] Figure 5 The top view for collecting fighting behavior.
[0072] Figure 6 The time repeatability analysis results of the aggressive evaluation index,
[0073] Among them, Figure 6 A attack mirror, Figure 6 B chelae display frequency, Figure 6 C cumulative duration of chelae display, Figure 6 D close to the mirror, Figure 6 E retreat, Figure 6 F stationary cumulative duration, Figure 6 G stationary frequency, Figure 6 H relative moving distance.
[0074] Figure 7 The elbow chart of KMeans clustering. The horizontal coordinate is the classification value k, and the vertical coordinate is the error sum of squares SSE.
[0075] Figure 8 the differences in fighting behavior of crabs of different aggressiveness categories,
[0076] wherein Figure 8 A fighting intensity, Figure 8 B total number of fighting rounds, Figure 8 C frequency of claw display, Figure 8 D cumulative duration of claw display, Figure 8 E cumulative duration of courtship, Figure 8 F fighting probability.
[0077] Figure 9 is a precision network diagram of the SVM model parameters, wherein Gamma is the coefficient of the kernel function, and Cost is the penalty coefficient C. DETAILED DESCRIPTION
[0078] As Figure 1 shown, a method for crab aggressiveness classification based on KMeans clustering and support vector machines, characterized by comprising the following steps:
[0079] Step 1: repeatedly measure the aggressiveness behavior of crabs through mirror experiments, with a sample size of no less than 100 crabs;
[0080] Step 2: record and quantify the aggressiveness behavior of crabs:
[0081] Step 3: perform time autocorrelation analysis on the measurement results of attack indicators and non-attack indicators to verify the accuracy of the mirror experiment measurement results;
[0082] Step 4: use KMeans clustering analysis to screen the optimal classification value K, and classify and label the aggressiveness of crabs;
[0083] Step 5: perform multiple paired fighting experiments on experimental crabs;
[0084] Step 6: measure and quantify the fighting behavior of crabs;
[0085] Step 7: analyze the differences in fighting behavior between different aggressiveness categories to verify the reliability of the KMeans clustering results;
[0086] Step 8: use support vector machines (SVM) to initially build an aggressiveness classification model for crabs;
[0087] Step 9: optimize the aggressiveness classification model through K-fold cross-validation and grid search;
[0088] Step 10: evaluate the model by the accuracy, sensitivity, and specificity of the predicted values;
[0089] Step 11: apply the model to the classification of crab aggressiveness behavior.
[0090] The present invention will now be described in detail below using the swimming crab (Portunus trituberculatus) as an example, in conjunction with the accompanying drawings. The described experiments are only some embodiments of the present invention, not all embodiments. All other embodiments obtained in the art based on the embodiments of the present invention are within the scope of protection of the present invention.
[0091] Step 1: Repeat the determination of aggressive behavior of the swimming crab with three tubercles using mirror experiments;
[0092] 1. Male three-spined swimming crab ( Portunus trituberculatus After being transported back to the laboratory, it was temporarily quarantined and kept in an aquarium (45×30×30 cm, 40.95 L) for two weeks;
[0093] 2. Select healthy, intact, and intermolting swimming crabs (juvenile crabs: n = 101; adult crabs (before sexual maturity): n = 146; adult crabs (after sexual maturity): n = 130) for the photography experiment;
[0094] 3. Aggressive behavior recording devices, such as Figure 2 , 3 As shown, the system includes an infrared night vision camera (HIKVISION, China), a monitor (PHILLIP, China), observation tanks (juvenile crabs: d1 = 12 cm, h = 11.7 cm, 1L; adult crabs: d2 = 60 cm, h = 50 cm, 141L), mirrors (juvenile crabs: 10×10 cm; adult crabs: 58×20 cm), and partitions. The inner wall of the observation tank is opaque white to facilitate information collection by subsequent behavioral analysis software. The camera is fixed directly above the observation tank, and the distance can be adjusted according to the different sizes of crabs, ensuring a clear view of the entire observation tank and the experimental crabs. A key feature of this behavioral acquisition system is the first-ever combination of two mirrors placed vertically along the center line of the observation tank, allowing simultaneous aggression testing of different crabs on both sides. This system not only simulates virtual enemies but also provides the scent of the opponent through the experimental crabs on the other side, offering a more realistic aggression testing scenario.
[0095] 4. After fasting for 24 hours, place the crabs in the observation tank. Separate the crabs from the mirror image using a partition. After acclimatizing for 10 minutes, gently remove the partition, exposing the crabs to the mirror. Film for 20 minutes, then stop. After each set of filming, change the seawater in the observation tank and clean it.
[0096] 5. Return the crabs to the temporary holding aquarium for 24 hours before conducting the next measurement. Repeat the photography 3-5 times. Since crabs are more active in darkness, all photography experiments were conducted under completely dark conditions. During the experiment, the seawater temperature and salinity were controlled to be consistent with the temporary holding conditions.
[0097] 6. Save the video for later analysis.
[0098] Step 2, record and quantify the aggressive behavior of Portunus trituberculatus;
[0099] 1. First, manually add the aggressive behavior indicators measured in the mirror experiment, which are divided into two categories: attack indicators and non-attack indicators. Attack indicators include attacking the mirror, cheliped display frequency, cheliped display cumulative duration, approaching the mirror, and retreating, while non-attack indicators include movement distance, stationary frequency, and stationary cumulative duration;
[0100] 2. Second, set up the observation area. The observation area for the mirror experiment is semi-circular, and two observation areas are drawn in each observation tank;
[0101] 3. Then, set the experimental animal detection conditions to accurately identify the experimental crabs. The detection sampling rate is 8 frames per second, the detection method is dynamic silhouette or gray gradient method, and the loss frame correction and trajectory smoothing settings are turned on. The trajectory smoothing configuration is:
[0102] a. Smooth based on 10 samples before and after each sampling point;
[0103] b. If the movement distance is less than 3 cm, the sampling point will still be set to the previous position;
[0104] c. If the maximum movement distance is greater than 20 cm, the sampling point will be set as missing.
[0105] 4. After correctly identifying the experimental crabs, start behavior collection, and the collection duration is 20 minutes;
[0106] 5. Manually record the collected video and output the quantitative aggressive behavior data of Portunus trituberculatus.
[0107] Step 3, test the time autocorrelation of Portunus trituberculatus aggressive behavior through correlation analysis, and further verify the accuracy of the mirror experiment measurement results;
[0108] 1. Through repeated measurement of the mirror experiment, verify the stability of Portunus trituberculatus aggressive behavior over time.
[0109] 2. Aggressive behavior indicators include attacking the mirror, cheliped display frequency, cheliped display cumulative duration, approaching the mirror, retreating, movement distance, stationary frequency, and stationary cumulative duration;
[0110] 3. The results show that the above 8 aggressive evaluation indicators have significant correlation at different measurement times (P < 0.05, P < 0.05, Figure 6), which also indicates that the mirror experiment method and results used in this experiment are reliable.
[0111] Step 4, the optimal classification value K is screened by KMeans clustering analysis, and the aggressiveness of Portunus trituberculatus is classified and labeled;
[0112] 1. The feature vector of KMeans clustering analysis is the 5 attack indicators measured by mirror experiment, including attack mirror, cheliped display, cumulative duration of cheliped display, approach and retreat;
[0113] 2. First, the original data is normalized by maximum and minimum, as the characteristic value for subsequent analysis;
[0114] 3. Then, the elbow chart is drawn to screen the optimal classification value k. Select different classification values K (K=1:10), and perform clustering analysis on the characteristic values by the "KMeans" function in R package. Take the classification value K (K=1:10) as the horizontal coordinate and the sum of squared errors (SSE) as the vertical coordinate to draw the elbow chart;
[0115] 4. The clustering analysis results show that the optimal classification value K is 2 ( Figure 7 ). Therefore, the aggressiveness of Portunus trituberculatus can be divided into 2 categories: strong and weak.
[0116] Step 5, multiple pair fighting experiments are conducted on the experimental crabs:
[0117] 1. After the mirror experiment, 67 Portunus trituberculatus crabs are randomly selected for fighting experiment. The crabs are randomly matched with 3-5 different opponents of similar size for one-on-one fighting experiment. The fighting behavior collection system consists of infrared night vision camera, display, observation tank and partition ( Figure 4 、 5 ). The difference in carapace width between the matched crabs and the experimental crabs is not more than 10%, and the same matched crab can fight with different experimental crabs;
[0118] 2. After 24 h of fasting, 1 experimental crab and matched crab are placed in the fighting behavior collection system (partition on both sides) for 10 min, gently remove the partition and start shooting, continuous shooting for 20 min, then end. Add equal amount of soft body extract of philippine clams in each observation tank as an inducer for fighting behavior. Replace the seawater in the observation tank after each shooting;
[0119] 3. Put the experimental crabs and matched crabs back into the temporary breeding aquarium for 24 h recovery before the next round of fighting. All experimental crabs are marked with red plastic tags on their carapace for identification in behavior analysis. The shooting experiment is carried out in a light-free environment, and the seawater temperature and salinity during the experiment are controlled to be consistent with the temporary breeding conditions;
[0120] Step 6, measure and quantify the fighting behavior of P. trituberculatus;
[0121] 1. Save the recorded video and record and quantify the fighting behavior by behavior analysis software:
[0122] (1) Manually add fighting behavior indicators. Fighting behavior indicators include approaching, retreating, demonstration (cheliped display frequency), defense (cumulative duration of cheliped display), cumulative duration of stillness, total number of fighting rounds, probability of fighting, and fighting intensity;
[0123] (2) Set the observation area. The observation area for the fighting experiment is circular, with the entire observation tank as the observation area;
[0124] (3) Detection and collection settings are consistent with step 2;
[0125] 2. Manually record the collected video and output the quantified fighting behavior results.
[0126] Step 7, analyze the differences in fighting behavior of P. trituberculatus in different aggressive categories, and verify the reliability of the KMeans clustering results;
[0127] 1. Fighting behavior indicators include approaching, retreating, demonstration (cheliped display frequency), defense (cumulative duration of cheliped display), cumulative duration of stillness, total number of fighting rounds, probability of fighting, and fighting intensity;
[0128] 2. Compare the differences in fighting behavior indicators between P. trituberculatus with different levels of aggressiveness using SPSS 25.0. The results show that demonstration (cheliped display frequency), defense (cumulative duration of cheliped display), cumulative duration of stillness, total number of fighting rounds, probability of fighting, and fighting intensity all have significant differences (P < 0.05), indicating that the KMeans clustering results are reliable as indicators for assessing aggressiveness. Figure 8
[0129] Step 8, use support vector machine (SVM) to preliminarily build an aggressiveness classification model for P. trituberculatus;
[0130] 1. To simplify the classification process of aggressiveness, select non-aggressive indicators (relative movement distance (ratio of movement distance to carapace width), stillness frequency, and cumulative duration of stillness) measured in the mirror experiment and KMeans clustering results as feature vectors for model construction;
[0131] 2. First, take the average of the original data of each crab's non-aggressive indicators (mixed juvenile and adult crabs), and randomly divide them into training set and test set, with 90% for training and 10% for testing;
[0132] 3. Train the feature vector using the "svm" function in the R package, and compare the effects of 12 combinations of 3 "Type" parameters (C-classification, nu-classification, and one-classification) and 4 kernel functions (linear, polynomial, radial, and sigmoid) in the "svm" function. The results show that the C-classification and radial combination is the best, and the optimal combination is used to preliminarily construct the aggressive classification model.
[0133] Step 9, optimize the aggressive classification model through K-fold cross-validation and grid search;
[0134] 1. In the training set, 10-fold cross-validation and grid search are established by R language to screen the optimal parameters of the model, including the coefficient of the kernel function (gamma) and the penalty coefficient C (cost). The results show that the optimal parameters of the model are gamma 0.35 and cost 4.00 (. Figure 9 );
[0135] 2. In the training set, the optimal parameters gamma and cost are used to optimize the aggressive classification model. The results show that there are 126 SVM support vectors, 63 strong groups and 63 weak groups.
[0136] Step 10, evaluate the model by the accuracy, sensitivity and specificity of the predicted value;
[0137] 1. In the test set, the optimized aggressive classification model is applied to classify the feature vector using the "predict" function.
[0138] 2. The prediction results show that the accuracy, sensitivity and specificity of the model are 92%, 84% and 100% respectively, and the SVM model has good classification effect.
[0139] Step 11, apply the model to aggressive classification:
[0140] 1. Take the average of the three non-aggressive indicators of the three-eared Mithrax spinosus attack evaluation indicators measured in the mirror experiment in this experiment, including relative moving distance, static frequency and static cumulative duration, as the input variables of the aggressive classification model;
[0141] 2. Input the above variables into the aggressive classification model to obtain the final aggressive classification result.
[0142] Through example verification, the crab aggressive classification method provided by the application is convenient and efficient, can more accurately evaluate and quantify the aggressive behavior characteristics of crabs, and thus accurately selects in the breeding process and improves the breeding efficiency. Therefore, the application not only has important significance for crab excellent variety breeding, but also has a certain promoting effect on the automatic evaluation of aggressive behavior in future crustacean models.
Claims
1. A method for crab aggressiveness classification based on KMeans clustering and support vector machines, characterized in that Comprising the following steps: Step 1, repeat the determination of crab aggression behavior through mirror experiment, sample size not less than 100; Step 2, record and quantify the aggression behavior of crabs: Firstly, divide the aggression behavior indicators measured by mirror experiment into two categories: attack indicators and non-attack indicators. Attack indicators include attack mirror, cheliped display frequency, cheliped display cumulative duration, approach to mirror and retreat. Non-attack indicators include relative moving distance, i.e. the ratio of moving distance to carapace width, stationary frequency and stationary cumulative duration. Then record the occurrence frequency and cumulative time of the above indicators in the mirror experiment; Step 3, perform time autocorrelation analysis on the results of attack indicators and non-attack indicators to verify the accuracy of the mirror experiment results; Step 4, use KMeans clustering analysis to screen the optimal classification value K, and classify and label the aggression of crabs:
1. The feature vector of KMeans clustering analysis is set as the 5 attack indicators measured by mirror experiment, including attack mirror, cheliped display, cheliped display cumulative duration, approach and retreat; 2. First, perform maximum-minimum normalization on the original data as the characteristic value for subsequent analysis; 3. Then, draw the elbow chart to screen the optimal classification value K: select different classification values K, K = 1:10, perform clustering analysis on the characteristic value by KMeans function, and draw the elbow chart with classification value K, K = 1:10 as the horizontal coordinate and error sum of squares as the vertical coordinate. The K value corresponding to the inflection point of the elbow chart is the optimal solution; 4. Classify and label the aggression of crabs according to the optimal classification value K; Step 5, perform multiple paired fighting experiments on experimental crabs; Step 6, measure and quantify the fighting behavior of crabs: Through the video, record and quantify the fighting behavior, including approach - experimental individuals actively approaching matched individuals, retreat - individuals separating after interacting with each other, demonstration - cheliped display frequency, defense - cheliped display cumulative duration, stationary cumulative duration, total number of fighting rounds - the total number of times individuals fight each other, fighting probability - the ratio of the number of times fighting occurs to all paired experiments, fighting intensity score; The mean value of repeated experiments is taken as the final result; Step 7, analyze the differences in fighting behavior between different aggression categories to verify the reliability of the KMeans clustering results; Step 8, use support vector machine SVM to preliminarily build a classification model of crab aggression; Step 9, optimize the aggression classification model through K-fold cross-validation and grid search; Step 10, evaluate the model by the accuracy, sensitivity and specificity of the predicted value; Step 11, apply the model to the classification of crab aggression behavior:
1. For a crab, measure three non-attack indicators in the aggression evaluation indicators through 3-5 mirror experiments, including moving distance - used to calculate relative moving distance, stationary frequency and stationary cumulative duration; 2. Take the average of the original data of the above 3 aggression evaluation indicators as the input variables of the aggression classification model; 3. Input the variables into the aggression classification model, and the output result is the aggression category of the crab.
2. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 1, the mirror experiment is performed in the following way: An observation cylinder with white inner wall is selected, a camera is fixed above the observation cylinder, two mirrors with the same width as the inner diameter of the observation cylinder are placed in the middle of the observation cylinder with their back sides adhered to each other and perpendicular to the observation cylinder, so that the two side areas can be used for mirror experiment at the same time; a partition is inserted into each of the two side areas of the mirror in the observation cylinder, and two crabs are placed in one side area of each partition, so that the crabs are separated from the mirror by the partition; after 10 minutes of adaptation, the partition is gently removed, and the crabs are exposed in front of the mirror; after 20 minutes of shooting, the experiment is ended; after the shooting of each group is completed, the seawater in the observation cylinder is replaced and the observation cylinder is cleaned.
3. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 2, the aggressive behavior of the crabs is recorded and quantified by behavior analysis software as follows: The sampling rate for detection is set to 8 frames per second, the detection method is dynamic silhouette method or gray gradient method, and the lost frame number correction and trajectory smoothing settings are turned on; the trajectory smoothing configuration is: a. smoothing processing based on 10 samples before and after each sampling point; b. if the moving distance is less than 3 cm, the sampling point is still set to the previous position; c. if the maximum moving distance is greater than 20 cm, the sampling point is set to missing.
4. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 3, the correlation analysis of the attack index and non-attack index measurement results is as follows: Through correlation analysis, the time autocorrelation of the crab aggressive behavior is tested, with P<0.05 as the significance level, the correlation coefficient r is in the range of [-1, 1], when r>0, it indicates that there is a positive correlation between the two, when r<0, it indicates that there is a negative correlation between the two.
5. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 5, the experimental crabs are subjected to multiple paired fighting experiments, including the following steps: After the mirror experiment, select no less than 30% of the experimental crabs to be randomly matched with 3-5 different opponents with similar specifications for one-on-one fighting experiment, the carapace width of the matched crabs and the experimental crabs should not differ by more than 10%, and the same matched crab can fight with different experimental crabs; after fasting for 24 hours, place one experimental crab and a matched crab on both sides of the partition in the observation cylinder for 10 minutes of adaptation, add an equal amount of soft body extract of philippine clams into the observation cylinder as an inducer for fighting behavior, gently remove the partition and start shooting, and after 20 minutes of continuous shooting, the experiment is ended; after the shooting of each group is completed, the seawater in the observation cylinder is replaced and the observation cylinder is cleaned; the experimental crabs and matched crabs are returned to the temporary breeding aquarium for 24 hours of recovery before the next round of fighting.
6. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 6, the fighting intensity is divided into 4 levels:
1. very weak: one individual approaches another individual and shows aggression, the other individual shows submission and no physical contact, contact behavior = 0, score 1 point; 2. weak~weak: both individuals show aggressive behavior, physical contact occurs, until the winner successfully climbs on the opponent or the loser appears persistent retreat, pinch + push = 0 and hit + climb > 0, score 2 points; 3. moderate~moderate: the fight of two individuals escalates to pinch and push, the loser appears retreat but constantly demonstrates with chelae, pinch + push > 0 and total number of fight rounds < 5, score 3 points; 4. strong~strong: the loser constantly restarts the fight process although retreat appears, pinch + push > 0; total number of fight rounds >= 5, score 4 points.
7. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1 wherein In step 7, the differences in fight behavior between different aggression categories are analyzed to verify the reliability of the KMeans clustering results, including the following steps:
1. The fight behavior indicators include approaching, retreating, demonstrating, defending, cumulative duration of stillness, total number of fight rounds, probability of fighting, and fighting intensity; 2. The differences in fight behavior indicators of K different aggression categories of crabs are compared by SPSS 25.0, and P<0.05 is taken as the significance level; 3. If more than 60% of the fight behavior indicators have significant differences between different aggression categories, it indicates that the KMeans clustering results as an aggression classification evaluation indicator are reliable.
8. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 8, the support vector machine is used to preliminarily build an aggression classification model of crabs, including the following steps:
1. To simplify the classification process of aggression, the relative movement distance, cumulative duration of stillness, and stillness frequency determined in the mirror experiment are used as feature vectors, and the KMeans clustering results are used for model building; 2. First, the original data of non-aggression indicators of each crab is averaged, and randomly divided into training set and test set, of which 80% or more is used for training, and the rest is used for testing; 3. The "svm" function in the R package is used to train the feature vector, and the model effects of 12 combinations of 3 "Type" parameters C-classification, nu-classification, and one-classification and 4 kernel functions linear, polynomial, radial, and sigmoid in the "svm" function are comprehensively compared, and the optimal combination is selected to preliminarily build the aggression classification model.
9. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1, wherein In step 9, the aggression classification model is optimized by K-fold cross-validation and grid search, including the following steps:
1. In the training set, K-fold cross-validation and grid search K>=10 are established by R language to screen the optimal parameters of the model, including the coefficient of the kernel function~gamma and the penalty coefficient C~cost; 2. The optimal parameters gamma and cost are used to optimize the aggression classification model.
10. The method for crab aggressiveness classification based on KMeans clustering and support vector machine as claimed in claim 1 wherein In step 10, the model is evaluated by the accuracy, sensitivity, and specificity of the predicted value, including the following steps:
1. In the test set, the optimized aggression classification model is applied, and the "predict" function is used to classify the feature vector; 2. The accuracy, sensitivity, and specificity of the predicted value are calculated to evaluate the model.
3. When the model accuracy reaches 90% and above, it indicates that the model is effective and can be used for attack classification; otherwise, go back to step 9 to optimize again.
Citation Information
Patent Citations
Swimming crab group personality classification method based on K-Means algorithm and application thereof
CN111950598A
Method for distinguishing good and non-good Chinese mitten crab groups
CN116803254A