SlideShare a Scribd company logo
1 of 25
Download to read offline
d
VIETNAM NATIONAL UNIVERSITY, HANOI
UNIVERSITY OF ENGINEERING AND TECHNOLOGY
STUDENT RESEARCH CONTEST
2015 - 2016
MONITORING AND CLASSIFICATION OF COW
ACTIVITIES USING THREE-DIMENSIONAL
ACCELEROMETERS
Nguyen Thi Huyen Nga QH-2012-I/CQ-Đ
Le Thi Thu Ha QH-2012-I/CQ-Đ
Doan Ba Cuong QH-2012-I/CQ-Đ
Research advisor: Assoc. Prof. Dr Tran Duc Tan
HA NOI - 2016
1
Abstract
Monitoring cattle motion is essential, it helps farmers has a comprehensive view of the
cattle's healthy. However, the issue is not able to supervise the cattle in the long time,
especially raise many cattle. This paper research the method to prognosticate the cattle's
healthy by using a cattle monitoring device that can record the 3-axis acceleration to
analysis. This sensor is used to measure three axes accelerometer data from Viet Nam
Yellow cows during natural behavior in a cage. The data of the accelerometer output
signal is used to modify a simple behavioral classification as: lying, standing and
feeding. Hence, we can identify some of cattle health events such as: lameness, estrus
cycle. The classification results were tested with the model of the cow. In conclusion,
accelerometers are an excellent tool to easily recognize different types of behavior
patterns in cows.
Keywords: cow behavior, decision tree, accelerometer.
2
TABLE OF CONTENTS
Abstract...........................................................................................................................1
List of figures..................................................................................................................3
List of tables ...................................................................................................................4
I. Introduction..............................................................................................................5
II. System design.......................................................................................................6
2.1. Components.......................................................................................................... 7
2.2. Connection and operating principle.......................................................................... 8
III. Proposed method ................................................................................................10
3.1. Calibration.......................................................................................................... 10
3.2. Algorithm ........................................................................................................... 13
IV. Results ................................................................................................................16
4.1. Data from tri-axial accelerometer........................................................................... 16
4.2. Performance of the system .................................................................................... 16
4.3. Define the threshold............................................................................................. 17
4.4. Infection of the window size ................................................................................. 20
V. Conclusion and future work ...............................................................................21
References ....................................................................................................................23
3
List of figures
Figure 1. Block diagram of the system...........................................................................6
Figure 2. Kit Arduino Uno .............................................................................................7
Figure 3. Sensor ADXL345 ............................................................................................7
Figure 4. SD Card Module.............................................................................................8
Figure 5. A real cow behavior’s system .........................................................................9
Figure 6. Calibration of X-axis ....................................................................................11
Figure 7. Calibration Y-axis.........................................................................................12
Figure 8. Calibration Z-axis.........................................................................................12
Figure 9. Algorithm Flow Chart ..................................................................................15
Figure 10. ROC curves to obtain optimal threshold values.........................................19
Figure 11. Sensitivity of the decision-tree algorithm across a range of different
threshold values............................................................................................................20
4
List of tables
Table 1. Pin connection..................................................................................................8
Table 2. Various positions to calibration each axis.....................................................11
Table 3. Performance of the decision-tree algorithm with the different window sizes 21
5
I. Introduction
Vietnam is located in the region of tropical monsoon climate, where is endowed
with cow farming. Dairy farming requires high technique and investment. In fact, 95%
dairy cows (according to statistics from VIETNAM DAIRY ASSOCIATION) in the
country has been scattered raised by small, unskillful households and using traditional
breeding methods. Thanks to applying modern techniques, the management of cattle
get easier and easier. In additions, the price of production are also reduced and saving
labor. Some milk processing companies in Vietnam, where implement advanced
technology in order to increase their livestock numbers and improve productivity and
quality of fresh milk. Such as: TH true milk applying Israel’s technology (AFIMILK)
one of the biggest industrial dairy farms in the world; VINAMILK using electronic chip
wear on neck with the modern system ALPRO provided by DELAVAL. As [1], they
measured the pitch angle of neck of the animal and categorized the behavior of animal
in active (grazing or looking for the grass) and inactive mode (lying down or
ruminating). ... [2] This literature have used accelerometers to classify behavior
activities in dairy cows, but this approach can just discriminate three basic states such
as feeding, lying and standing. Methods recently proposed for automatic behavior
classification in animals are mainly based on different machine-learning algorithms
such as decision-trees [3, 4], k-means [5], SVM [7], and HMMs [6]. In this study we
develop a decision- tree that uses tri-axial accelerometer data from a neck. In particular,
the advanced cow monitoring systems collect and analyze data points on every
individual cow, to forecast some activities in the long time. It will provides farmers with
all of the information that they need and therefore they could be define health problems
or a risk of animals for disease, moreover predicting estrus status. Actually, dairy cows
must calve on intervals of 12-14 months to maximize average daily milk production on
their lifetime. A deficient detection of heat is one of the main factors that negatively
affects calving intervals and reproductive management. Timely insemination is crucial
for reproduction and heat detection is the key to the successful use of artificial
insemination. [8]. When heat excited, activity levels of cows increase significantly.
When cow are sick or lame, their activity will clearly reduce. The study tested a 3D-
accelerometer (ADXL345) without transceiver device, here we record the acceleration
6
data into memory card. The accelerometer was positioned on top of the neck. This paper
is organized as follows: Section II, The components, connection and operating principle
of the integration system. Section III, Proposed methods to improve performance,
function of the system. Section IV, Simulation and experiment results. Finally,
concludes the use of classification method.
II. System design
The system including three main components: Kit Arduino Uno, Sensor
ADXL345 and SD Card Module. We using this Kit to processing data receive from
sensor and write the data after calibration to the SD Card during each period of time.
And, we set two LED to notify the activity of the system. The green LED on when Kit
reading data from sensor and write to SD Card. If any action in this system broken, the
red LED will be on continuously.
Figure 1. Block diagram of the system
7
2.1. Components
2.1.1. Arduino Uno
The Uno is a microcontroller board based on
the ATmega328P. It has 14 digital input/output pins
(of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz quartz crystal, a USB connection,
a power jack, an ICSP header and a reset button.
Figure 2. Kit Arduino Uno
2.1.2. Sensor ADXL345
The ADXL345 is a complete 3-axis acceleration
measurement system with a selectable measurement
range of ±2 g, ±4 g, ±8 g, or ±16 g with g=9.81(m/s2
). It
measures both dynamic acceleration resulting from
motion or shock and static acceleration, such as gravity,
which allows the device to be used as a tilt sensor.
The sensor is a polysilicon surface-micro machined
structure built on top of a silicon wafer. Polysilicon springs suspend the structure over
the surface of the wafer and provide a resistance against acceleration forces.
Deflection of the structure is measured using differential capacitors that consist of
independent fixed plates and plates attached to the moving mass. Acceleration deflects
the beam and unbalances the differential capacitor, resulting in a sensor output whose
Figure 3. Sensor ADXL345
8
amplitude is proportional to acceleration. Phase-sensitive demodulation is used to
determine the magnitude and polarity of the acceleration.
2.1.3. SD Card Module
The Arduino SD Card Shield is a solution for transferring data to and from a standard
SD card
2.2. Connection and operating principle
We're setting up the connection between devices. First of all, that is sensor
ADXL345 which is a small, thin, low power, 3-axis accelerometer with high resolution
(13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos
complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.
The Table 1 describing which pins on the Arduino should be connected to the pins on
the accelerometer:
Table 1. Pin connection
Arduino Pin ADXL345 Pin
10 CS
11 SDA
12 SDO
13 SCL
3V3 VCC
GND GND
Figure 4. SD Card Module
9
The communication between the microcontroller and the SD card using SPI, which
takes place on digital pins 11, 12, and 13 on Arduino Uno.
After that, the connection between SD Card and Arduino is set. In order to using SD
Card we must be check the SD Card, if SD Card is available, we turn the green LED on
and we can read or write data to that. Otherwise, we the red LED is turn on to warning
about the device working not very well. The figure 5 describe a real device for cow
behaviors:
(a)
(b)
Figure 5. A real cow behavior’s system
10
III. Proposed method
3.1. Calibration
Today, there are a lot of good sensors and many are 'good enough' out of the box
for many non-critical applications. The ADXL chips are calibrated at the factory to a
level of precision sufficient for most purposes. But in order to achieve the best possible
accuracy, a sensor should be calibrated in the system where it will be used. Because,
no sensor is perfect, and the sensor is only one component in the measurement system.
Calibration does not change the sensor outputs. But it is a method of improving sensor
performance by removing structural errors in the sensor outputs.
3.1.1. Convert to g values
In order to find the G values from the raw accelerometer data we must scale the
original values. To find the scale we need to know two things: the number of bits used
to represent the original values and the range of acceleration values that can be
represented. The ADXL345 is set up to measure the values with 10 bits. We've set the
range to ± 2, 4, 8, 16g. In this case, we’ve decided using ± 8g range in full resolution.
The range bits basically sets the range of the measurements, so possible configurations
by send 0x10 to register DATA_FORMAT.
writeTo(DATA_FORMAT, 0x10);
Convert the accelerometer value to G's. [10]
With 10 bits measuring over a ±8g range we can find how to convert by using the
equation:
Gs = Measurement Value ×
𝐺−𝑟𝑎𝑛𝑔𝑒
210 in which, Scale =
𝐺−𝑟𝑎𝑛𝑔𝑒
210 .
Gs = Measurement Value ×
16
1024
.
Xg = x × 0.015625; Yg = y × 0.015625; Zg = z × 0.015625;
11
3.1.2. Calibration 3 axis
Calibration can be performed at 6 stationary positions as shown in next table.
Table 2. Various positions to calibration each axis
One method used to get an accurate and reliable 0g reading is to rotate the device from
+1g through -1g. The max value will be +1g and the minimum value will be -1g.
Assuming that the sensitivity is symmetric from zero to positive and from zero to
negative the sensitivity of the device can be calculated by dividing by 2[9].
- Define zero g in X axis
Figure 6. Calibration of X-axis accelerometer
0 20 40 60 80 100 120 140 160 180 200
-5
-4
-3
-2
-1
0
1
2
3
4
5
Number of samples
Acceleration(g)
Calibration X-axis
X-positive
X-negative
X-zero
12
- Define zero g in Y axis
Figure 7. Calibration of Y-axis accelerometer
- Define zero g in Z axis
Figure 8. Calibration of Z-axis accelerometer
- Zero g value also is offset value.
0 20 40 60 80 100 120 140 160 180 200
-5
-4
-3
-2
-1
0
1
2
3
4
5
Number of samples
Acceleration(g)
Calibration Y-axis
Y-positive
Y-negative
Y-zero
0 20 40 60 80 100 120 140 160 180 200
-5
-4
-3
-2
-1
0
1
2
3
4
5
Number of samples
Acceleration(g)
Calibration Z-axis
Z-positive
Z-negative
Z-zero
13
3.2. Algorithm
A decision tree is a tree in which each branch node represents a choice between
a number of alternatives, and each leaf node represents a decision. Decision tree starts
with a root node on which it is for users to take actions. From this node, users can split
each node recursively according to decision tree learning algorithm. The final result is
a decision tree in which each branch represents a possible scenario of decision and its
outcome. Decision tree learning is a method for approximating discrete-valued target
functions, in which the learned function is represented by a decision tree. Decision tree
learning is one of the most widely used and practical methods for inductive inference
[12]. Decision tree has various advantages such as: able to handle both categorical and
numerical data; performs well with large datasets [13]. However, it has some limitations
like: problem in optimal decision tree, don’t generalize well with over- complex trees
[13]. Three are many specific decision-tree algorithms as ID3, C4.5, CART, CHAID.
But, in this study, we use ROC to define threshold with the desire to improve the quality
of decision tree algorithm. Because, ROC analysis is increasingly being recognized as
an important tool for evaluation and comparison of classifiers when the operating
characteristics (i.e. class distribution and cost parameters) are not known at training
time [14].
3.2.1. Feature characteristics
To classify cow behavior activities, we used two different components of the raw
acceleration data: a static and a dynamic component.
The static component of the acceleration is caused by the orientation of the sensor
relative to the gravity field of the earth and can be calculated as a running mean, to
determine the body posture [2, 15].
The dynamic component of the acceleration is caused directly by the movement of the
animal [16, 17]. Overall dynamic body acceleration (ODBA) and its vectorial variation
(VeDBA) represent an aggregated acceleration measure for the subject [16, 17].
Therefore, the dynamic body acceleration is a good candidate to discriminate between
14
behaviors with high dynamic movement (such as feeding) from behaviors with low
dynamic movement (such as standing or lying) [2].
Firstly, we need to know about running mean:
A running mean of set of data points { 𝑎𝑖} 𝑁
𝑖=1
is new set of data points { 𝑠𝑖} 𝑁−𝑛−1
𝑖=1
which
each point is calculated by taking the arithmetic mean of the previous n points.
Secondly, the static acceleration for each axis is derived using a running mean over the
corresponding raw accelerometer data.
µ𝑖 𝑡
= ∑ 𝐴𝑖 𝑡
∗
/𝑆
𝑡+𝑆/2
𝑡−𝑆/2 ,
(1)
in which {
𝑖 = 𝑥, 𝑦, 𝑧; 𝑡: 𝑑𝑎𝑡𝑎 𝑝𝑜𝑖𝑛𝑡
𝑆 = 𝑤𝑖𝑛𝑑𝑜𝑤𝑛 𝑠𝑖𝑧𝑒
𝐴𝑖, 𝐴𝑖
∗
, µ𝑖 𝑡
: 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑 𝑡𝑜 𝑡ℎ𝑒 𝑠𝑡𝑎𝑡𝑖𝑐 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑜𝑚𝑒𝑡𝑒𝑟, 𝑟𝑎𝑤
𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑜𝑚𝑒𝑡𝑒𝑟 𝑑𝑎𝑡𝑎 𝑎𝑛𝑑 𝑟𝑢𝑛𝑛𝑖𝑛𝑔 𝑚𝑒𝑎𝑛, 𝑟𝑒𝑠𝑝𝑒𝑐𝑡𝑖𝑣𝑒𝑙𝑦.
After that, the resulting static acceleration is subtracted from the corresponding raw
accelerometer data.
𝐷𝐵𝐴𝑖 = 𝐴𝑖 𝑡
= |𝐴𝑖 𝑡
∗
− µ𝑖 𝑡
|. (2)
Finally, we obtained values which presented as follows:
ODBA = | 𝐴 𝑋 + 𝐴 𝑌 + 𝐴 𝑍| , (3)
and
VeDBA = √ 𝐴 𝑥
2 + 𝐴 𝑦
2 + 𝐴 𝑧
2. (4)
The component in the Y- axis of the gravitation acceleration varies according to
SCAY: 𝑔⃗ 𝑦 = 𝑔 ∗ cos(180 − 𝛽) (5)
where β is the angle in degrees of the sensor relative to the horizontal.
15
To classify data, there are two thresholds that used in the decision tree algorithm are
calculated as the mean of the static component of the accelerometer in Y-axis
(SCAY) and the mean of VeDBA, respectively. Both means are taking over the
duration of the window selected. [x].
3.2.2. Algorithm flow chart
Figure 9. Algorithm Flow Chart
Data: Feature
characteristics
Low ActivityHigh Activity
Raw accelerometer
data
Standing LyingFeeding
Y N
Mean of VeBDA >
Threshold A
Y N
Mean of SCAY >
Threshold B
16
3.2.3. Moving window size
When calculating the VeDBA and SCAY from raw acceleration data set, it is
essential to define a window size, which make the data and the two thresholds (A and
B) more smoothly for each step of the decision tree. The choice of window size or the
threshold value used can affect the performance of the decision-tree algorithm [2], and
windows ranging from 1 to 600 seconds. In this paper, we use 3 categories of window
size as: 60 s, 300 s, 600 s.
IV. Results
In this section, we will discuss the result from two data sets: the data which were
published in work [2] and the data from the experiments with model of cow. The result
of behavior classification were determined by comparing the percent agreement
between manual observation and the proposed classification method during the entire
experiment. System can distinguish the three main behavior pattern: lying, standing and
feeding. Other behaviors aren’t attached special importance to
Fig.4. Sensor position and orientation.
4.1. Data from tri-axial accelerometer
When the cow is lying or standing, the acceleration is changes little because both
behavior show little overall movement. When the cow is feeding, it move head up and
down so we can observe the change of acceleration. There also the different in the
component of y-axis between lying and standing.
Fig.5. Raw tri-axial accelerometer for lying, standing, feeding.
Fig.6. The running mean of the acceleration in the y-axis (SCAY) and vector dynamic
body acceleration (VeDBA) value under the three behaviors
4.2. Performance of the system
There are many metrics that can be used to measure the performance of o
classification or predictor, different fields have differences for specific metrics due to
different goals [11]. In this paper we consider two performance metrics: sensitivity of
17
classification and precision of classification. Sensitivity and precision are known in
statics as classification function:
- Sensitivity 𝑆𝑒𝑛 =
𝑇𝑃
𝑇𝑃 + 𝐹𝑁
(6)
- Precision 𝑃𝑟𝑒 =
𝑇𝑃
𝑇𝑃 + 𝐹𝑃 (7)
TP (true positive): the number of instances where the behavioural state of interest that
was correctly classified by the algorithm after validation by the visual observer.
FN (false negative): the number of instances where the behavioural state of interest was
visually observed in reality but was incorrectly classified as some other behaviour by
the algorithm.
FP (false positive): the number of times the behavioural state of interest was
(incorrectly) classified by the algorithm but not observed in reality.
TN (true negative): number of instances where the behavioural state of interest was
(correctly) classified as not being observed.
4.3. Define the threshold
The algorithm contain two threshold (A and B). Thresholds A were used to discriminate
between high activities (feeding) and low activities (lying and standing) through the
VeDBA time series. Threshold B were used to discriminate between lying and standing
through the SCAY time series. The performance of the system can be affected by the
choice of these threshold. We use two approach to choice these threshold
Approach 1: Use ROC (receiver operating characteristic) curve to show the true
positive rate TPR (known as sensitivity) against the false positive rate FPR (known as
the false alarm rate) when varying the threshold
𝑇𝑃𝑅 =
𝑇𝑃
𝑇𝑃 + 𝐹𝑁
(8)
18
𝐹𝑃𝑅 =
𝐹𝑃
𝐹𝑃 + 𝑇𝑁
(9)
In this curve, the optimal threshold value is the one that generates the pair of TPR and
FPR values closet to the top left corner which represents the value that separates
perfectly the positives from the negatives.
(a)
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
false positive rate(%)
truepositiverate(%)
ROC curve to obtain threshold A
19
(b)
Figure 10. ROC curves to obtain the best threshold values
Figure 10.a) ROC curve when varying threshold A in range between -0.1 and 0.9g. The
optimal threshold were selected by taking the closet point to the left top corner, with
value of 0.041g.
Figure 10.b) ROC curve when varying threshold B in range between -0.9 and 0.9g. The
overall TPR and overall FPR are defined as the mean of their respective rates for lying
and standing. The optimal threshold were selected by taking the closet point to the left
top corner, with value of -0.055g.
Approach 2: Select both thresholds at the same time by running a comparison of the
performance of the algorithm over a 2-dimentional space range (threshold A and B).
The range of variation was 0.01 to 0.08g for threshold A and -0.3 to 0.3g for threshold
B. Contours illustrate regions with the same sensitivity.
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
false positive rate(%)
truepositiverate(%) ROC curve to obtain threshold B
lying
standing
overall
20
Figure 11. Sensitivity of the decision-tree algorithm across a range of different
threshold values
From the figure we see that the highest overall sensitivity (~85%) occurs when threshold
A is in the range 0.03 to 0.05g and threshold B is in the range -0.08 to 0.1g.
The threshold values obtained using the first approach (0.041g for threshold
A and -0.055g for threshold B) are contained in the regions with the highest overall
sensitivity obtained using the second approach (see Fig. 5). Hence, we used these values
for the thresholds in the decision-tree algorithm.
4.4. Infection of the window size
The choice of window size used can affect the performance of the decision-tree
algorithm. Window size below 60s showed a low overall sensitivity, particularly for
feeding behaviour . At small window sizes it may not be easy to perceive the regular up
and down movements of the cow’s neck while eating, which will result in apparently
low activity values (VeDBA) and hence lead to misclassification. Classification
performance for lying and standing were very similar for all windowsizes but the best
overall accuracies were found above 60s. Window size above 600s result in two few
Threshold for VeDBA
ThresholdforSCAY Sensitivity of system across a range of different threshold values
0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08
-0.2
-0.1
0
0.1
0.2
0.3
0.35
0.4
0.45
0.5
0.55
0.6
0.65
0.7
0.75
0.8
0.85
21
data points for a faire comparison of performance [2]. To explore the effect of the choice
of window size, the performance of the algorithm was calculated using the same input
data, the fixed threshold value and window size in turn 60s, 300s and 600s. The
sensitivity and the precision of the algorithm were obtained in the Table 3.
Table 3. Performance of the decision-tree algorithm with the different window sizes
Window size 60s 300s 600s
Sensitivity
Lying 74.09 74.09 77.42
Standing 82.08 88.46 88.00
Feeding 95.65 97.44 98.78
Overall 83.94 86.66 88.06
Precision
Lying 96.57 97.95 98.63
Standing 47.01 47.92 55.00
Feeding 92.03 93.25 93.10
Overall 78.53 79.71 82.24
Overall sensitivity is calculated as the arithmetic mean sensitivity for the three
behaviors. Overall precision is calculated in the similar way. Table 1 illustrate that the
best performance is obtained at the largest window size of 600s.
V. Conclusion and future work
Our work has shown that accelerometers can be used to recognize some important
behavior pattern in cows. Simple decision-tree classification algorithm was useful in
classification of measured behavior pattern. However, the result of practical
experiments are not satisfied due to some reasons. Our cows were not trained to wear
22
the neck-mounted device, although it is not heavy. It need time to get used to wearing
something without uncomfortable.
With this simple system, it would be feasible to determine the frequency of each
behavior. Hence it can automatically detection the heal problem in cow even in other
similar cattle. It has a good application value.
In the future work, we consider how to enhance the classification performance by
combining the decision tree algorithm with SVM algorithm. More behavior will be
classified by this. Furthermore, pedometer is also used to detect cycle of estrus in cow
through gathering steps. It becomes easy to prevent cow disease, accurately determine
the cow estrus to promote the quality of milk, increase farmers’ income.
A part of this report is presented in the following publication.
Pham Van Thanh, Nguyen Thi Huyen Nga, Le Thi Thu Ha, Do Van Lam, Dinh-
Chinh Nguyen, Duc-Tan Tran, Development of a Real-time Supported System for
Firefighters in Emergency Cases, the 6th International Conference on the Development
of Biomedical Engineering in Vietnam which will take place in Ho Chi Minh, Vietnam
from June 27-29, 2016, accepted.
23
References
[1] Schwager Mac, et al. "Robust classification of animal tracking data." Computers
and Electronics in Agriculture, Vol. 56, No.1, (2007), pp. 46-59.
[2] Diosdado, Jorge A. Vázquez, et al. "Classification of behaviour in housed dairy
cows using an accelerometer-based activity monitoring system." Animal Biotelemetry,
Vol 3, No.1, (2015).
http://en.vbcsd.vn/detail.asp?id=476
[3] Resheff, Yehezkel S., et al. "AcceleRater: a web application for supervised learning
of behavioral modes from acceleration measurements." Movement ecology, Vol. 2,
No.1, (2014), pp. 25.
[4] McClune, David W., et al. "Tri-axial accelerometers quantify behaviour in the
Eurasian badger (Meles meles): towards an automated interpretation of field data."
Animal Biotelemetry Vol. 2, No.1, (2014), pp.1.
[5] Bidder, Owen R., et al. "Love thy neighbour: automatic animal behavioural
classification of acceleration data using the k-nearest neighbour algorithm." PloS one
9.2 (2014): e88609.
[6] Langrock, Roland, et al. "Flexible and practical modeling of animal telemetry data:
hidden Markov models and extensions." Ecology Vol. 93, No.11, (2012), pp.2336-
2342.
[7] Martiskainen, Paula, et al. "Cow behaviour pattern recognition using a three-
dimensional accelerometer and support vector machines." Applied Animal Behaviour
Science Vol.119, No.1, (2009), pp.32-38.
[8] Gray, H.G., Varner, M.A.: Signs of estrus and improving detection of estrus in cattle.
Fact Sheet IRM 6, West Virginia University (1984).
24
[9] Tuck, Kimberly. "Implementing auto-zero calibration technique for
accelerometers." Freescale Semiconductor Application Note, AN3447 (2007).
[10] https://www.sparkfun.com/tutorials/240
[11]
https://en.wikipedia.org/wiki/Binary_classification#Evaluation_of_binary_classifiers
[12] Mitchell, Tom M. "Machine learning." (1997).
[13] https://en.wikipedia.org/wiki/Decision_tree_learning
[14] Ferri, César, Peter Flach, and José Hernández-Orallo. "Learning decision trees
using the area under the ROC curve." ICML. Vol. 2. (2002).
[15] Brown, Danielle D., et al. "Observing the unwatchable through acceleration
logging of animal behavior." Animal Biotelemetry Vol.1, No.1, (2013), pp.1.
[16] Qasem, Lama, et al. "Tri-axial dynamic acceleration as a proxy for animal energy
expenditure; should we be summing values or calculating the vector?." PLoS One 7.2
(2012): e31187.
[17] Gleiss, Adrian C., Rory P. Wilson, and Emily LC Shepard. "Making overall
dynamic body acceleration work: on the theory of acceleration as a proxy for energy
expenditure." Methods in Ecology and Evolution Vol. 2, No.1, (2011), pp.23-33.

More Related Content

Similar to REPORT_STUDENT_RESEARCH_CONTEST

SMART WAIST BELT FOR HEALTH MONITORING
SMART WAIST BELT FOR HEALTH MONITORINGSMART WAIST BELT FOR HEALTH MONITORING
SMART WAIST BELT FOR HEALTH MONITORINGIRJET Journal
 
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...sipij
 
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...sipij
 
IEEE PROJECTS CENTER TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...
IEEE PROJECTS CENTER  TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...IEEE PROJECTS CENTER  TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...
IEEE PROJECTS CENTER TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...ASHOKKUMAR RAMAR
 
Deep learning-based classification of cattle behavior using accelerometer sen...
Deep learning-based classification of cattle behavior using accelerometer sen...Deep learning-based classification of cattle behavior using accelerometer sen...
Deep learning-based classification of cattle behavior using accelerometer sen...IAESIJAI
 
Automation of livestock production system
Automation of livestock production systemAutomation of livestock production system
Automation of livestock production systemAhmad Shah Rasooli
 
IRJET- Diabetes Prediction using Machine Learning
IRJET- Diabetes Prediction using Machine LearningIRJET- Diabetes Prediction using Machine Learning
IRJET- Diabetes Prediction using Machine LearningIRJET Journal
 
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...IRJET Journal
 
Jeevan rakshak patient monitoring system using matuino
Jeevan rakshak patient monitoring system using matuinoJeevan rakshak patient monitoring system using matuino
Jeevan rakshak patient monitoring system using matuinoeSAT Journals
 
Driver Alertness On Android With Face And Eye Ball Movements
Driver Alertness On Android With Face And Eye Ball MovementsDriver Alertness On Android With Face And Eye Ball Movements
Driver Alertness On Android With Face And Eye Ball MovementsIJRES Journal
 
WEARABLE HEALTH MONITORING SYSTEM FOR BABIES
WEARABLE HEALTH MONITORING SYSTEM FOR BABIESWEARABLE HEALTH MONITORING SYSTEM FOR BABIES
WEARABLE HEALTH MONITORING SYSTEM FOR BABIESIAEME Publication
 
IRJET - Smart Maternal Real Time Monitoring using IoT-Technique
IRJET - Smart Maternal Real Time Monitoring using IoT-TechniqueIRJET - Smart Maternal Real Time Monitoring using IoT-Technique
IRJET - Smart Maternal Real Time Monitoring using IoT-TechniqueIRJET Journal
 
Sensors Wield to Detect the Behavior of Humans
Sensors Wield to Detect the Behavior of HumansSensors Wield to Detect the Behavior of Humans
Sensors Wield to Detect the Behavior of HumansIRJET Journal
 
Document from Nithish Shekar.pptx
Document from Nithish Shekar.pptxDocument from Nithish Shekar.pptx
Document from Nithish Shekar.pptxNithish294393
 
Child Activity Recognition Using Accelerometer and RFID Reader
Child Activity Recognition Using Accelerometer and RFID ReaderChild Activity Recognition Using Accelerometer and RFID Reader
Child Activity Recognition Using Accelerometer and RFID ReaderIJRES Journal
 
IRJET- Animal Health Monitoring System using GPS & GSM Modem
IRJET- Animal Health Monitoring System using GPS & GSM ModemIRJET- Animal Health Monitoring System using GPS & GSM Modem
IRJET- Animal Health Monitoring System using GPS & GSM ModemIRJET Journal
 
A gsm enabled real time simulated heart rate monitoring & control system
A gsm enabled real time simulated heart rate monitoring & control systemA gsm enabled real time simulated heart rate monitoring & control system
A gsm enabled real time simulated heart rate monitoring & control systemeSAT Publishing House
 
Evaluating a Potential Commercial Tool for Healthcare Application for People ...
Evaluating a Potential Commercial Tool for Healthcare Application for People ...Evaluating a Potential Commercial Tool for Healthcare Application for People ...
Evaluating a Potential Commercial Tool for Healthcare Application for People ...Artificial Intelligence Institute at UofSC
 

Similar to REPORT_STUDENT_RESEARCH_CONTEST (20)

SMART WAIST BELT FOR HEALTH MONITORING
SMART WAIST BELT FOR HEALTH MONITORINGSMART WAIST BELT FOR HEALTH MONITORING
SMART WAIST BELT FOR HEALTH MONITORING
 
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...
Machine-Learning Estimation of Body Posture and Physical Activity by Wearable...
 
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...
MACHINE-LEARNING ESTIMATION OF BODY POSTURE AND PHYSICAL ACTIVITY BY WEARABLE...
 
IEEE PROJECTS CENTER TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...
IEEE PROJECTS CENTER  TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...IEEE PROJECTS CENTER  TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...
IEEE PROJECTS CENTER TAMBARAM/PALLAVARAM/CHROMPET- a zigbee based animal hea...
 
Deep learning-based classification of cattle behavior using accelerometer sen...
Deep learning-based classification of cattle behavior using accelerometer sen...Deep learning-based classification of cattle behavior using accelerometer sen...
Deep learning-based classification of cattle behavior using accelerometer sen...
 
Automation of livestock production system
Automation of livestock production systemAutomation of livestock production system
Automation of livestock production system
 
IRJET- Diabetes Prediction using Machine Learning
IRJET- Diabetes Prediction using Machine LearningIRJET- Diabetes Prediction using Machine Learning
IRJET- Diabetes Prediction using Machine Learning
 
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...
Comparative Analysis of Heart Disease Prediction Models: Unveiling the Most A...
 
Jeevan rakshak patient monitoring system using matuino
Jeevan rakshak patient monitoring system using matuinoJeevan rakshak patient monitoring system using matuino
Jeevan rakshak patient monitoring system using matuino
 
Driver Alertness On Android With Face And Eye Ball Movements
Driver Alertness On Android With Face And Eye Ball MovementsDriver Alertness On Android With Face And Eye Ball Movements
Driver Alertness On Android With Face And Eye Ball Movements
 
WEARABLE HEALTH MONITORING SYSTEM FOR BABIES
WEARABLE HEALTH MONITORING SYSTEM FOR BABIESWEARABLE HEALTH MONITORING SYSTEM FOR BABIES
WEARABLE HEALTH MONITORING SYSTEM FOR BABIES
 
IRJET - Smart Maternal Real Time Monitoring using IoT-Technique
IRJET - Smart Maternal Real Time Monitoring using IoT-TechniqueIRJET - Smart Maternal Real Time Monitoring using IoT-Technique
IRJET - Smart Maternal Real Time Monitoring using IoT-Technique
 
Sensors Wield to Detect the Behavior of Humans
Sensors Wield to Detect the Behavior of HumansSensors Wield to Detect the Behavior of Humans
Sensors Wield to Detect the Behavior of Humans
 
Document from Nithish Shekar.pptx
Document from Nithish Shekar.pptxDocument from Nithish Shekar.pptx
Document from Nithish Shekar.pptx
 
Behavioral Monitoring Tool for Pigs
Behavioral Monitoring Tool for PigsBehavioral Monitoring Tool for Pigs
Behavioral Monitoring Tool for Pigs
 
Child Activity Recognition Using Accelerometer and RFID Reader
Child Activity Recognition Using Accelerometer and RFID ReaderChild Activity Recognition Using Accelerometer and RFID Reader
Child Activity Recognition Using Accelerometer and RFID Reader
 
IRJET- Animal Health Monitoring System using GPS & GSM Modem
IRJET- Animal Health Monitoring System using GPS & GSM ModemIRJET- Animal Health Monitoring System using GPS & GSM Modem
IRJET- Animal Health Monitoring System using GPS & GSM Modem
 
Electronic Ear Tag for Farm Animals
Electronic Ear Tag for Farm AnimalsElectronic Ear Tag for Farm Animals
Electronic Ear Tag for Farm Animals
 
A gsm enabled real time simulated heart rate monitoring & control system
A gsm enabled real time simulated heart rate monitoring & control systemA gsm enabled real time simulated heart rate monitoring & control system
A gsm enabled real time simulated heart rate monitoring & control system
 
Evaluating a Potential Commercial Tool for Healthcare Application for People ...
Evaluating a Potential Commercial Tool for Healthcare Application for People ...Evaluating a Potential Commercial Tool for Healthcare Application for People ...
Evaluating a Potential Commercial Tool for Healthcare Application for People ...
 

REPORT_STUDENT_RESEARCH_CONTEST

  • 1. d VIETNAM NATIONAL UNIVERSITY, HANOI UNIVERSITY OF ENGINEERING AND TECHNOLOGY STUDENT RESEARCH CONTEST 2015 - 2016 MONITORING AND CLASSIFICATION OF COW ACTIVITIES USING THREE-DIMENSIONAL ACCELEROMETERS Nguyen Thi Huyen Nga QH-2012-I/CQ-Đ Le Thi Thu Ha QH-2012-I/CQ-Đ Doan Ba Cuong QH-2012-I/CQ-Đ Research advisor: Assoc. Prof. Dr Tran Duc Tan HA NOI - 2016
  • 2. 1 Abstract Monitoring cattle motion is essential, it helps farmers has a comprehensive view of the cattle's healthy. However, the issue is not able to supervise the cattle in the long time, especially raise many cattle. This paper research the method to prognosticate the cattle's healthy by using a cattle monitoring device that can record the 3-axis acceleration to analysis. This sensor is used to measure three axes accelerometer data from Viet Nam Yellow cows during natural behavior in a cage. The data of the accelerometer output signal is used to modify a simple behavioral classification as: lying, standing and feeding. Hence, we can identify some of cattle health events such as: lameness, estrus cycle. The classification results were tested with the model of the cow. In conclusion, accelerometers are an excellent tool to easily recognize different types of behavior patterns in cows. Keywords: cow behavior, decision tree, accelerometer.
  • 3. 2 TABLE OF CONTENTS Abstract...........................................................................................................................1 List of figures..................................................................................................................3 List of tables ...................................................................................................................4 I. Introduction..............................................................................................................5 II. System design.......................................................................................................6 2.1. Components.......................................................................................................... 7 2.2. Connection and operating principle.......................................................................... 8 III. Proposed method ................................................................................................10 3.1. Calibration.......................................................................................................... 10 3.2. Algorithm ........................................................................................................... 13 IV. Results ................................................................................................................16 4.1. Data from tri-axial accelerometer........................................................................... 16 4.2. Performance of the system .................................................................................... 16 4.3. Define the threshold............................................................................................. 17 4.4. Infection of the window size ................................................................................. 20 V. Conclusion and future work ...............................................................................21 References ....................................................................................................................23
  • 4. 3 List of figures Figure 1. Block diagram of the system...........................................................................6 Figure 2. Kit Arduino Uno .............................................................................................7 Figure 3. Sensor ADXL345 ............................................................................................7 Figure 4. SD Card Module.............................................................................................8 Figure 5. A real cow behavior’s system .........................................................................9 Figure 6. Calibration of X-axis ....................................................................................11 Figure 7. Calibration Y-axis.........................................................................................12 Figure 8. Calibration Z-axis.........................................................................................12 Figure 9. Algorithm Flow Chart ..................................................................................15 Figure 10. ROC curves to obtain optimal threshold values.........................................19 Figure 11. Sensitivity of the decision-tree algorithm across a range of different threshold values............................................................................................................20
  • 5. 4 List of tables Table 1. Pin connection..................................................................................................8 Table 2. Various positions to calibration each axis.....................................................11 Table 3. Performance of the decision-tree algorithm with the different window sizes 21
  • 6. 5 I. Introduction Vietnam is located in the region of tropical monsoon climate, where is endowed with cow farming. Dairy farming requires high technique and investment. In fact, 95% dairy cows (according to statistics from VIETNAM DAIRY ASSOCIATION) in the country has been scattered raised by small, unskillful households and using traditional breeding methods. Thanks to applying modern techniques, the management of cattle get easier and easier. In additions, the price of production are also reduced and saving labor. Some milk processing companies in Vietnam, where implement advanced technology in order to increase their livestock numbers and improve productivity and quality of fresh milk. Such as: TH true milk applying Israel’s technology (AFIMILK) one of the biggest industrial dairy farms in the world; VINAMILK using electronic chip wear on neck with the modern system ALPRO provided by DELAVAL. As [1], they measured the pitch angle of neck of the animal and categorized the behavior of animal in active (grazing or looking for the grass) and inactive mode (lying down or ruminating). ... [2] This literature have used accelerometers to classify behavior activities in dairy cows, but this approach can just discriminate three basic states such as feeding, lying and standing. Methods recently proposed for automatic behavior classification in animals are mainly based on different machine-learning algorithms such as decision-trees [3, 4], k-means [5], SVM [7], and HMMs [6]. In this study we develop a decision- tree that uses tri-axial accelerometer data from a neck. In particular, the advanced cow monitoring systems collect and analyze data points on every individual cow, to forecast some activities in the long time. It will provides farmers with all of the information that they need and therefore they could be define health problems or a risk of animals for disease, moreover predicting estrus status. Actually, dairy cows must calve on intervals of 12-14 months to maximize average daily milk production on their lifetime. A deficient detection of heat is one of the main factors that negatively affects calving intervals and reproductive management. Timely insemination is crucial for reproduction and heat detection is the key to the successful use of artificial insemination. [8]. When heat excited, activity levels of cows increase significantly. When cow are sick or lame, their activity will clearly reduce. The study tested a 3D- accelerometer (ADXL345) without transceiver device, here we record the acceleration
  • 7. 6 data into memory card. The accelerometer was positioned on top of the neck. This paper is organized as follows: Section II, The components, connection and operating principle of the integration system. Section III, Proposed methods to improve performance, function of the system. Section IV, Simulation and experiment results. Finally, concludes the use of classification method. II. System design The system including three main components: Kit Arduino Uno, Sensor ADXL345 and SD Card Module. We using this Kit to processing data receive from sensor and write the data after calibration to the SD Card during each period of time. And, we set two LED to notify the activity of the system. The green LED on when Kit reading data from sensor and write to SD Card. If any action in this system broken, the red LED will be on continuously. Figure 1. Block diagram of the system
  • 8. 7 2.1. Components 2.1.1. Arduino Uno The Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. Figure 2. Kit Arduino Uno 2.1.2. Sensor ADXL345 The ADXL345 is a complete 3-axis acceleration measurement system with a selectable measurement range of ±2 g, ±4 g, ±8 g, or ±16 g with g=9.81(m/s2 ). It measures both dynamic acceleration resulting from motion or shock and static acceleration, such as gravity, which allows the device to be used as a tilt sensor. The sensor is a polysilicon surface-micro machined structure built on top of a silicon wafer. Polysilicon springs suspend the structure over the surface of the wafer and provide a resistance against acceleration forces. Deflection of the structure is measured using differential capacitors that consist of independent fixed plates and plates attached to the moving mass. Acceleration deflects the beam and unbalances the differential capacitor, resulting in a sensor output whose Figure 3. Sensor ADXL345
  • 9. 8 amplitude is proportional to acceleration. Phase-sensitive demodulation is used to determine the magnitude and polarity of the acceleration. 2.1.3. SD Card Module The Arduino SD Card Shield is a solution for transferring data to and from a standard SD card 2.2. Connection and operating principle We're setting up the connection between devices. First of all, that is sensor ADXL345 which is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. The Table 1 describing which pins on the Arduino should be connected to the pins on the accelerometer: Table 1. Pin connection Arduino Pin ADXL345 Pin 10 CS 11 SDA 12 SDO 13 SCL 3V3 VCC GND GND Figure 4. SD Card Module
  • 10. 9 The communication between the microcontroller and the SD card using SPI, which takes place on digital pins 11, 12, and 13 on Arduino Uno. After that, the connection between SD Card and Arduino is set. In order to using SD Card we must be check the SD Card, if SD Card is available, we turn the green LED on and we can read or write data to that. Otherwise, we the red LED is turn on to warning about the device working not very well. The figure 5 describe a real device for cow behaviors: (a) (b) Figure 5. A real cow behavior’s system
  • 11. 10 III. Proposed method 3.1. Calibration Today, there are a lot of good sensors and many are 'good enough' out of the box for many non-critical applications. The ADXL chips are calibrated at the factory to a level of precision sufficient for most purposes. But in order to achieve the best possible accuracy, a sensor should be calibrated in the system where it will be used. Because, no sensor is perfect, and the sensor is only one component in the measurement system. Calibration does not change the sensor outputs. But it is a method of improving sensor performance by removing structural errors in the sensor outputs. 3.1.1. Convert to g values In order to find the G values from the raw accelerometer data we must scale the original values. To find the scale we need to know two things: the number of bits used to represent the original values and the range of acceleration values that can be represented. The ADXL345 is set up to measure the values with 10 bits. We've set the range to ± 2, 4, 8, 16g. In this case, we’ve decided using ± 8g range in full resolution. The range bits basically sets the range of the measurements, so possible configurations by send 0x10 to register DATA_FORMAT. writeTo(DATA_FORMAT, 0x10); Convert the accelerometer value to G's. [10] With 10 bits measuring over a ±8g range we can find how to convert by using the equation: Gs = Measurement Value × 𝐺−𝑟𝑎𝑛𝑔𝑒 210 in which, Scale = 𝐺−𝑟𝑎𝑛𝑔𝑒 210 . Gs = Measurement Value × 16 1024 . Xg = x × 0.015625; Yg = y × 0.015625; Zg = z × 0.015625;
  • 12. 11 3.1.2. Calibration 3 axis Calibration can be performed at 6 stationary positions as shown in next table. Table 2. Various positions to calibration each axis One method used to get an accurate and reliable 0g reading is to rotate the device from +1g through -1g. The max value will be +1g and the minimum value will be -1g. Assuming that the sensitivity is symmetric from zero to positive and from zero to negative the sensitivity of the device can be calculated by dividing by 2[9]. - Define zero g in X axis Figure 6. Calibration of X-axis accelerometer 0 20 40 60 80 100 120 140 160 180 200 -5 -4 -3 -2 -1 0 1 2 3 4 5 Number of samples Acceleration(g) Calibration X-axis X-positive X-negative X-zero
  • 13. 12 - Define zero g in Y axis Figure 7. Calibration of Y-axis accelerometer - Define zero g in Z axis Figure 8. Calibration of Z-axis accelerometer - Zero g value also is offset value. 0 20 40 60 80 100 120 140 160 180 200 -5 -4 -3 -2 -1 0 1 2 3 4 5 Number of samples Acceleration(g) Calibration Y-axis Y-positive Y-negative Y-zero 0 20 40 60 80 100 120 140 160 180 200 -5 -4 -3 -2 -1 0 1 2 3 4 5 Number of samples Acceleration(g) Calibration Z-axis Z-positive Z-negative Z-zero
  • 14. 13 3.2. Algorithm A decision tree is a tree in which each branch node represents a choice between a number of alternatives, and each leaf node represents a decision. Decision tree starts with a root node on which it is for users to take actions. From this node, users can split each node recursively according to decision tree learning algorithm. The final result is a decision tree in which each branch represents a possible scenario of decision and its outcome. Decision tree learning is a method for approximating discrete-valued target functions, in which the learned function is represented by a decision tree. Decision tree learning is one of the most widely used and practical methods for inductive inference [12]. Decision tree has various advantages such as: able to handle both categorical and numerical data; performs well with large datasets [13]. However, it has some limitations like: problem in optimal decision tree, don’t generalize well with over- complex trees [13]. Three are many specific decision-tree algorithms as ID3, C4.5, CART, CHAID. But, in this study, we use ROC to define threshold with the desire to improve the quality of decision tree algorithm. Because, ROC analysis is increasingly being recognized as an important tool for evaluation and comparison of classifiers when the operating characteristics (i.e. class distribution and cost parameters) are not known at training time [14]. 3.2.1. Feature characteristics To classify cow behavior activities, we used two different components of the raw acceleration data: a static and a dynamic component. The static component of the acceleration is caused by the orientation of the sensor relative to the gravity field of the earth and can be calculated as a running mean, to determine the body posture [2, 15]. The dynamic component of the acceleration is caused directly by the movement of the animal [16, 17]. Overall dynamic body acceleration (ODBA) and its vectorial variation (VeDBA) represent an aggregated acceleration measure for the subject [16, 17]. Therefore, the dynamic body acceleration is a good candidate to discriminate between
  • 15. 14 behaviors with high dynamic movement (such as feeding) from behaviors with low dynamic movement (such as standing or lying) [2]. Firstly, we need to know about running mean: A running mean of set of data points { 𝑎𝑖} 𝑁 𝑖=1 is new set of data points { 𝑠𝑖} 𝑁−𝑛−1 𝑖=1 which each point is calculated by taking the arithmetic mean of the previous n points. Secondly, the static acceleration for each axis is derived using a running mean over the corresponding raw accelerometer data. µ𝑖 𝑡 = ∑ 𝐴𝑖 𝑡 ∗ /𝑆 𝑡+𝑆/2 𝑡−𝑆/2 , (1) in which { 𝑖 = 𝑥, 𝑦, 𝑧; 𝑡: 𝑑𝑎𝑡𝑎 𝑝𝑜𝑖𝑛𝑡 𝑆 = 𝑤𝑖𝑛𝑑𝑜𝑤𝑛 𝑠𝑖𝑧𝑒 𝐴𝑖, 𝐴𝑖 ∗ , µ𝑖 𝑡 : 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑 𝑡𝑜 𝑡ℎ𝑒 𝑠𝑡𝑎𝑡𝑖𝑐 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑜𝑚𝑒𝑡𝑒𝑟, 𝑟𝑎𝑤 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑜𝑚𝑒𝑡𝑒𝑟 𝑑𝑎𝑡𝑎 𝑎𝑛𝑑 𝑟𝑢𝑛𝑛𝑖𝑛𝑔 𝑚𝑒𝑎𝑛, 𝑟𝑒𝑠𝑝𝑒𝑐𝑡𝑖𝑣𝑒𝑙𝑦. After that, the resulting static acceleration is subtracted from the corresponding raw accelerometer data. 𝐷𝐵𝐴𝑖 = 𝐴𝑖 𝑡 = |𝐴𝑖 𝑡 ∗ − µ𝑖 𝑡 |. (2) Finally, we obtained values which presented as follows: ODBA = | 𝐴 𝑋 + 𝐴 𝑌 + 𝐴 𝑍| , (3) and VeDBA = √ 𝐴 𝑥 2 + 𝐴 𝑦 2 + 𝐴 𝑧 2. (4) The component in the Y- axis of the gravitation acceleration varies according to SCAY: 𝑔⃗ 𝑦 = 𝑔 ∗ cos(180 − 𝛽) (5) where β is the angle in degrees of the sensor relative to the horizontal.
  • 16. 15 To classify data, there are two thresholds that used in the decision tree algorithm are calculated as the mean of the static component of the accelerometer in Y-axis (SCAY) and the mean of VeDBA, respectively. Both means are taking over the duration of the window selected. [x]. 3.2.2. Algorithm flow chart Figure 9. Algorithm Flow Chart Data: Feature characteristics Low ActivityHigh Activity Raw accelerometer data Standing LyingFeeding Y N Mean of VeBDA > Threshold A Y N Mean of SCAY > Threshold B
  • 17. 16 3.2.3. Moving window size When calculating the VeDBA and SCAY from raw acceleration data set, it is essential to define a window size, which make the data and the two thresholds (A and B) more smoothly for each step of the decision tree. The choice of window size or the threshold value used can affect the performance of the decision-tree algorithm [2], and windows ranging from 1 to 600 seconds. In this paper, we use 3 categories of window size as: 60 s, 300 s, 600 s. IV. Results In this section, we will discuss the result from two data sets: the data which were published in work [2] and the data from the experiments with model of cow. The result of behavior classification were determined by comparing the percent agreement between manual observation and the proposed classification method during the entire experiment. System can distinguish the three main behavior pattern: lying, standing and feeding. Other behaviors aren’t attached special importance to Fig.4. Sensor position and orientation. 4.1. Data from tri-axial accelerometer When the cow is lying or standing, the acceleration is changes little because both behavior show little overall movement. When the cow is feeding, it move head up and down so we can observe the change of acceleration. There also the different in the component of y-axis between lying and standing. Fig.5. Raw tri-axial accelerometer for lying, standing, feeding. Fig.6. The running mean of the acceleration in the y-axis (SCAY) and vector dynamic body acceleration (VeDBA) value under the three behaviors 4.2. Performance of the system There are many metrics that can be used to measure the performance of o classification or predictor, different fields have differences for specific metrics due to different goals [11]. In this paper we consider two performance metrics: sensitivity of
  • 18. 17 classification and precision of classification. Sensitivity and precision are known in statics as classification function: - Sensitivity 𝑆𝑒𝑛 = 𝑇𝑃 𝑇𝑃 + 𝐹𝑁 (6) - Precision 𝑃𝑟𝑒 = 𝑇𝑃 𝑇𝑃 + 𝐹𝑃 (7) TP (true positive): the number of instances where the behavioural state of interest that was correctly classified by the algorithm after validation by the visual observer. FN (false negative): the number of instances where the behavioural state of interest was visually observed in reality but was incorrectly classified as some other behaviour by the algorithm. FP (false positive): the number of times the behavioural state of interest was (incorrectly) classified by the algorithm but not observed in reality. TN (true negative): number of instances where the behavioural state of interest was (correctly) classified as not being observed. 4.3. Define the threshold The algorithm contain two threshold (A and B). Thresholds A were used to discriminate between high activities (feeding) and low activities (lying and standing) through the VeDBA time series. Threshold B were used to discriminate between lying and standing through the SCAY time series. The performance of the system can be affected by the choice of these threshold. We use two approach to choice these threshold Approach 1: Use ROC (receiver operating characteristic) curve to show the true positive rate TPR (known as sensitivity) against the false positive rate FPR (known as the false alarm rate) when varying the threshold 𝑇𝑃𝑅 = 𝑇𝑃 𝑇𝑃 + 𝐹𝑁 (8)
  • 19. 18 𝐹𝑃𝑅 = 𝐹𝑃 𝐹𝑃 + 𝑇𝑁 (9) In this curve, the optimal threshold value is the one that generates the pair of TPR and FPR values closet to the top left corner which represents the value that separates perfectly the positives from the negatives. (a) 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 false positive rate(%) truepositiverate(%) ROC curve to obtain threshold A
  • 20. 19 (b) Figure 10. ROC curves to obtain the best threshold values Figure 10.a) ROC curve when varying threshold A in range between -0.1 and 0.9g. The optimal threshold were selected by taking the closet point to the left top corner, with value of 0.041g. Figure 10.b) ROC curve when varying threshold B in range between -0.9 and 0.9g. The overall TPR and overall FPR are defined as the mean of their respective rates for lying and standing. The optimal threshold were selected by taking the closet point to the left top corner, with value of -0.055g. Approach 2: Select both thresholds at the same time by running a comparison of the performance of the algorithm over a 2-dimentional space range (threshold A and B). The range of variation was 0.01 to 0.08g for threshold A and -0.3 to 0.3g for threshold B. Contours illustrate regions with the same sensitivity. 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 false positive rate(%) truepositiverate(%) ROC curve to obtain threshold B lying standing overall
  • 21. 20 Figure 11. Sensitivity of the decision-tree algorithm across a range of different threshold values From the figure we see that the highest overall sensitivity (~85%) occurs when threshold A is in the range 0.03 to 0.05g and threshold B is in the range -0.08 to 0.1g. The threshold values obtained using the first approach (0.041g for threshold A and -0.055g for threshold B) are contained in the regions with the highest overall sensitivity obtained using the second approach (see Fig. 5). Hence, we used these values for the thresholds in the decision-tree algorithm. 4.4. Infection of the window size The choice of window size used can affect the performance of the decision-tree algorithm. Window size below 60s showed a low overall sensitivity, particularly for feeding behaviour . At small window sizes it may not be easy to perceive the regular up and down movements of the cow’s neck while eating, which will result in apparently low activity values (VeDBA) and hence lead to misclassification. Classification performance for lying and standing were very similar for all windowsizes but the best overall accuracies were found above 60s. Window size above 600s result in two few Threshold for VeDBA ThresholdforSCAY Sensitivity of system across a range of different threshold values 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 -0.2 -0.1 0 0.1 0.2 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85
  • 22. 21 data points for a faire comparison of performance [2]. To explore the effect of the choice of window size, the performance of the algorithm was calculated using the same input data, the fixed threshold value and window size in turn 60s, 300s and 600s. The sensitivity and the precision of the algorithm were obtained in the Table 3. Table 3. Performance of the decision-tree algorithm with the different window sizes Window size 60s 300s 600s Sensitivity Lying 74.09 74.09 77.42 Standing 82.08 88.46 88.00 Feeding 95.65 97.44 98.78 Overall 83.94 86.66 88.06 Precision Lying 96.57 97.95 98.63 Standing 47.01 47.92 55.00 Feeding 92.03 93.25 93.10 Overall 78.53 79.71 82.24 Overall sensitivity is calculated as the arithmetic mean sensitivity for the three behaviors. Overall precision is calculated in the similar way. Table 1 illustrate that the best performance is obtained at the largest window size of 600s. V. Conclusion and future work Our work has shown that accelerometers can be used to recognize some important behavior pattern in cows. Simple decision-tree classification algorithm was useful in classification of measured behavior pattern. However, the result of practical experiments are not satisfied due to some reasons. Our cows were not trained to wear
  • 23. 22 the neck-mounted device, although it is not heavy. It need time to get used to wearing something without uncomfortable. With this simple system, it would be feasible to determine the frequency of each behavior. Hence it can automatically detection the heal problem in cow even in other similar cattle. It has a good application value. In the future work, we consider how to enhance the classification performance by combining the decision tree algorithm with SVM algorithm. More behavior will be classified by this. Furthermore, pedometer is also used to detect cycle of estrus in cow through gathering steps. It becomes easy to prevent cow disease, accurately determine the cow estrus to promote the quality of milk, increase farmers’ income. A part of this report is presented in the following publication. Pham Van Thanh, Nguyen Thi Huyen Nga, Le Thi Thu Ha, Do Van Lam, Dinh- Chinh Nguyen, Duc-Tan Tran, Development of a Real-time Supported System for Firefighters in Emergency Cases, the 6th International Conference on the Development of Biomedical Engineering in Vietnam which will take place in Ho Chi Minh, Vietnam from June 27-29, 2016, accepted.
  • 24. 23 References [1] Schwager Mac, et al. "Robust classification of animal tracking data." Computers and Electronics in Agriculture, Vol. 56, No.1, (2007), pp. 46-59. [2] Diosdado, Jorge A. Vázquez, et al. "Classification of behaviour in housed dairy cows using an accelerometer-based activity monitoring system." Animal Biotelemetry, Vol 3, No.1, (2015). http://en.vbcsd.vn/detail.asp?id=476 [3] Resheff, Yehezkel S., et al. "AcceleRater: a web application for supervised learning of behavioral modes from acceleration measurements." Movement ecology, Vol. 2, No.1, (2014), pp. 25. [4] McClune, David W., et al. "Tri-axial accelerometers quantify behaviour in the Eurasian badger (Meles meles): towards an automated interpretation of field data." Animal Biotelemetry Vol. 2, No.1, (2014), pp.1. [5] Bidder, Owen R., et al. "Love thy neighbour: automatic animal behavioural classification of acceleration data using the k-nearest neighbour algorithm." PloS one 9.2 (2014): e88609. [6] Langrock, Roland, et al. "Flexible and practical modeling of animal telemetry data: hidden Markov models and extensions." Ecology Vol. 93, No.11, (2012), pp.2336- 2342. [7] Martiskainen, Paula, et al. "Cow behaviour pattern recognition using a three- dimensional accelerometer and support vector machines." Applied Animal Behaviour Science Vol.119, No.1, (2009), pp.32-38. [8] Gray, H.G., Varner, M.A.: Signs of estrus and improving detection of estrus in cattle. Fact Sheet IRM 6, West Virginia University (1984).
  • 25. 24 [9] Tuck, Kimberly. "Implementing auto-zero calibration technique for accelerometers." Freescale Semiconductor Application Note, AN3447 (2007). [10] https://www.sparkfun.com/tutorials/240 [11] https://en.wikipedia.org/wiki/Binary_classification#Evaluation_of_binary_classifiers [12] Mitchell, Tom M. "Machine learning." (1997). [13] https://en.wikipedia.org/wiki/Decision_tree_learning [14] Ferri, César, Peter Flach, and José Hernández-Orallo. "Learning decision trees using the area under the ROC curve." ICML. Vol. 2. (2002). [15] Brown, Danielle D., et al. "Observing the unwatchable through acceleration logging of animal behavior." Animal Biotelemetry Vol.1, No.1, (2013), pp.1. [16] Qasem, Lama, et al. "Tri-axial dynamic acceleration as a proxy for animal energy expenditure; should we be summing values or calculating the vector?." PLoS One 7.2 (2012): e31187. [17] Gleiss, Adrian C., Rory P. Wilson, and Emily LC Shepard. "Making overall dynamic body acceleration work: on the theory of acceleration as a proxy for energy expenditure." Methods in Ecology and Evolution Vol. 2, No.1, (2011), pp.23-33.