Changes in behavioral activity are increasingly recognized as a useful indicator of dairy cows' health and welfare. The classifying of changes in behavioral activity can be useful in early detection and prevention of diseases, and monitoring dairy cows' behavioral activity helps farmers to take a comprehensive view of the dairy cows' estrus time. The aim of this study is to automatically measure and distinguish several behavior activities of dairy cows from accelerometer data. The study consists of 2 parts, namely, wireless leg sensor and binary decision-tree algorithm. The wireless leg sensor was designed to collect test data, which integrates microcontroller MSP430F149IMP, tri-axial accelerometer ADXL345, and radio frequency module CC1101 to meet the requirements of accurately collecting data of the acceleration of dairy cows, and long-term reliable transmission of data. The binary decision-tree algorithm was designed to classify the behavior of dairy cows. Firstly, 24 statistical features describing the magnitude, symmetry, steepness, variability, uncertainty and angle of the three-axis acceleration of cow legs were selected. Secondly, the best classification behavior category and optimal threshold of each statistical feature were obtained by constructing ROC(receiver operating characteristic) curve. Then the information gain is used as the selection criterion for the split attribute of the binary decision-tree model. Finally, a optimal binary decision tree classification model is constructed to classify and recognize the dairy cow motion behavior. Compared with the traditional binary decision-tree algorithm, the innovation of the algorithm is as follows: Firstly, the ROC curve principle is used to ensure the classification and threshold of each statistical feature to select the local optimal. Then the information gain is used as the split attribute selection standard, and the binary decision-tree classification model is constructed to realize the overall optimal classification of the behavior characteristics of the dairy cows. The results illustrate that the optimal binary decision-tree algorithm can accurately classify 6 types of biologically relevant behavior: standing (88.59% sensitivity, 83.35% precision, and 85.89% F1 score ), lying (85.59% sensitivity, 86.04% precision, and 86% F1 score), normal walking (73.91% sensitivity, 84.25% precision, and 78.74% F1 score), active walking (75.75% sensitivity, 74.46% precision, and 75.1% F1 score), standing up (67.63% sensitivity, 67.81% precision, and 67.72% F1 score), and lying down (66.96% sensitivity, 65.06% precision, and 65.99% F1 score). The highest sensitivity was 88.59% for standing and the sensitivity was good for all classes of behavior except standing up and lying down. The best precision was achieved for standing, lying, and normal walking. The precision for active walking classification was slightly lower but substantially better than those for standing up and lying down. Standing and lying behavior were classified correctly to a high degree, but were also misclassified as other behavior. Normal walking was mainly misclassified as either standing or active walking (18.79% of the cases). Active walking was misclassified most often as standing or normal walking (18.43% of the cases). Standing up and lying down were mostly confused with each other (15.53% and 14.92% of the cases, respectively). The average sensitivity, the average precision and the average F1 score of the classification are 76.47%, 76.83%, and 76.57% respectively. Compared with the traditional ID3 (iterative dichotomiser 3) decision-tree algorithm, they are increased by 5.71 percentage points, 5.4 percentage points and 5.61 percentage points respectively; they are increased by 7.51 percentage points, 8.02 percentage points and 7.77 percentage points respectively compared with the K-means clustering algorithm, and 6.77 percentage points, 6.72 percentage points and 6.57 percentage points respectively compared with the support vector machine algorithm. The experimental results show that the optimal binary decision-tree algorithm has the characteristics of simple classification rules and high classification accuracy. This research of the method can provide an effective theoretical support for improving the classification accuracy of dairy cow behavior. © 2018, Editorial Department of the Transactions of the Chinese Society of Agricultural Engineering. All right reserved.