Abstract:Abstract: Behaviour monitoring of lactating sows is an important research scope in intelligent breeding. Postpartum care of sows provides an effective health guarantee for lactating sows and subsequent productivity improvement, allowing piglets to obtain a good material basis for growth. This study looked into the method of behaviour recognition for lactating sows using wearable devices. The wearable device for data gathering mainly involved the STM32L151CB microprocessor, an MPU9250 9-axis attitude sensor (including an accelerometer, a gyroscope, and a magnetometer), and an SX1268 wireless transmission module. The wireless gateway device received the 9-axis attitude data from the wearable device and forwarded them to the IoT cloud server via the E18-MS1-PCB wireless module. Considering the hardware and network limitations in the practical application scenario, the time-domain feature extraction method and random forest algorithm, which were more suitable for the data stream of low-power wearable devices than other traditional algorithms and artificial neural networks, were selected to conduct this study. The technical process mainly included four steps, namely data acquisition, data pre-processing, feature extraction, and construction of classifiers. Firstly, two wearable devices were attached to a lactating sow’s ear and a hind leg respectively to collect data on six typical daily behaviours, including activity, drinking, eating, nursing, sleeping, and lying. At the same time, a camera was installed above each barn to record the image information of the sow synchronized with the attitude sensor, which was used to tag the data of the attitude sensor to train the supervised machine learning-based model. Secondly, data pre-processing operations included data annotation and data segmentation. Thirdly, features from the segmented data were extracted to reduce the dimension of the model’s input data. In this paper, 4 statistical characteristic quantities, including mean, maximum, minimum, and energy were selected to represent the raw data. Since sensor data could be integrated into a multitude of different ways, three kinds of feature sets were designed to compare the impact of data integration on classification effectiveness. Finally, behaviour classifiers for lactating sows using seven machine learning algorithms were constructed, which were logistic regression, na?ve bayes, support vector machine, decision tree, random forest, fully connected neural network, and convolutional neural network. Based on four commonly used indicators (accuracy, precision, recall, and F1-score), the performance of different feature extraction methods and classification algorithms was comprehensively evaluated. The experimental results showed that the sensor deployed on the hind legs of sows could identify postpartum behaviours in a better way. Using 16-dimensional features of accelerometer data collected from hind legs, the random forest algorithm finally obtained the highest classification accuracy among the seven algorithms. The mean accuracy, mean precision, mean recall, and mean F1-score of the model trained by this method were 96.16%, 96.25%, 96.16%, and 96.20% respectively. In addition, the proposed method was also compared with existing behaviour recognition methods of related work to further validate its superiority. To verify the effectiveness of the proposed method, 3 additional indices (feature dimension, time-consuming, and memory-consuming) were looked into in detail. The comparison experimental results showed that the random forest algorithm got higher recognition accuracy, less time-consuming as well as less memory-consuming than other machine learning recognition algorithms. In particular, the prediction of a piece of data could be completed in 0.52 s for the random forest, with reference[18, 22] of 0.55 and 0.59 s, respectively. In terms of the model size, the random forest model was 1.37 MB, which was 0.28 MB smaller than that of the reference[22]. There were two reasons that contributed to the advantage of the random forest algorithm, one was that the statistical characteristic quantities of the method in this paper could differentiate the data of different behaviours in a better way. The other was that the algorithm could well learn and express the characteristics of different behaviours data, which made it have better generalization ability. The research results could provide a reference for postpartum behavior monitoring and health assessment of sows