0% found this document useful (0 votes)
21 views13 pages

@unsupervised Automated Monitoring of Dairy Cows' Behavior Based On

Uploaded by

cht ayt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views13 pages

@unsupervised Automated Monitoring of Dairy Cows' Behavior Based On

Uploaded by

cht ayt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Computers and Electronics in Agriculture 167 (2019) 105068

Contents lists available at ScienceDirect

Computers and Electronics in Agriculture


journal homepage: www.elsevier.com/locate/compag

Unsupervised automated monitoring of dairy cows’ behavior based on T


Inertial Measurement Unit attached to their back
⁎ ⁎
Brahim Achoura, , Malika Belkadia, , Rachida Aoudjita, Mourad Laghroucheb
a
LARI Laboratory, Mouloud Mammeri University of Tizi Ouzou, Algeria
b
LAMPA Laboratory, Mouloud Mammeri University of Tizi Ouzou, Algeria

A R T I C LE I N FO A B S T R A C T

Keywords: Automated monitoring of dairy cow behavior based on non-invasive sensors offers a great potential to improve
Precision livestock farming the monitoring processes of its welfare and health in the context of the smart farm. It can detect any changes
Behavior classification before the appearance of the clinical signs, allowing the farmer to take necessary measures as soon as possible.
Dairy cow The objective of this study is to develop an effective un-supervised classification model of data collected by
Inertial Measurement Unit
Inertial Measurement Units (IMU) attached to the back of dairy cows housed in free-stall. These data were
Finite mixture model
Unsupervised monitoring
aggregated according to different sampling frequencies and segmentation windows. The different times of lying,
standing, lying down, standing up, walking and stationary behaviors were observed and recorded in real time.
The designed classification model is based on univariate and multivariate Finite Mixture Models (FMM) and
decision trees. The valid transitions between standing and lying behaviors are guaranteed by constraints imposed
by a deterministic finite state automaton. The obtained results revealed that 99% of behaviors are well classified.
Standing, lying on each side and changing between these positions are classified with 100% accuracy, followed
by stationary with 99% sensitivity, 96% specificity, 99% precision and 99% accuracy. The walking behavior is
classified with 96% sensitivity, 99% specificity, 91% precision and 98% accuracy. These results show that the
back is an interesting location for sensors to monitor the dairy cow behavior.

1. Introduction et al., 2013; Sendra et al., 2013; Barwick et al., 2018), sows (Pastell
et al., 2016), pig (Tabasum Ahmed et al., 2015; Huang et al., 2018),
Nowadays, livestocks are among the most important areas that en- pink iguanas (Loreti et al., 2018), horse (Burla et al., 2014; Norton
visage the harnessing of the New Information and Communication et al., 2018), dairy cows (Stangaferro et al., 2016; Sepúlveda-Varas
Technologies (NICTs) proliferation. Indeed, the precision livestock is et al., 2016; Fogsgaard et al., 2012; Pastell and Frondelius, 2018), etc.
based essentially on these NICTs and so they offer great potential for were automatically monitored using sensors to measure the necessary
improving the productivity. Sensing technologies (WSN), localization data for monitoring their health, ensure their welfare, protect them
technologies (GPS) and identification technologies (RFID) offer farmers from attack by wild animals, detect the heat periods that indicate the
the possibility to acquire information and the ability to monitor their appropriate time for artificial insemination, etc. These systems have
farms in real time with high degree of accuracy (Halachmi, 2015). several benefits such as relieving the farmer from the hard manual
Monitoring visually the animal behavior changes is not an easy task; it monitoring and contributing directly or indirectly in improving the
requires lengthy observation and increased labor force. Practically, this economy. Sendra et al. (2013) authors present an extended version of
is impossible in farms with large number of animals or during the night. their work presented in Llario et al. (2013) where they propose the use
Fortunately, automated monitoring systems may provide an alternative of an intelligent system based on IEEE 802.14.5 WSN to avoid and
measurement to detect any earlier behavior or animal's status changes prevent wolf attacks and thefts. Pastell et al. (2016) authors proposed a
during 24 h a day (Halachmi, 2015; Llario et al., 2013; Sendra et al., wireless 3D accelerometer system to predict sows farrowing. Buerkert
2013; Pastell et al., 2016; Burla et al., 2014; Stangaferro et al., 2016; and Schlecht (2009) authors compare the precision of three GPS system
Norton et al., 2018). Detecting these changes help the farmers in any in recording of daily goats grazing positions. Loreti et al. (2018) authors
decision-making process. Several animals such as goats (Llario et al., describe an Ultra Low Power WSN node aimed to monitor the habit of
2013; Sendra et al., 2013; Buerkert and Schlecht, 2009), sheep (Llario pink iguanas. Burla et al. (2014) an accelerometer was used for horses


Corresponding authors.
E-mail addresses: [email protected] (B. Achour), [email protected] (M. Belkadi).

https://doi.org/10.1016/j.compag.2019.105068
Received 13 March 2019; Received in revised form 18 July 2019; Accepted 20 October 2019
Available online 28 October 2019
0168-1699/ © 2019 Elsevier B.V. All rights reserved.
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

gait determination where authors define an acceleration value ranges Accelerometers are the most used sensors for monitoring animal
for horse standing, walking, galloping and trotting. Barwick et al. movements (Dutta et al., 2015; Rahman et al., 2017). Arcidiacono et al.
(2018) authors study the ability of an ear-tag, collar and front leg 3D (2017), accelerometer data were used for discriminating between the
accelerometer to classify sheep movements. food activities and the standing behavior of dairy cows. Robert et al.
Automatic monitoring and classification of the behavioral activities (2009) study was based on accelerometer data to distinguish four
of animals have the potential to detect any earlier health or welfare classes of cattle positions (lying, standing, walking and the transition
problem. When an animal is sick, a set of behavioral changes can be step between them). Spatial behavioral monitoring using Real-Time
investigated by the farmer to identify its illness. These behaviors in- Location System (RTLS) or Global Positioning Systems (GPS) can pro-
clude a reduction in general activity, such as in food intake, in social vide additional information on specific livestock behaviors such as the
behaviors and in locomotion (Sepúlveda-Varas et al., 2016; Halasa animal’s visit duration and frequencies to a feeder or to a water re-
et al., 2007). The main symptoms related to a disease are lack in ac- servoir (Shane et al., 2016). Williams et al. (2017) used a GPS to collect
tivity and appetite. This behavior is a well-adapted response of the data to classify the cattle behavior into grazing, resting or walking. The
animal's body to resist the disease and accelerate their recovery. Gen- fusion of these data with the data of the accelerometer allows in-
erally, invasive pathogens trigger processes requiring energy from the creasing the number of classes and the performances of classification
body to increase the effectiveness of the immune system and to over- (Gonzãlez et al., 2015). Currently, there is a large use of Inertial Mea-
come the infection (for example increasing body temperature). There- surement Units (IMU) to collect parameters that allow behavioral
fore, energy will shift from behavioral activities such as eating, social classification (Dutta et al., 2015; Andriamandroso et al., 2017; Smith
contact or grooming to immunity (Fogsgaard et al., 2012). The lack of et al., 2016). They measure both linear and angular accelerations and
appetite has been interpreted as a way to reduce the intake of certain estimate the trajectory, which expands the data used. These IMUs are
micronutrients required for the multiplication of pathogens (Siivonen composed of 3-axis accelerometer, 3-axis gyroscope and 3-axis mag-
et al., 2011). netometer. Andriamandroso et al. (2017) used IMUs to feed activity
In this paper we develop an un-supervised classification model classification for dairy cows.
based on data collected by an Inertial Measurement Units (IMU) at- The location of these sensors on the body of the animal has a great
tached to the back of dairy cows housed in free-stall. Our main objec- impact on the classification results. Most of researchers place the sen-
tive is to study the impact of the dairy cows’ back as a new location of sors on animal’s leg, neck, head or ear. The sensors attached to the
the used sensors to discriminate their behaviors. The model aim to animal leg have a great ability to classify the behavioral activities that
discriminate three main classes of dairy cows behaviors which are directly affect the leg (standing, lying, counting steps) (Robert et al.,
standing, lying and transition where each of these classes contains two 2009; Benaissa et al., 2017). But, they remain helpless when it comes to
subclasses (stationary, walking), (lying on the right side, lying on the monitoring muscle contractions, heart rate, breast temperature, body
left side) and (standing up, lying down) respectively. As a classification condition, body weight, food activity and rumination. The sensors at-
method, the designed model is based on a statistical analysis and tached to the neck, head or ear has an acceptable capacity for detecting
probabilities models known as finite mixture models. The classification the eating behavior. But this capacity decreases when it is applied to the
performance is evaluated in terms of precision, sensitivity, specificity classification of activities (Andriamandroso et al., 2017; Benaissa et al.,
and accuracy. 2017; Diosdado et al., 2015; Abell et al., 2017). These locations make
This paper is organized as follows. Section 2 gives an overview of these sensors ineffective in monitoring muscle contractions, heart rate,
the state of the art of animal behaviors classification. Section 3 presents teat temperature, body condition, and body weight. Rahman et al.
the sequence of the different adopted steps in the classification proce- (2017) placed sensors on three different parts of the animal's body
dure. Section 4 evaluates the classification model before and after the (neck, head, ear) to study the location influence on the classification of
optimization. Section 5 is devoted to the comparison of the present a set of typical cattle behaviors.
results with those obtained in other researches. Finally, Section 6 In this paper, unlike the other ones, we chose the back as a stable
summarizes the main sections presented in the paper. and safe location which is directly impacted by the animal’s activities
for behavior classification. This location allows integrating several
2. Related work sensors and offers the possibility to follow a wide range of sanitary,
reproductive and morphological phenomena such as muscular con-
The behavioral classification of the activities of dairy cows has been traction, overlap acceptance, breast temperature and animal’s cir-
considered by several studies. In this section, we present an overview cumference measurement.
about the automated monitoring of the behavior of dairy cows while
specifying the different sensors used to collect data, their location and 2.2. Classification methods used
we give some classification methods to exploit and classify this col-
lected data. The chosen sensors have a high degree of data variety, requiring
efficient and accurate analyzing methods to exploit and classify the
2.1. The sensors used and their locations collected data. The recent proposed methods for animal’s automatic
behavioral classification are mainly based on different algorithms such
With the advent of Precision Livestock Farming (PLF) and the in- as decision-trees (Gonzãlez et al., 2015; Diosdado et al., 2015), k
creasing use of the innovative technologies, different types of sensors nearest neighbors method (Smith et al., 2016; Benaissa et al., 2017),
have been deployed in smart farms. These sensors are used to estimate Support Vector Machines (SVM) (Smith et al., 2016; Martiskainen et al.,
various physiological, morphological or behavioral parameters on the 2009; Behmann et al., 2016), neural networks (Gutierrez-Galan et al.,
animal. These sensors are placed in the building, the pasture or directly 2018) and Hidden Markov Models (HMMs) (Pastell and Frondelius,
attached to the animals whose function is to collect information and 2018; Williams et al., 2017), etc. However, most of these techniques are
thus allowing an earlier intervention to avoid pathologies and remedy high resources-consuming in terms of mathematical operations. For
before the health or comfort of animals deteriorates. example, SVM and HMMs come with large computational costs, which
Since behavioral parameters are among the various types of in- make their implementation inside a resource-constrained device im-
dicators which directly reflect the welfare and the health status of an practical (Diosdado et al., 2015; Yang and Zhang, 2017; Shoaran et al.,
animal, many automated systems of behavioral classification have been 2018; Tang and Verma, 2018). Nevertheless, decision-trees have a
developed. These systems use generally the non-invasive or wearable much lower computational cost and can easily be implemented inside
sensors such as accelerometers, pedometers, GPS, IMU, etc. resource-constrained embedded devices in real time (Diosdado et al.,

2
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

2015; Yang and Zhang, 2017; Shoaran et al., 2018; Tang and Verma, storage module (SD Card 8 Go), two leds (red and green) and a battery
2018). Based on these confirmations and thanks to the simplicity in module (AAbattery). All these components are connected and sealed on
training, the accuracy and the applicability of decision trees, we opted a belt attached on the back of the dairy cows. The IMU has a MPU-9250
for it as a classification method to classify the dairy cow behaviors. with 9 degree of freedom and an integrated SiP system that combines
Let us note that sophisticated models can be constructed using a two chips: the first is the MPU-6500 which contains a 3-axis gyroscope
range of learning techniques to infer behavior. Dutta et al. (2015) a and a 3-axis accelerometer and the second is the AK8963 which con-
method based on two stages classifier is proposed for cattle behavior tains a 3-axis magnetometer. This IMU allows the acquisition of ac-
classification. In the first stage, clustering is performed using the celerometer, gyroscope and magnetometer data.
probabilistic principle component analysis, Fuzzy C-means and self The system is programmed to collect IMU data at 80 Hz (288,000
organizing maps. In the second phase, the clustering results are classi- lines of data per hour). These data are saved on the SD cards and at the
fied using a set of classifier methods such as Bagging and AdaBoost end of the acquisition, the data are downloaded.
along with classification methods such as binary tree, linear dis- The experiments were done in December 2017 in a free-stall farm on
criminative analysis and naive Bayes classifiers. dairy cows located in the region of Tizi Ouzou (Algeria). The data ac-
Diosdado et al. (2015) used a decision tree to separate eating, quisition system is used on an average of 6 h (between 9:00 and 15:00).
standing and lying activities. In this regard a set of different predefined Eight dairy cows of different breeds (two PRIM HOLSTEIN, three
threshold values were considered. In this case two threshold values MONTBELIARD and three FLECKVIEH) are selected for the experiment.
return the best performance. The data acquisition system is attached to the back of each dairy cow
Gonzãlez et al. (2015), a decision tree is adopted to classify the with a belt as shown in Fig. 2(b).
cattle behavior (foraging, rumination, walking, lying) according to The data collected from three dairy cows (Cow1, Cow2, Cow3) are
thresholds fixed by univariate mixture models of several laws (normal, used during the development step of the classification model and the
log-normal, weibull). Arcidiacono et al. (2017) have developed a clas- data acquired from all the eight cows (Cow1, Cow2, …, Cow8) are used
sification technique based on statistical analysis to define thresholds during the validation step of the model as shown in Table 1.
adapted to the discrimination of the feeding activity for cows in a free- The data capture provides a total of 16 signals: 9 signals are col-
stall. lected by the IMU (3D accelerometer (Acc_x, Acc _y, Acc_z), 3D gyro-
In the same context, this work deals with the choice of decision trees scope (Gyr_x, Gyr _y, Gyr_z) and 3D magnetometer (Mag_x, Mag _y, Mag
using the univariate and multivariate mixture models to define their _z)). Then the ATMega2560 microcontroller receives these signals as
thresholds. These learning techniques used by the classification model input and uses Madgwick filter (Madgwick et al., 2011) to compute the
offers several advantages, mainly the automatic and un-supervised 4D quaterions (q0, qx, que, qz). After that, conversion from the qua-
process offered by mixture models (Figueiredo and Jain, 2002). These ternions to the Euler angles 3D (Yaw, pitch, Roll) is done in realtime. In
models do not need any learning phase to ensure their progress and addition to these 16 signals, 3 time signals (hour, minute, second) are
their operation is less complex and simple to human interpretations saved.
(McLachlan and Peel, 2000). They reduce the need for training data and
take into account the differences between the individual dairy cows and 3.2. Step2: Data preprocessing and processing
offer computational efficiency adapted to a large amount of data
(Gonzãlez et al., 2015). 3.2.1. Modeling behaviors using deterministic finite state automaton
The dairy cow behavior was modeled using deterministic finite state
3. Materials and methods automaton to illustrate the behavioral states in which a dairy cow may
be found in order to describe possible transitions between these beha-
In this section, we illustrate the different steps of the procedure vioral classes in a valid order. A finite state automaton describes the
followed for developing our classification model of the behavioral ac- behaviors related to the animal’s posture (standing, lying and transition
tivities of dairy cows in real time. These steps are illustrated in Fig. 1 between these positions). This automaton permits also to set the con-
and detailed below. straints on these behaviors’ sequence. For example, the behavioral
series: standing – lying –walking are false because a dairy cow cannot
3.1. Step 01: Acquisition system development, deployment and data walk when it is lying. On the other hand, the behavioral series: standing
collection –lying down - lying – standing up– standing are valid (Fig. 3).

The acquisition equipment illustrated in Fig. 2(a) consists of an 3.2.2. Transformation and data processing
Inertial Measurement Unit (SparkFun MPU-9250 9 Dof IMU Breakout), Cows' behaviors are observed on videos and classified manually into
a microcontroller (ATmega2560, Arduino MEGA ADK rev3 card), a data three main classes (standing, lying and transition) and six subclasses

Fig. 1. Development procedure of the behavioral classification system.

3
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

(a) System components (b) Location of the system on the dairy cow’s
Fig. 2. Data acquisition system.

Table 1 Table 2
Dataset description. The behavioral classes studied.
Cow ID Video Sensor data Steps using the dataset Behavior Prevalence Subbehaviors
duration duration
Standing 74,05% Stationary
Cow1 6h27min 6h17 min Development and Walking
Validation Lying 25,67% Lying on the right sideLying on the left side
Cow2 6h30 min 6h21 min Development and Transition 0,28% Lying down
Validation Standing up
Cow3 5h08 min 5h00 min Development and
Validation
Cow4 6h44 min 5h10 min Validation
gyroscope (Gyr_x, Gyr_y, Gyr_z) signals, counting14 characteristics. For
Cow5 5h41 min 5h34 min Validation
Cow6 6h42 min 6h35 min Validation
each segmentation window and at each sampling frequency eight sta-
Cow7 8h37 min 8h30 min Validation tistical variables were computed: the mean value, the standard devia-
Cow8 7h14 min 7h35 min Validation tion, the maximum, the minimum, the median, the interquartile range,
Total Duration 53h03 min 50h 03min – the entropy and the energy. This gives a table of 112 variables asso-
ciated with each segmentation window and sampling frequency.

(stationary, walking, lying on the right side, lying on the left side,
standing up, lying down) as shown in Table 2. 3.3. Steps 03: Statistical analysis and decision tree construction
The data collected by the acquisition sensor were visualized and
processed using Matlab 2015B software (Mathworks, NL). The acqui- The previous step allows determining 112 statistical variables.
sition sensor signals are displayed on Matlab interface as a function of However, as feature extraction is an important step in a classification
time and are compared with the cows’ behaviors observed in the videos model, the purpose of this statistical analysis is to extract suitable
recorded. This permits selecting the minimum time required by a dairy variables to discriminate the behavioral activities.
cow to carry out each activity considered in this study. This time is The linear mixed effects model is an extension of the linear model
considered as a segmentation window. According to this visual analysis that takes into account the variability associated to individuals. This
the following windows were selected: 3 s for walking and stationary, model consists of a fixed part and a random part. The fixed part is
10 s for lying down and standing up and 5 s for standing and lying. For identical for all individuals and represents the population effect. The
each classification the data is displayed in vectors according to these random part is specific to each individual and reflects the variability
windows. Then, the statistical variables were calculated by applying associated to it.
different sampling frequencies to each vector. It is worth noting that the In the present case, mixed linear regression with random variable is
frequency of 80 Hz was used during the data acquisition step. After used to describe the variation of each characteristic (statistical variable)
testing several sub-sampled frequencies we found that 1 Hz and 4 Hz according to the current behavioral class of a dairy cow. This allows
are the ones that give better results of classification. For this, during all selecting the best variables reflecting the variation between behavioral
other steps, 1 Hz and 4 Hz are the frequencies used. classes. The decision tree will be constructed on the basis of the analysis
Although we have 16 characteristics (signals), only 12 were main- results.
tained: Accelerometer values (Acc_x, Acc_y, Acc_z), Gyroscope values
(Gyr_x, Gyr_y, Gyr_z), Magnetometer values (Mag_x, Mag_y, Mag_z) and 3.4. Step 04: Thresholds adjustment
Euler angle (Yaw, Pitch, Roll). Quaternions values are not considered
because they are converted to Euler Angle values. These data have been The precedent step allows to choose the suitable statistical variables
enriched by combining the accelerometer (Acc_x, Acc_y, Acc_z) and the that can discriminate the activities. These variables are used to create

where
LDRS: Lying Down on the Right Side.
LDLS:Lying Down on the Left Side.
LRS:Lying on the Right Side.
LLS: Lying on the Left Side.
SU: Standing Up.

Fig. 3. Automaton example for modeling the basic dairy cow behavior.

4
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Statistical and ProbabilityAnalysis

Choice of variable, threshold estimation

Computing validation performance

=1 Yes
Phase 1:
No Selection of relevant
Add the variable to the Yes variables
Se > 0,95
relevant variables table
No

No
Last Variable

Yes
Multivariate mixture Classification
with best two relevant variables

Computing Validation Performance

Phase 2:
Multivariate mixture Classification No Construction of final
=1 decision trees and
with best three relevant variables
validation
Yes

Computing Validation Performance Data Fusion Tree Construction

Data Fusion Tree Construction


withbestmixtureperformance Classification End

Fig. 4. Data fusion method.

g
the global architecture of the decision tree and to choose the appro- other words, there are g coefficients π1, ⋯ , πg (πK > 0 and ∑k = 1 πk = 1) .
priate variables that reflect the variability between the behavioral For any x ∈ X , we have:
classes. g
The thresholds of the decision tree are adjusted by the finite mixture p(x) = ∑ πk pk (x)
models. The finite mixture model is a clustering approach based on a k=1 (1)
statistical model to represent the data as a mixture of several distinct
populations. When a random variable is continuous and takes values in πk and pk are respectively called proportions and components of the
the set of real numbers, the probability distribution is then a function of mixture.
a real variable called density of probability. The finite mixture model The automatic classification by the finite mixture law is a mathe-
assumes that the data come from a source containing several homo- matical procedure that proposes one or more partitions among a mul-
geneous subpopulations called components, the total population being titude of possibilities. The most known probability laws are the Normal
a mixture of these subpopulations. Law, the Exponential Law, the Chi-Square Law, the Student Law, the
Although the finite mixture model is part of statistical modeling Fisher Snedecor Law, Weibull's Law and the Gamma Law, etc.
methods, it is not based on formal statistical model but on an iterative In this work, the density function of each data point’s population
and intuitive approach that consists in gathering the most similar in- identified in the statistical analysis was adjusted using the mixture of
dividuals and ruling out the most different ones. The major interest of Normal distributions. To determine the number of laws composing each
the finite mixture model is to provide a rigorous framework to assess mixture we have represented the density functions of the different ac-
the number of groups in an unsupervised classification context or to tivities for each variable selected during the statistical analysis on a
evaluate the stability of a classification function (McLachlan and Peel, same graph. The distributions mixture with the best adjustment was
2000). selected thanks to the mixtools package of R (Benaglia et al., 2009).
A law of finite mixtures p on a space X is a probability law defined
as a linear combination of several probability laws p1, ⋯⋯ ,pg on X . In

5
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Table 3
Linear regression that shows the influence of behavioral activities on the variables followed using several segmentations and frequencies with the data of the dairy
cow 2.
3.1. Mean values of standing, lying on the right side, lying on the left side, lying down, and standing up behaviors based on median and interquartile range characteristics of accelerometer axis using
linear regression on data of the dairy cow 2

Sensor/Variable Axe Lying right side Standing Lying left side Lying down Standing up RSE* R2 p-value

Accelerometer/Median 1 Hz, 5 s X 462,675 −137,359 −934,347 −132,282 −234,85 68,62 0,9706 < 2,2 e−16
Y 143,856 −128,932 122,732 −80,59 116 67,51 0,7579 < 2,2 e−16
Z 469,560 808,331 518,835 773,307 564,535 59,83 0,8441 < 2,2 e−16
Accelerometer/interquartile range 1 Hz, X 5,217 28,585 7,481 456,934 532,308 33,22 0,3941 < 2,2 e−16
10 s Y 6,0265 28,0762 7,7714 219,073 259,268 26,72 0,2413 < 2,2 e−16
Z 4,8011 12,1277 7,1547 197,433 198,923 17,65 0,2503 < 2,2 e−16

3.2 Mean values of standing and stationary behaviors based on energy of accelerometer and gyroscope using linear regression on data of the dairy cow 2

Sensor/Variable Axe Stationary Walking RSE P-value R2

Gyroscope/Energy 1 Hz, 3 s X 5,943 132,471 131,7 < 2,2 e−16 0,08237


Y 11,13 400,31 203,3 < 2,2 e−16 0,2567
Z 33,64 335,937 184,8 < 2,2 e−16 0,2275

* Residual Standard Error.

3.5. Step 05: Validation and optimization results Phase 2: The classification by multivariate mixtures models and the
construction of the final decision trees with their validation.
3.5.1. Validation
Several measures can be used to evaluate the classification perfor- In the first phase, variables with high degree of classification sen-
mance. Four measures were considered: sensitivity, specificity, preci- sitivity of any activity were selected and added to a list of relevant
sion and accuracy which are defined as follows: variables. To construct this list, a classification by univariate mixture
TP model was performed for each of the 112 variables. The number of laws
Sensitivity (Se ) = used for this classification is identical to that chosen for the classifica-
TP + FN (2)
tion of the variables selected by the statistical analysis. Variables that
TN show a high sensitivity rate were added to the list of relevant variables.
Specificity (Sp) =
TN + FP (3) In the second phase, a multivariate classification using the
TP Mclusttool on R (Scrucca et al., 2016) was performed using two or three
Precision (Pr) = relevant variables to have a compromise between sensitivity and pre-
TP + FP (4)
cision. Finally, the final decision trees were constructed. These trees
TP + TN allow mixing and merging all the variables sensitive to the detection of
Accuracy (Ac ) =
TP + TN + FP + FN (5) the desired class. This helps to maintain good classification sensitivity
where while optimizing the accuracy and the specificity. The new classifica-
tion rates were calculated and the classification results were compared
TP (True Positive): the number of instances where the behavioral with those of the single variable decision trees.
state was correctly classified by the algorithm after its validation by
the visual observer. 4. Results
FN (False Negative): the number of instances where the behavioral
state was observed visually, but was incorrectly classified as another Following section presents the development and the validation re-
behavior by the algorithm sults of the classification model. Final decision trees were designed
FP (False Positive): the number of times that the behavioral state using these results.
was incorrectly classified by the algorithm but not observed in
reality.
4.1. Statistical analysis results
TN (True Negative): The number of instances where the behavioral
state was correctly classified as not being observed.
The median and interquartile range variables in the x-axis of the
accelerometer have a high classification level which they maintain even
3.5.2. Optimization of results and final validation
at lower frequencies (Table 3.1). The median distinguishes activity
Further analysis was carried out to achieve a classification rate
classes related to body position. Indeed, Fig. 5 shows the results of
higher than the ones obtained with univariate model. This analysis is
linear mixed regression based on the data of three dairy cows for
based on data fusion aiming to reduce false positive rates (Borges and
standing and lying (on the left or on the right side) classification using
Brusamarello, 2016). It is motivated by the results presented in Huynh
the accelerometer’s median variable of the x-axis with 5 s segmentation
et al. (2015), Andò et al. (2016) and Tsinganos and Athanassios (2018).
and 1 Hz frequency. During the data acquisition period of the cow 3, no
The fusion of accelerometer and gyroscope variables presented in
period of lying on the right side was observed which explains the ab-
Huynh et al. (2015) and Andò et al. (2016) to detect the falls of the
sence of this population of data in Fig. 5. Likewise the interquartile
elderly has significantly improved detection performance. The variables
range indicates all transitions between standing and lying (Table 3.1).
fusion of a single accelerometer reported in Tsinganos and Athanassios
The energy of the y-axis of the gyroscope has a great capacity for
(2018) also shows a good optimization capacity. In the current study,
classifying a dairy cow’s walking or stationary behaviors (Table 3.2),
the data fusion method shown in Fig. 4 is divided into two phases:
except that this classification is not optimal because it depends on the
way in which the dairy cow performs its activity.
Phase 1: The selection of relevant variables.
When a dairy cow is standing or lying, the IMU orientation changes

6
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Fig. 5. Results of linear mixed regression with random variables on the data of three dairy cows for activities classification such as standing and lying (on the left and
right side) using the accelerometer’s median variable of the x-axis (segmentation 5 s, 1 Hz).

considerably. This change can be exploited directly by the sensor to


deduce the dairy cow’s position. However, the average energy of the
animal varies greatly according to its race, parity and physiological
state. Threshold A

4.2. Threshold adjustment results

Based on its ability to separate the standing and the lying on each
side classes, the median variable of the x-axis of the accelerometer was
selected to verify that this variable has different populations of data
that can represent the behaviors. However, the interquartile range of
the x-axis of the accelerometer has been chosen to separate the Fig. 7. The third consecutive mixture model of two normal laws of the inter-
standing, the lying and the transition behavioral classes. The energy quartile range variable of the accelerometer’s x-axis used to separate the tran-
variable of the y-axis of the gyroscope has been selected to differentiate sition class from the other behaviours.
the stationary and the walking states.
For the median of the x-axis of the accelerometer, the best adjust- The value of the threshold A separates P1 from P2. The intersection
ment is a mixture of three Normal distributions (Fig. 6) to separate the between P1 and P2 of the third mixture is used as the first step in the
standing, lying on the right and lying on the left side classes. The in- classification of data points which permits to find the exact moments of
terquartile range of the x-axis of the accelerometer gave the best ad- transition in order to separate them from the global scale of data.
justment by using three consecutive mixtures. The first two mixtures The mixture model of the Fig. 6 is a mixture of three Normal laws,
are composed of three Normal laws. They are preliminary and serve to where the population of the data points is a mixture of three sub-
reduce the data scale. The third mixture is composed of two Normal populations P1, P2 and P3. P1 represents the population of data points
laws (Fig. 7). It allows finding the optimal threshold which separates of lying on the left side class, P2 represents the population of data
the transition class from the other ones. points of the standing class and P3 represents the population of data
The mixture model of the Fig. 7 is a mixture of two Normal laws, points of the lying on the right side class. The values of thresholds B and
where the population of the data points is a mixture of two sub- C separate the data population from P3, P1 and P2. The intersection
populations (P1 and P2). P1 represents the subpopulation of the tran- between P1, P2 and P3 is used as the second step in the data point’s
sition class and P2 the subpopulation of the other behavioral classes. classification method.
The overlap between the behavioral activities described in the
previous section by the deterministic finite state automaton in Fig. 3 is
Threshold B used to identify the type of transition without using a new variable. This
automaton permits making an automatic annotation of all transitions in
Threshold C
four types (Standing-Lying on right side, Standing-Lying on left side,
Lying on right side-Standing, Lying on left side-Standing) and this with
combining the result of the previous classifications (Standing, Lying on
the right side, Lying on the left side and transition) with the chron-
ological order of their appearances.
For the gyroscope’s data energy of the y-axis, a model with a con-
secutive mixture composed of three phases separates the stationary and
walking classes of the previously separated standing class. The first
mixture of two Normal laws is preliminary; it allows separating a part of
the stationary class from the other classes. This model is followed by a
second model that consists of a mixture of two Normal laws (Fig. 8(a)).
Fig. 6. Median variable’s mixture model of three normal laws of the accel-
erometer’s x-axis with a segmentation of 5 s at frequency of 1 Hz. It is used to separate the walking and the stationary classes by

7
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Threshold D Threshold E

(a) The second mixture of two Normal laws which (b) The third mixture of two Normal laws which
determines the threshold D determines the threshold E
Fig. 8. The consecutive mixture model used for the stationary and the walking classes separation.

optimizing the sensitivity. Similarly the third mixture serves to separate between the data of the x-axis of the accelerometer at a frequency 1 Hz
the walking and the stationary classes, but optimizing the precision in the four minutes preceding and succeeding the transition when the
(Fig. 8(b)). This third mixture consists of a mixture of two Normal laws, finite mixture model of two Normal laws is applied. If this value is
where the classification results vary according to the mixture choice (a) significant (greater than 200 units of gravity) the transition is valid,
or (b). otherwise it is invalid.
The threshold D value corresponds to the gyroscope’s energy value The Eq. (6) is used in the decision tree to estimate the spacing
of the y-axis where the first and the second Probability Density variable in real-time. To achieve this, the sensor continuously stores the
Function (PDF) of the mixture (a) intersect. The first population re- accelerometer’s median value of the x-axis (with 1 Hz frequency and 5 s
presents the stationary class and the second one represents the walking segmentation) when the standard deviation value of the same data
class. This last class is isolated by using a third mixture of two new segment is small (< 10 gravity units, that reflecting a low variance in
Normal laws to find the threshold E (Fig. 8(b)). This threshold is the the data). The spacing (Esp) is determined by subtracting the last
gyroscope’s energy value of the y-axis where the first and second PDF median before the transition and the first median after the transition.
mixture (b) intersects. The role of the threshold D is to optimize the This automatic validation achieves a precision of 100%. Table 4 gives
sensitivity and the role of the threshold E is to optimize the precision. the obtained results.

Esp
4.3. Results optimization
= ABS (Last _median _before _transition (x _axis )
The classification results obtained by the univariate mixture model [Standard deviation (x _axis ) < 10] − First _median _aftertransition
were very satisfactory for the standing and lying (on the right side or on
(x _axis )[Standard deviation (x _axis ) < 10 (6)
the left side) classes as shown in Table 5 and acceptable for all other
classes (Tables 4 and 6). To optimize the results of the classification we
have proceeded as follows: 4.3.2. Data fusion (multivariate mixture model)
The univariate classification showed an excellent capacity classifi-
4.3.1. Automatun constraints cation in standing, lying and transiting between these positions using
The classification of the transitions (lying down and standing up) by the two variables: the median and the interquartile range of the x-axis
an univariate mixture model has a 100% sensitivity but only 59% of the accelerometer. This procedure is improved by the multivariate
precision. The univariate mixture model detects all the transitions classification.
without any false negative. The only error that exists is related to the Regarding the classification of the standing, the lying on the right
false positive. For that each transition found by this model must be and on left sides’ classes, two variables are used: the accelerometer’s
verified. median of the x and y-axis with a segmentation of 5 s at a frequency
According to the automaton, a valid transition is certainly between 1 Hz (Fig. 10). This combination slightly improves the results provided
the standing and lying states. To verify this, a study on the data that by the univariate model shown in Table 5.
precedes and succeeds the moment of transitions is realized. In Fig. 9, As for the stationary and walking classes’ classification, three vari-
the spacing variable (Esp) is determined by computing the distance ables are fusioned: the gyroscope’s energy of the y-axis at 1 Hz, the

Table 4
Results obtained during the validation of the transition classification with univariate mixture, with and without validation by the automaton (Esp Threshold = 200).
No. dairy IQR(ax) Mean Number Mean Number of Number of Transitions Found Transitions Found Precision before Precision after
cow Threshold A of Esp valid Esp invalid Transitions without validation after validation validation validation

1 380 623 11 2 3 2 0,66 1,00


2 360 688 29 8 11 8 0,72 1,00
3 300 637 82 12 15 12 0,8 1,00
4 300 520 56 6 13 6 0,46 1,00
5 320 469 39 6 18 6 0,33 1,00
Average 332 587 43 36 56 36 0,59 1,00

8
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Table 5
The classification results of standing, lying on right and on left sides classes by the two mixture models (univariate and multivariate).
Model Lying on right side Standing Lying on left side

Se Sp Pr Ac Se Sp Pr Ac Se Sp Pr Ac

Univariate Model 100 99 99 99 99 100 100 99 100 100 100 100


Multivariate Model 100 100 100 100 100 100 100 100 100 100 100 100

Table 6 5. Discussion
Classification results of walking and stationary classes by the four methods.
Averageof Thresholds Walking Stationnary
In this section we discuss two important points. Firstly, we present
what differentiates our work from others and we compare our results
Methods D/E G H Se Sp Pr Ac Se Sp Pr Ac with those of selected works. Secondly, we present the energy con-
sumption and thus the estimated lifetime of our system.
M1 D = 47 – – 98 98 84 98 97 97 99 98
M2 D = 47 2960 1760 96 99 91 98 99 96 99 99
The main features that distinguish the present work from ones found
M3 E = 142,4 – – 93 99 93 99 99 95 99 99 in the literature are summarized as follows:
M4 E = 142,4 2960 1760 89 99 96 99 99 90 99 99

• The sensor location (the dairy cow’s back).


M1: univariate mixture of two PDF (threshold D).
• The type of sensor used (IMU),
M2: multivariate mixture of three variables optimizing the method 1 (threshold
D, G, H). • The use of a deterministic finite state automaton for modeling the
dairy cows behavior
• The data acquisition frequency (80 Hz).
M3: consecutive univariate mixture of two followed PDF by two PDF (threshold
E).
M4: multivariate mixture of three variables optimizing the method 3 (threshold • The variation in the sampling frequency, to have the lowest fre-
E, G, H). quency and to preserve the energy autonomy of the sensor
• The selection of the segmentation window according to the
accelerometer’s energy of the x and y-axis at 4 Hz with a segmentation minimum time required by the animal to perform an activity
of three seconds for the three variables. For the gyroscope’s energy • The number of variables extracted and the number of activities
variable of the y-axis, the thresholds’ values D and E determined by the followed by our classification method.
univariate analysis have been maintained. The data fusion (mixture) • The classification results optimization with the data fusion
allows fixing the thresholds’ values G and H. The thresholds G and H • The use of new variable (spacing) which allows to validate the
correspond to accelerometer’s energy variable of the x-axis and y-axis transitions
respectively. In total, four methods can be tested and the results vary • The use of unsupervised learning models (univariate and multi-
considerably between these methods, as shown in Table 6. The fusions variate models)
significantly improve the walking class’ precision from 89% to 98%,
and the stationary class’ sensitivity from 97% to 99%. Let us mention that the variation of the data sampling frequency is a
culminant point in the methodology. A very high frequency of data
collection was used to have a rich database. Then, variations of this
4.4. Construction of the decision trees frequency were made in order to find the smallest possible frequencies
that allow to have higher classification levels. The idea is to limit the
The use of the different variables and thresholds found in the uni- frequency to the lowest possible level without causing losses in classi-
variate and multivariate mixture model analysis and the constraints fication rates because the small frequencies allow the sensor to have a
imposed by a finite state automaton led to the creation of two decision very high energy autonomy; therefore a longer life.
trees presented in Fig. 11. The first decision tree is used to classify the The lying position is characterized by a considerable change in the
five classes (standing, lying on the right, lying on the left sides, standing back orientation with very low energy levels. When the dairy cow lies
up and lying down). The second serves to divide the standing class into its back will tilt towards two distinct orientations: the right or the left,
two subclasses: stationary and walking. differentiating between lying on the right and the left sides. The

Esp
Esp ≈ 600 ≈50

Esp ≈ 600 is greater than 200 units of gravity: Esp ≈ 50 is lower than 200 units of gravity:
Valid transition Invalid transition
Fig. 9. Validation of the transition between standing and lying by studying the spacing between the data mixture of the two Normal laws of 4 min before and after the
transition.

9
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Fig. 10. The multivariate classification of standing and lying on the right/left sides classes with the accelerometer’s median of x and y axis.

transition between the standing and lying positions is characterized by energy level. Only a few isolated cases of displacement showed average
a remarkable change in the back orientation; standing up or lying down energy.
involves a great tilt (up or down) of the dairy cow back with a high The current work has optimal classification rates for some classes
energy level. However, the standing position is characterized by an related to the animal posture (standing, lying, transitions) and very
unchanged back orientation but the energy level differs according to high for other classes related to movement (stationary, walking). These
several behaviors included in the standing state: stationary and classification rates are considerably higher than those reported by other
walking. The stationary state is characterized by several movements studies in terms of sensitivity, specificity, precision and accuracy
where the dairy cow uses less than two legs to make its activities (Tables 7–9), confirming the hypothesis that the animal’s back can be
(grooming, coughing or kicking). When it is stationary, there is no re- used as an effective location for classifying activities with high rates.
markable activity and the energy level is very low. Walking is char- Regarding standing, lying behaviors (Table 7) and transitions be-
acterized by other sub-behaviors such as displacement, travel, social tween them (Table 9), the current classification is accurate and reliable
interaction and rotation. All these events are characterized by a high (100%). Thus it can be used as a reference method by replacing the

(a) The decision tree architecture to separate the standing, (b) The decision tree architecture allowing the separation
lying on the right or left side classes and transition between of the walking and stationary classes included in the
standing and lying standing class
Fig. 11. The decision trees’ architecture.

10
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

Table 7
Comparison between the present work and other researches for standing and lying behavioral classes.
Ref Sensor Location Method Lying Standing

Se Sp Pr Ac Se Sp Pr Ac

Abell et al. (2017) Acc 3D Ear Random Forest 88 92 – 91 85 84 – 84


Head 97 99 – 99 91 84 – 88
Neck 94 98 – 97 92 87 – 90
Behmann et al. (2016) Indoor positioning Neck under the chest strap SVM – – – 86 – – – 89
heart rate sensor Conditional Random
Field
Benaissa et al. (2017) Acc 3D Leg K-nearest neighbours 100 – 99 – 76 – 68 –
Neck naive bayes 96 – 83 – 68 – 81 -
SVM
Martiskainen et al. (2009) Acc 3D Neck SVM 80 – 83 84 80 – 65 87
Diosdado et al. (2015) Acc 3D Neck Decision Tree 77 – 98 – 88 – 55 -
Robert et al. (2009) Acc 3D Leg classification Tree – – – 99 – – – 98
Our IMU Back Decision Tree 100 100 100 100 100 100 100 100

Table 8 consecutive mixtures and considering the new thresholds related to the
Comparison between this work and some researches regarding the walking accelerometer found by the data fusion method, the precision and the
behavioral class. specificity increased by 7% (it reach 91%) and 1% (it reach 99%) re-
Ref Sensor Location Method Se Sp Pr Ac spectively. However, the sensitivity decreased by 2% (it reaches 96%)
and the accuracy saves the same rate of 98%. The use of three con-
Smith et al. Acc Neck SVM 69 – 77 – secutive mixtures to find the gyroscope’s energy variable threshold of
(2016) Mag 3D LR
the y-axis and the fusion with the two variables coming from the ac-
GPS RFE
KNN celerometer, the precision increased by 3% (it reaches 96%) while the
Robert et al. Acc 3D Leg Classification – – – 67 sensitivity decreased by 4% (it reaches 89%), the specificity and the
(2009) Tree accuracy save the same rate (98%). The use of the deterministic finite
Behmann et al. indoor Neck SVM – – – 18
state automaton makes constraints on the order of the dairy cow be-
(2016) positioning under the Conditional
heart rate chest Random Field
haviors. This order leads to finding the transition type and differ-
sensors strap entiating between the standing up and lying down activities. The other
Abell et al. Acc 3D Ear Random Forest 72 73 – 73 use of these constraints is for transitions validation, for example a valid
(2017) Head 80 76 – 77 transition cannot be between two similar states. This validation order
Neck 78 76 – 76
led to the computation of a spacing variable between populations
Martiskainen Acc 3D Neck SVM 79 – 79 99
et al. preceding and succeeding the transition period and allowed optimizing
(2009) the classification results until reaching a rate of 100%.
Our IMU Back Decision Tree 96 99 91 98 The classification results of standing, lying on the right or on the left
side and the transition behaviors are optimal; this is due to the con-
siderable variation in the tilt of the dairy cows’ back during these ac-
manual annotation made after watching the video currently used in the tivities (Fig. 12). During the standing period there is no tilt of the dairy
search. During the videos acquisition, the dairy cows may be out of cow’s back; during this position the back is strictly straight (Fig. 12(a)).
range of cameras resulting in losses of data to be processed. During the lying position to the right or left side the dairy cow's back is
Data fusion allows the optimization of the classification rates by considerably tilted towards the right or the left respectively
reducing the False Positive number. The fusion of the accelerometer’s (Fig. 12(b)). During the transition, the cow's back tilts considerably
median of the x and y axis at a frequency of 1 Hz and 5 s segmentation upward (when it standing up) or downward (when lying down)
achieves a level rate of 100% compared to one found using a single (Fig. 12(c)). Theses tilts of dairy cows' back allow to reach high rate
variable (of the order of 99%). The accelerometer’s interquartile range classification.
fusion of the x and y axis at 1 Hz and 10 s segmentation improves the As for the lying behavioral class, very high classification rates were
results provided by the univariate model (precision = 59%). When the obtained when an accelerometer is attached to the dairy cows’ leg
precision achieves 85%, both models have a sensitivity of 100%. (Se = 100%, Pr = 99% (Benaissa et al., 2017), Ac = 99% (Robert et al.,
The fusion of the gyroscope’s energy of the y-axis (at 1 Hz and 3 s for 2009)) comparable to those obtained in this work (Table 7). However,
segmentation) and the accelerometer’s energy of the x and y axis (at the classification rates decrease when the sensors are placed on the
4 Hz and 3 s for segmentation) greatly reduces the False Positive rates neck, head and ear. The sensitivity varies from 77% to 99%, the spe-
and enhances the precision and the sensitivity. However, this fusion cificity from 92% to 98%, the precision from 83% to 98% and the ac-
also caused a loss in the True Positive rates that reflects the system curacy from 84% to 99% according to the different works shown in
sensitivity to find all the walking events. Table 7.
Using the gyroscope’s energy threshold of the y-axis found by two With respect to the standing behavioral class, this work showed a

Table 9
Comparison between this work and some researches regarding the transition detection between standing and lying behavioral classes.
Ref Sensor Location Method Se Sp Pr Ac

Diosdado et al. (2015) Acc 3D Neck Decision Tree 96 – 87 -


Martiskainen et al. (2009) Acc 3D Neck SVM 71 – 29 100
Our IMU Back Decision Tree 100 100 100 100

11
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

a) Standing: the dairy cow's (b) Lying left side: the dairy (c) Transition: the dairy cow's
back is straight cow's back is tilted considerably back is considerably tilted
towards the left side downwards
Fig. 12. Tilt of the dairy cow's back according to its behavior.

classification rate of 100% considerably greater compared to the results 6. Conclusions


obtained when the sensor is attached on the animal’s leg (Se = 76%,
Pr = 68%, Ac = 98%) and remains higher compared to the sensor at- The present work shows clearly that the back is an effective location
tached to animal‘s neck, head and ear (Se varies from 68% to 88%, Sp to monitor the dairy cows’ behavioral activities. We achieved optimal
varies from 84% to 94%, Pr varies from 55% to 81% and Ac varies from classification rates for lying (on the right or the left sides), standing and
84% to 98%). transition (standing up or lying down) classes. A high classification
A high rate has been obtained for the classification of the walking rates are also reached for the walking and stationary classes.
class. This rate is higher than those obtained by the previous works The finite mixture models present a lot of advantages compared to
(Table 8). When the sensor is placed on the head, the neck, the ear or other classification models such as reducing the need of training data,
the leg, the obtained classification rates are: Se varies from 69% to 80%, considering the differences between individual animals, offering a
Sp varies from 73% to 79%, Pr varies from 77% to 79% and Ac varies computational efficiency for a large amount of data and estimating the
from 18% to 99%. But although the dairy cow is immobile, her head, threshold values for individual animals under unknown or variable
neck or ear may be moving (turns, licks, rubs) and she can kick, which environmental conditions.
explains these obtained rates. However the back of the animal is a more This approach can serve as a reference method for behavioral
stable location and better suitable to this discrimination. classification significantly reducing the time and costs associated to the
The exact detection of the transition between the standing and lying camera’s data collection used to perform visual annotation. However,
positions has also been successfully classified and is still more accurate additional research on a large number of animals in different geo-
and optimal compared to other research works as shown in Table 9. The graphical areas with different types of livestock buildings and other
classification rates of the transitions (standing up and lying down) behaviors such as overlap are needed.
given in Diosdado et al. (2015) and Martiskainen et al. (2009) by at- The IMU location on the dairy cows’ back can replace the ped-
taching a 3D accelerometer to the neck of the animal are lower than ometers or accelerometers attached to the animals’ leg while adding a
those we obtained by placing the IMU on the back of the animal. This better informative value by integrating other sensors to the micro-
can be explained by the fact that the neck is a location that is impacted controller such as RFID and GPS for localization, muscle contraction
by several events such as feeding, grooming, etc compared to the back detector for calving detection, pressure sensor for heat events, etc.
which is not impacted by these movements. However, the shortcoming of this location lies in its limited ability to
After comparing the results, we estimate the lifetime of our used monitor feeding, watering and rumination behaviors. In our future
system. In our work, we can distinguish two main steps: the develop- work we can overcome these limits by integrating for example a loca-
ment of the classification model (decision trees) and its implementa- lization system that allows to estimate the number of times of feeding
tion. To develop this model, we used the arduino MEGA ADK rev3 and watering periods. We will also study the ability of our system to
board. This choice is motivated by the fact that the microcontroller of discriminate other activities of dairy cows such as the heat events. In
this card (ATmega2560) has enough memory to save and run the data the near future, we intend to focus on reducing the size of our system
acquisition program compared to other microcontrollers such as which offers the possibility of sticking it directly on the back of the
ATtiny85, ATmega168, ATmega328, etc. The acquisition program re- dairy cows without using a belt.
quires a memory space of 32,432 bytes for storage and 1401 bytes for
its execution. The results of this step show that only three variables (the Acknowledgement
x and y axis of the accelerometer and the y-axis of the gyroscope) are
used by these decision trees (Fig. 11) with two frequencies (1 Hz and The authors are grateful to the dairy cows farm SOFLAIT, located in
4 Hz). As the memory space required for the storage of the program the region of Draa Ben Khedda, Tizi Ouzou, Algeria, for giving the
allowing the acquisition of these three variables is reduced to only opportunity of carrying out the trials and allowing the data collection.
24,032 bytes and 1361 bytes for its execution, and the arduino Mini Pro
card consumes significantly less energy than the arduino MEGA ADK References
card, we were motivated to replace this latter card by the arduino Mini
Pro card. By using a battery with 2600 mAh with a discharge factor of Abell, K.M., Theurer, M.E., Larson, R.L., White, B.J., Hardin, D.K., Randle, R.F., 2017.
15%, the lifetime of our system is estimated to be approximately three Predicting bull behavior events in a multiple-sire pasture with video analysis, ac-
celerometers and classification algorithms. J. Comput. Electron. Agric. 136, 221–227.
years at the frequency of 1 Hz and one year at the frequency of 4 Hz. Andò, B., Baglio, S., Lombardo, C.O., Marletta, V., 2016. A multisensor data-fusion

12
B. Achour, et al. Computers and Electronics in Agriculture 167 (2019) 105068

approach for ADL and fall classification. IEEE Trans. Instrum. Measur. 65 (9), Madgwick, S.O.H., Harrison, A.J.L., Vaidyanathan, R., 2011. Estimation of IMU and
1960–1967. MARG orientation using a gradient descent algorithm. In: IEEE International
Andriamandroso, A.L.H., Lebeau, F., Beckers, Y., Froidmont, E., Dufrasne, I., Heinesch, B., Conference on Rehabilitation Robotics, Zurich, pp. 1–7.
Dumortier, P., Blanchy, G., Blaise, Y., Bindelle, J., 2017. Development of an open- Martiskainen, P., Jarvinen, M., Skön, J.P., Tiirikainen, J., Kolehmainen, M., Mononen, J.,
source algorithm based on inertial measurement units (IMU) of a smartphone to 2009. Cow behaviour pattern recognition using a three-dimensional accelerometer
detect cattle grass intake and ruminating behaviors. J. Comput. Electron. Agric. 139, and support vector machines. J. Appl. Animal Behav. Sci. 119, 32–38.
126–137. McLachlan, G., Peel, D., 2000. Finite Mixture Models. John Wiley & Sons Publishers, New
Arcidiacono, C., Porto, S.M.C., Mancino, M., Cascone, G., 2017. Development of a York.
threshold-based classifier for real-time recognition of cow feeding and standing be- Norton, T., Piette, D., Exadaktylos, V., Berckmans, D., 2018. Automated real-time stress
havioral activities from accelerometer data. Comput. Electron. Agric. 134, 124–134. monitoring of police horses using wearable technology. Appl. Animal Behav. Sci. J.
Barwick, Jamie, Lamb, David W., Dobos, Robin, Welch, Mitchell, Trotter, Mark, 2018. 198, 67–74.
Categorising sheep activity using a tri-axial accelerometer. Comput. Electron. Agric. Pastell, Matti, Frondelius, Lilli, 2018. A hidden Markov model to estimate the time dairy
145, 289–297. cows spend in feeder based on indoor positioning data. J. Comput. Electron. Agric.
Behmann, J., Hendriksen, K., Müller, U., Büscher, W., Plümer, L., 2016. Support Vector 152, 182–185.
machine and duration-aware conditional random field for identification of spatio- Pastell, M., Hietaoja, J., Yun, J., Tiusanen, J., Valros, A., 2016. Predicting farrowing of
temporal activity patterns by combined indoor positioning and heart rate sensors. sows housed in crates and pens using accelerometers and CUSUM charts. Comput.
GeoInformatica 20 (4), 693–714. Electron. Agric. 127, 197–203.
Benaglia, Tatiana, Chauveau, Didier, Hunter, David, Young, Derek, 2009. mixtools: an R Rahman, A., Smith, D.V., Little, B., Ingham, A.B., Greenwood, P.L., Bishop-Hurley, G.J.,
package for analyzing finite mixture models. J. Statistical Software, Univ. California, 2017. Cattle behaviour classification from collar, halter and ear tag sensors. Inform.
Los Angeles 32 (6), 1–29. Process. Agric. 5 (1), 124–133.
Benaissa, Said, Tuyttens, Frank A.M., Plets, David, de Pessemier, Toon, Trogh, Jens, Robert, B., White, B.J., Renter, D.G., Larson, R.L., 2009. Evaluation of three-dimensional
Tanghe, Emmeric, Martens, Luc, Vandaele, Leen, Van Nuffel, Annelies, Joseph, Wout, accelerometers to monitor and classify behavior patterns in cattle. Comput. Electron.
Sonck, Bart, 2017. On the use of on-cow accelerometers for the classification of be- Agric. 67 (1–2), 80–84.
haviours in dairy barns. Res. Veterinary Sci. https://doi.org/10.1016/j.rvsc.2017.10. Scrucca, Luca, Michael Fop, T., Murphy, Brendan, Rafter, Adrian E., 2016. mclust 5:
005. clustering, classification and density estimation using gaussian finite mixture models.
Borges, Gabriel, Brusamarello, Valner, 2016. Sensor fusion methods for reducing false R Journal 8 (1), 289–317.
alarms in heart rate monitoring. J. Clin. Monitor. Comput. 30 (6), 859–867. Sendra, S., Llario, F., Parra, L., Lloret, J., 2013. Smart wireless sensor network to detect
Buerkert, A., Schlecht, E., 2009. Performance of three GPS collars to monitor goats’ and protect sheep and goats to wolf attacks. Recent Adv. Commun. Networking
grazing itineraries on mountain pastures. Comput. Electron. Agric. 65 (1), 85–92. Technol. 2 (2), 91–101.
Burla, J.-B., Ostertag, A., Westerath, H.S., Hillmann, E., 2014. Gait determination and Sepúlveda-Varas, Pilar, Proudfoot, Kathryn L., Weary, Daniel M., von Keyserlingk, Marina
activity measurement in horses using an accelerometer. Comput. Electron. Agric. A.G., 2016. Changes in behaviour of dairy cows with clinical mastitis. J. Appl. Animal
102, 127–133. Behav. Sci. 175, 8–13.
Diosdado, Vázquez, Barker, Jorge A., Hodges, Zoe E., Amory, Holly R., Croft, Jonathan R., Shane, Douglas D., White, Brad J., Larson, Robert L., Amrine, David E., Kramer, Jeremy
Bell, Darren P., Codling, Nick J., Edward, A., 2015. Classification of behaviour in L., 2016. Probabilities of cattle participating in eating and drinking behavior when
housed dairy cows using an accelerometer-based activity monitoring system. Animal located at feeding and watering locations by a real time location system. J. Comput.
Biotelemet. 3 (15). Electron. Agric. 127, 460–466.
Dutta, R., Smith, D., Rawnsley, R., Bishop-Hurley, G., Hills, J., Timms, G., Henry, D., Shoaran, M., Haghi, B.A., Taghavi, M., Farivar, M., Emami-Neyestanak, A., 2018. Energy-
2015. Dynamic cattle behavioral classification using supervised ensemble classifiers. efficient classification for resource-constrained biomedical applications. IEEE J.
J. Comput. Electron. Agric. 111, 18–28. Emerg. Selected Topics Circuits Syst. 8 (4), 693–707.
Figueiredo, M.A.T., Jain, A.K., 2002. Unsupervised learning of finite mixture models. Siivonen, J., Taponen, S., Hovinen, M., Pastell, M., Lensink, B.J., Pyörälä, S., Hänninen,
IEEE Trans. Pattern Anal. Mach. Intellig. 24 (3), 381–396. L., 2011. Impact of acute clinical mastitis on cow behavior. J. Appl. Animal Behav.
Fogsgaard, K.K., Røntved, C.M., Sørensen, P., Herskin, M.S., 2012. Sickness behavior in Sci. 132 (2011), 101–106.
dairy cows during Escherichia coli mastitis. J. Dairy Sci. 95 (2), 630–638. Smith, Daniel, Rahman, Ashfaqur, Bishop-Hurley, Greg J., Hills, James, Shahriar, Sumon,
Gonzãlez, L.A., Bishop-Hurley, G.J., Handcock, R.N., Crossman, C., 2015. Behavioral Henry, David, Rawnsley, Richard, 2016. Behavior classification of cows fitted with
classification of data from collars containing motion sensors in grazing cattle. J. motion collars: decomposing multi-class classification into a set of binary problems.
Comput. Electron. Agric. 110, 91–102. J. Comput. Electron. Agric. 131, 40–50.
Gutierrez-Galan, D., Dominguez-Morales, J.P., Cerezuela-Escudero, E., Rios-Navarro, A., Stangaferro, M.L., Wijma, R., Caixeta, L.S., Al-Abri, M.A., Giordano, J.O., 2016. Use of
Tapiador-Morales, R., Rivas-Perez, M., Dominguez-Morales, M., Jimenez-Fernandez, rumination and activity monitoring for the identification of dairy cows with health
A., Linares-Barranco, A., 2018. Embedded neural network for real-time animal be- disorders: Part I. Metabolic and digestive disorders. J. Dairy Sci. 99 (9), 7395–7410.
havior classification. J. Neurocomputing 272, 17–26. Tabasum Ahmed, S., Mun, H.-S., Islam, M., Yoe, H., Yang, C.-J., 2015. Monitoring activity
Halachmi, 2015. Precision Livestock Farming Applications: Making Sense of Sensors to for recognition of illness in experimentally infected weaned piglets using received
Support Farm Management. Wageningen Academic Publishers. signal strength indication zigbee-based wireless acceleration sensor. Asian-
Halasa, T., Huijps, K., Østerås, O., Hogeveen, H., 2007. Economic effects of bovine Australasian J. Animal Sci. 29 (1), 149–156.
mastitis and mastitis management: a review. Veterinary Quart. 29 (1), 18–31. Tang, Y., Verma, N., 2018. Energy-efficient pedestrian detection system: exploiting sta-
Huang, W., Zhu, W., Ma, C., Guo, Y., Chen, C., 2018. Identification of group-housed pigs tistical error compensation for Lossy memory data compression. IEEE Trans. Very
based on Gabor and Local Binary Pattern features. J. Biosyst. Eng. 166, 90–100. Large Scale Integration (VLSI) Syst. 26 (7), 1301–1311.
Huynh, Quoc T., Nguyen, Uyen D., Irazabal, Lucia B., Ghassemian, Nazanin, Tran, Binh Tsinganos, Panagiotis, Skodras, Athanassios, 2018. On the comparison of wearable sensor
Q., 2015. Optimization of an accelerometer and gyroscope-based fall detection al- data fusion to a single sensor machine learning technique in fall detection. J. Sensors
gorithm. J. Sensors 2015, 1–8. 18 (2).
Llario, F., Sendra, S., Parra, L., Lloret, J., 2013. Detection and protection of the attacks to Williams, M.L., James, W.P., Rose, M.T., 2017. Fixed-time data segmentation and beha-
the sheep and goats using an intelligent wireless sensor network. In: IEEE vior classification of pasture-based cattle: Enhancing performance using a hidden
International Conference on Communications Workshops (ICC 2013), pp. Markov model. J. Comput. Electron. Agric. 142, 585–596.
1015–1019. Yang, F., Zhang, L., 2017. Real-time human activity classification by accelerometer em-
Loreti, P., Catini, A., Luca, M.D., Bracciale, L., Gentile, G., Natale, C.D., 2018. Ultra low bedded wearable devices. In: 4th International Conference on Systems and
power wireless sensor network for pink iguanas monitoring. Multidisc. Digital Publ. Informatics (ICSAI), Hangzhou. China, 11–13 November 2017; IEEE, Piscataway, NJ,
Inst. Proc. 2 (13), 978. USA, pp. 469–473.

13

You might also like