# Hierarchical Long Short Term Memory Recurrent Neural Network for Goats Behaviour Prediction from Accelerometer Data

Mathieu Bonneau, Laura Faillot, Willy Troupe, Lucile Riaboff

► To cite this version:

Mathieu Bonneau, Laura Faillot, Willy Troupe, Lucile Riaboff. Hierarchical Long Short Term Memory Recurrent Neural Network for Goats Behaviour Prediction from Accelerometer Data. Smart Agricultural Technology, 2025, 11 (101045), pp.101045. 10.1016/j.atech.2025.101045. hal-05089855

HAL Id: hal-05089855

https://hal.inrae.fr/hal-05089855v1

Submitted on 2 Jun 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_2.png" /></figure>

<figure><img src="image_3.png" /></figure>

# Hierarchical long short term memory recurrent neural network for goats behaviour prediction from accelerometer data

Mathieu Bonneau<sup>a, ID, *</sup>, Laura Faillot<sup>a</sup>, Willy Troupe<sup>b</sup>, Lucile Riaboff<sup>c,d,e</sup>

## ARTICLE INFO

**Keywords:**

Monitoring

Goats

Behaviour

Accelerometers

Long short-term memory recurrent neural network

## ABSTRACT

Gastrointestinal parasitism is a major challenge in small grazing ruminants, affecting animal welfare and farmers' income. In this regard, monitoring individual animal behaviour could help to develop new selection schemes that favor animals with a lower risk of larval infestation, but also support the targeted use of anthelmintic by focusing only on infested animals. Accelerometer sensors are widely used in combination with statistical models to predict the behaviour of grazing ruminants, but the lack of generalization of the models and the limited range of well-predicted behaviours are still challenging. In our study, we introduce an innovative methodology based on hierarchical long short term memory (LSTM) recurrent neural networks to predict the main behaviours of goats on pasture. For that purpose, we collected accelerometer data from the horns of 59 Creole goats and annotated the behaviour over 144 hours of data. We defined 13 moving features that are mathematical combinations of the raw data to get more information while preserving the temporal structure of the accelerometer time-series. A data augmentation technique involving the addition of random noise was applied to sequences from the minority behaviour labels. A hierarchical LSTM model was then built to derive behaviours from a given accelerometer signal, by sequentially combining several models that first tackle simple classification tasks (e.g., grazing or non-grazing segments), then increasingly complex ones (e.g., displacement or other activities), progressively withdrawing segments that have already been identified. The hierarchical LSTM model was validated using a testing set consisting of goats not seen during model training, and carefully selected to maximize behavioural labels heterogeneity. Performance of the hierarchical LSTM model was also compared to those of a regular LSTM model which directly classified the raw signal into the 5 behaviours, used as the baseline. Highest performance was obtained with the hierarchical LSTM model, reaching a Fscore of 87.84%, a precision of 89.44% and a recall of 86.3%. Best performance was obtained for grazing prediction (recall: 99.5%; precision: 99.4%), following by resting (recall: 98.0%; precision: 98.4%) and ruminating (recall: 95.2%; precision: 89%). Most confusions occurred with the displacement (recall: 51.2%; precision: 67.8%), likely due to the low number of sequences in the dataset (0.42% of the dataset). While other avenues remain to be explored for improving the prediction of such rare behaviours, our approach introduces key innovations that not only address the methodological limitations identified in the literature, but also facilitate further exploration of the role of goat behaviour in managing gastrointestinal parasitism on pasture.

## Introduction

Agroecology aims to stimulate natural processes and to design agricultural systems that are weakly artificialized, productive, environmentally friendly and less dependent on chemical inputs [11]. Grazing sys-

tems fully meet the core principle for livestock ruminants as animals are mainly fed with on-pasture and harvested forage with few additional inputs. However, small grazing animals are exposed to gastrointestinal parasitism. The use of anthelmintic drugs for many years has led to an increase in anthelmintic resistance. Their efficiency is now dramatically

<footnote><sup>a</sup> UR143 ASSET, INRAE, 97170 Petit-Bourg (Guadeloupe), France</footnote>

<footnote><sup>b</sup> PTEA, INRAE, Tropical Livestock Experimental Facility, 97170 Petit-Bourg (Guadeloupe), France¹</footnote>

<footnote><sup>c</sup> GenPhySE, Université de Toulouse, INRAE, ENVT, 31326, Castanet-Tolosan, France</footnote>

<footnote><sup>d</sup> School of Computer Science, University College Dublin, Ireland</footnote>

<footnote><sup>e</sup> VistaMilk SFI Research Centre, Ireland</footnote>

<footnote>* Corresponding author.
E-mail address: mathieu.bonneau@inrae.fr (M. Bonneau).</footnote>

<footnote n="1">¹ https://doi.org/10.17180/50N1-KN86.</footnote>
challenged [27]; setting up alternative strategies are therefore urgently needed. Monitoring behaviour in small ruminants should help to select animals for breeding based on their infestation risk, as some individual behavioural characteristics (e.g., exploratory dynamics, feeding strategies, social ability, etc.) may increase the risk of larval ingestion. In addition, detecting a change in behaviour would help to identify the animals that need to be treated as parasitic infestation could alter animal behaviour [18]. Therefore, a fine individual behaviour monitoring on pasture will allow us to (i) understand the relationship between animal behaviour and gastrointestinal parasite load for animal selection purposes, and to (ii) identify animals likely to be infested to apply targeted treatments. Human observation is the reference methodology for collecting information on animal behaviour. However, observation is time-consuming and labor intensive; this technique is thus not adapted for a continuous monitoring over long periods [23]. In that respect, on-board accelerometer sensors that can monitor animal behaviour automatically are extremely relevant [25,1]. Accelerometers are non-invasive, have a long battery life (> 1 month) and are small and light enough to be fitted to the animal's neck, legs, back, etc., without causing any disturbance. They return a continuous accelerometer data stream on a three-dimensional plane that can be turned into a succession of animal behaviours (e.g., grazing, ruminating, resting, etc.). A 3-steps methodology is typically applied to translate accelerometer signal into animal behaviour [26] i.e.: (1) Collecting accelerometer data with behaviour annotations, (2) Processing accelerometer data to calculate features aligned with the annotated behaviours (reference measure), and (3) Developing a statistical model from accelerometer features to classify the time-series into behaviours. Generally, this methodology leads to good performance for small ruminants on pasture. [24] achieved accuracies of 83.7% for ewes' postures and 70.9% for ewes' grazing activities using accelerometer neck-collars and Random Forest algorithm. [7] also found an overall accuracy of 84% for classifying grazing, ruminating and "others" using a neck-collar and Discriminant Analysis. However, [26] underlined the complexity of developing generalizable models, i.e., models that maintain strong performance when applied to conditions different from those used for model training. Recent research in small ruminants further support this finding. [4] applied models on 5 new animals using different deployments and showed a large variation in accuracy between sheep, depending on the behaviour and sensor position. Similarly, [8] highlighted the impact of terrain on accelerometer data interpretation and the variation between captive conspecifics goats and their domesticated counterparts. In that regard, deep learning models developed from raw and/or accelerometer features seem more generalizable than machine learning models. [2] reached a good generalization from one animal to another (Matthews Correlation Coefficient > 0.85) and from one dataset to another (Matthews Correlation Coefficient > 0.80) for classifying the main behaviours of grazing cattle using MultiLayer Perceptron. In small ruminants, [28] compared several machine learning and deep learning methods and showed superior generalisability of the latter on unseen sheep. Among deep learning models, Long Short-Term Memory Recurrent Neural Network (LSTM) is relevant for accelerometer time series, as the memory capabilities allow the sequential nature of the data to be taken into account for behaviour classification [28]. [26] also highlighted the difficulty of correctly classifying a large spectrum of behaviours. This is partly due to the fixed window size of the accelerometer signal used for classification, for which finding an optimal value is challenging: longer time windows are more informative and give better results for behaviours such as grazing or ruminating, but they also lead to a drastic reduction in the number of windows available for shorter behaviours such as walking or grooming, while the datasets are already suffering from class imbalance. In this respect, splitting the classification problem between several models specialised in a given classification task (e.g., ruminating/grazing/other; standing/lying, etc.), as proposed in [28] seems very promising. In particular, a hierarchical approach that sequentially combines multiple models to tackle increasingly complex classification tasks is worth exploring. The objective of this study

is to develop a Hierarchical Long Short-Term Memory Recurrent Neural Network model that (i) ensures accurate classification of the main behaviours of small ruminants on pasture and that (ii) is generalizable enough to monitor individual behaviour regardless of the animal. This model will be developed for livestock goats, given the few studies that have focused on this ruminant species (< 10%; [26]) and the parasitism challenge faced in these animals. The model will then be used to monitor individual goat behaviour in relation to gastrointestinal parasite infestation in order to design alternative strategies.

## Material & methods

### Data collection

Experiment took place from March 2023 to March 2024 at the INRAE Tropical Livestock Experimental Facility (PTEA, INRAE, 2024) located in Guadeloupe (French West Indies). The experiment describes in this article were performed in accordance with the current French law on animal experimentation and ethics (#69-2023-3_v2 from the Animal Care and Use Committee of French West Indies and Guyana).

The dataset used in this article is extensively described in [12]. For that reason, only a brief description is provided here and we refer to the data article for more details on the data collection.

### Experimental design and animals

The aim of the data collection was to obtain accelerometer data and to film the animals at the same time expressing natural grazing behaviours. To do this, 59 adult lactating and pregnant Creole goats were split into small groups of 2 to 5 animals and isolated in an experimental paddock (20 m x 10 m, see Fig. 1.a). A camera fixed high up was used to film the animals. The goats were equipped with a 3-axes accelerometer sensor attached to the horn (see the next section) and fitted with collars of different colors to help distinguish them in the videos. Animal identifier, accelerometer identifier, coat color and collar were recorded for each goat. Animals are outdoor grazing year-round and the paddock provided grazing conditions similar to those the animals usually experienced. The goats were free to graze in the paddock for 6 to 8 consecutive hours, and the groups of animals were rotated daily, with breaks between observations, according to farm constraints and to ensure a sufficient supply of grass. The animals had *ad libitum* access to water.

### Accelerometers and cameras

3-axes accelerometer sensors (AX3, Axivity Ltd, Newcastle, UK; 11g) were used for the trial. Accelerometers were setup with tape to the left horn of each animal (as viewed from the front of the animal's head; see Fig. 1.b).

The X axis is along the horn, the Y axis along the back of the animal, and the Z axis is perpendicular to and on the same plane as the Y axis. The positioning of the accelerometers was standardized to allow for comparative analysis across different animals. Acceleration data were recorded at a frequency of 25 Hz with a sensitivity of +/- 8 g.

The groups of animals were monitored using a CCTV camera connected to a Raspberry Pi that saved the footage on a hard drive. Videos were collected at the end of each day of experimentation. Videos were recorded in h264 format and then converted to mp4 to be readable on any computer.

### Timestamp synchronization

Timestamps of the accelerometers and the cameras must be synchronized. The accelerometers were automatically synchronized to UTC time using a computer with the Open Movement software provided by the accelerometer's manufacturer. The CCTV camera was not connected to the internet, and the camera time was synchronized after recording. We simply presented the clock of a smartphone close to the camera while it was recording. We then computed the offset between the camera time
<figure><img src="image_4.png" /><figcaption>Fig. 1. (a). Illustration of the experimental setup. (b). Location and setup of the accelerometer on the animal's horn.</figcaption></figure>

<table><caption>**Table 1**

Definition of the five activity classes considered in this study.</caption><thead><tr><td>Behavioural labels</td><td>Descriptions</td></tr></thead><tbody><tr><td>Grazing</td><td>The animal is grazing with the head down. Between grazing sequences, the animal can pull its head up for chewing. The chewing sequences that last less than 5 seconds were labelled as Grazing, and as Ruminating/Chewing for longer sequences</td></tr><tr><td>Displacement</td><td>The animal is moving, either walking or running inside the pasture but not grazing. It can be for example to move to the water bucket. Transitions between standing/lying and lying/standing were also labelled Displacement.</td></tr><tr><td>Ruminating/Chewing</td><td>The animal is either standing or lying, with the head straight and ruminating or chewing, with a moving jaw. During two Ruminating/Chewing sequences, the animal can stop the jaw movement. When the sequence was shorter than 3 seconds, it was labelled as Ruminating/Chewing. Longer sequences were labelled as Resting.</td></tr><tr><td>Resting</td><td>The animal is either standing or lying, with the head straight, or set down on the ground, with no activity. Sequences where the animal was on alert, with quick changes of the head direction was not labelled as resting, but Other. Same when the animal was bleating.</td></tr><tr><td>Other</td><td>All other observed behaviours. It includes, grooming, bleating, alarm, eating the hedges, scratching, social interactions, drinking, urinate or defecate.</td></tr></tbody></table>

and the corresponding UTC time when the clock was visible. The camera time at the start and end of the video was manually read from the footage, saved, and converted to UTC time. Taking into account the frame rate of the camera, each video frame was then associated with a UTC time, which could be compared to the accelerometer time. In addition, as the time-drift is usually observed regardless of the electronic device, additional corrections were applied to compute and correct the time-drift. We refer to [12] for a detailed explanation of the procedure applied.

### Behaviour annotations and alignment with the accelerometer time-series

Behaviour labelling was done from the videos with the Boris software [13]. For that purpose, a 5-classes activity ethogram has been set up from the main goats' behaviours, i.e., Grazing, Displacement, Ruminating/Chewing, Resting and Other. They are described extensively in Table 1. Each animal was identified in the video by coat and collar color. The experimental design allowed easy annotation of behaviours from the videos, except when the animals were far from the camera or in shaded areas. These sequences were thus excluded from the analysis. The output of this annotation step is a csv file with the animal's identifier, the annotated behaviours and the associated time in UTC format. Behavioural annotations were then merged to the corresponding accelerometer data to create the dataset. The final dataset consists of accelerometer data associated with behavioural labels.

### Data description

In total, 144 hours of acceleration data collected from 59 different animals were manually labelled with one of the five behaviours. Dataset statistics are presented in Table 2. As shown, the labelling time varies significantly among the behaviours. This heterogeneity reflects the natural behaviour of the animals, with some behaviours being naturally longer and more frequent, such as grazing and resting. Additionally,

not all behaviours were observed for all 59 animals. For example, displacement and ruminating/chewing were observed in only 31 and 33 animals, respectively.

### Splitting data into training and test sets

As the model aims to be applied with other animals than those used during model training, we used data from different animals for training and model evaluation. For that purpose, a selection procedure has been applied to identify the most suitable animals for model evaluation, i.e., animals with both a substantial amount of annotated accelerometer data and behavioural labels heterogeneity. The following procedure has been applied for selecting animals for the Test Set:

1. **Duration-Based Selection:** We first computed the total duration of the annotated data for each animal and selected the top 10 animals with the highest duration as potential candidates for the test set.

2. **Entropy Calculation:** We then identified animals with the largest heterogeneity in their labelled data. Indeed, if Animal 1 has 50 hours of data labelled as grazing exclusively, and Animal 2 has 10 hours in each of the 5 behaviours, Animal 2 would be preferred for testing as it provides a more balanced evaluation. For that purpose, we computed the entropy of the labelled data across the 5 behaviours for each animal: if $p_i$ is the proportion of labelled data for behaviour i, the entropy is defined as $\sum_{i=1}^{5} -p_i \log(p_i)$. In that way, Animal 1 in the previous example would have lower entropy than Animal 2.

3. **Selection of Test Set:** The top 10 candidates were sorted in decreasing order of entropy, and the set of animals with the highest entropy that represented at least 20% of the total labelled duration of the entire dataset was selected.
<table><caption>**Table 2**
Dataset statistics. A sequence is defined as a continuous series of acceleration data from the same animal exhibiting the same behaviour. The cumulative time represents the total duration of the labelled sequences for each behaviour.</caption><thead><tr><th>Behaviours</th><th>Cumulated time (h)</th><th>Mean sequences duration (s)</th><th>Number of sequences</th><th>Number of animal per sequence</th><th>Mean number of sequences per animal</th></tr></thead><tbody><tr><td>Displacement</td><td>0.61</td><td>7.03</td><td>312</td><td>31</td><td>10.06</td></tr><tr><td>Grazing</td><td>67.67</td><td>32.93</td><td>7398</td><td>56</td><td>132.11</td></tr><tr><td>Ruminating / Chewing</td><td>10.58</td><td>29.73</td><td>1281</td><td>33</td><td>38.82</td></tr><tr><td>Other</td><td>6.23</td><td>9.23</td><td>2429</td><td>58</td><td>41.88</td></tr><tr><td>Resting</td><td>59.55</td><td>42.2</td><td>5080</td><td>57</td><td>89.12</td></tr></tbody></table>

<figure><img src="image_5.png" /><figcaption>**Fig. 2.** Example of augmented signal data.</figcaption></figure>

Following this procedure, 7 animals were chosen for testing and 52 for training. The Test Set represents 21% of the original dataset.

## Data augmentation

As explained in the data description section, the dataset shows an imbalance between the behavioural labels. Imbalanced datasets pose a challenge for classification problems in machine learning and deep learning, as predictions tend to consistently favor the majority class. The objective of data augmentation is to balance the number of training samples in each class. In this study, we used the following data augmentation technique to achieve balanced training data in the training set (see Fig. 2 for an illustration):

1. **Selection of random accelerometer sequences:** a sequence is defined as a continuous series of acceleration data from the same animal exhibiting the same behaviour. We randomly selected sequences from the class that required augmentation (i.e., the minority classes). Sequences were randomly selected until behavioural labels are balanced.

2. **Calculation of noisy sequences:** for each selected sequence, noise was applied as follows. Let $\{X(t)\}_{t=1}^l$ represents the original sequence signal of length $l$. The noisy version $X^n(t)$ is defined as $X^n(t) = X(t) \times (1 + \frac{n(t)}{100})$, where $n(t)$ is a random real number between -30% and +30%, and $t \in [1, \dots, l]$ is the time step. The noise applied is therefore homogeneous within the sequence, leading to low up to high-level noisy sequences. The level of noise is different and drawn randomly for each selected sequence.

## Features calculation

To increase the amount of information derived from the raw acceleration data, we defined several features that are mathematical combinations of the raw data [26]. In addition to the accelerations along the three spatial axes $(X, Y, Z)$, we first computed the sum of the absolute values of the accelerations: $|X| + |Y| + |Z|$. Next, we computed several moving statistics on this sum: the mean, standard deviation,

maximum, minimum, and median values. The moving statistics were computed with a window size of 25, equivalent to 1 second. Finally, we calculated the derivative information, defined as $v(t) - v(t - 1)$, where $v$ is the signal being differentiated, and $t$ is the time. We applied this to the three acceleration signals $(X, Y, Z)$, as well as to the sum of their absolute values. In total, 13 features were used to predict the behaviour (see Fig. 3 for an illustration).

## LSTM models

### Objective and relevance of the LSTM model

Our aim is to identify the succession of behaviours from an original accelerometer signal using the 13 derived features (see the previous section). In that regard, Long Short-Term Memory (LSTM) neural networks are highly relevant. LSTM neural networks are a type of Recurrent Neural Network (RNN), particularly suited for time-series prediction. RNNs use circular connections between their layers, allowing past information to influence current predictions. LSTM networks [16] are an enhanced version of RNNs [30], designed to solve convergence problems caused by back-propagated error signals, thereby enabling the learning of long-term dependencies [14].

In this study, we used bidirectional LSTM networks [15], which account for both past and future information in the time series for current predictions. This approach is especially suitable when the entire time-series is known at the time of prediction. In our context, accelerometers are set up on the animals for a period and then removed to analyze the entire signal. In other contexts, such as real-time behaviour estimation, unidirectional LSTMs would be preferred.

### Training batch data points calculation

The gradient of the LSTM network is not computed on all training data at once, but iteratively on small batches of the same length, containing only a subset of the training sequences. Therefore, we created training batch data points (TBDPs) of same length $l$ from the sequences as follows (see Fig. 4):

1. We first randomly selected a sequence of data from the training set. If the sequence length exceeds $l$, only the first $l$ data points were
<figure><img src="image_6.png" /><figcaption>Fig. 3. Example of features computation.</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>Fig. 4. Example of constructing training batch data points (TBDPs). For clarity, only the signal magnitude is drawn, but in practice, the TBDPs were constructed using all the 13 features. The signal color indicates the labelled behaviour. The initial signal comprises 5 different sequences. In this example, the TBDP length is set to 500, so the original signal will yield a total of 6 TBDPs. Note that a single TBDP may include data points from different behavioural labels. Each TBDP is a matrix with 13 rows for each sequence of features and 1 column.</figcaption></figure>

included in the TBDP (truncating), and the remaining data points were used for creating subsequent TBDPs. If the sequence length is shorter than *l* (padding), it is completed with another randomly chosen sequence, adjusted as described above.

2. Each TBDP was created from the 13 sequences derived from the features calculation. A TBDP is thus a matrix with 13 rows (representing the 13 sequences of features) and *l* columns.

### Model set-up and parameters

The LSTM model we used (see Fig. 5) consists of a sequence input layer with *z-score* normalization, where the input data are normalized by subtracting the mean value and dividing by the standard deviation.

The input layer is followed by a bidirectional LSTM layer, a softmax layer, and a classification layer. Two parameters are essential when using LSTMs, the number of hidden units is the first one. This parameter determines the amount of information the LSTM layers retain between time steps. Large values generally lead to overfitting the training data and increased computational cost. Low values generally lead to underfitting, loss of information and poor generalization capacity. The second critical parameter is the length of the TBDPs. In particular, labelled sequences often vary in length (e.g., a grazing sequence is typically longer than a displacement one; see Table 2), making it difficult to identify the optimum length of the TBDPs. The challenge of selecting a TBDP length is similar to choosing the appropriate time windows for segmenting
<figure><img src="image_8.png" /><figcaption>Fig. 5. LSTM networks.</figcaption></figure>

tation using machine learning algorithms [26]. Moreover, as detailed in Table 2, the training data are highly heterogeneous, complicating the convergence of the training algorithm. Parameters optimized for one behaviour may not yield accurate predictions for other activities. To address these challenges, we proposed a hierarchical prediction model that selects different LSTM configurations, each adapted to specific behavioural label.

## Hierarchical LSTM models

### Hierarchical LSTM model design

The idea of the hierarchical model is to derive the behaviour from a given accelerometer signal step by step. First, we constructed a model to determine segments of the accelerometer signal where the animal is grazing versus non-grazing. For the non-grazing segments, we applied a second model to identify parts where the animal is resting/ruminating/chewing (RRC) or not. The segments identified as RRC are then analyzed with a third model to differentiate between resting and ruminating/chewing. Finally, the segments identified as non-RRC are analyzed with a last model to distinguish between other activities and displacement. A schematic representation of the hierarchical model is shown in Fig. 6.

### Models fitting using the training set

Each LSTM model works with binary type data (e.g. RRC vs non-RRC), as a consequence, the initial training set needs to be adapted for training. For the first model, the entire training set was used, with all non-grazing sequences labelled as non-grazing. For the second model, the grazing sequences are removed, and the resting and ruminating/chewing sequences are labelled RRC, while other sequences are labelled non-RRC. The third model uses only the resting and ruminating/chewing sequences from the initial dataset. The fourth model uses only the displacement and other sequences. For each model, the minority class was augmented, as detailed in the Data Augmentation section. As mentioned earlier, two important parameters need to be tuned: the number of hidden units in the LSTM layer and the length of the TBDP in the training batches. To select the best options for each model, we tried different sets of parameter values and chose the ones with the best prediction scores. Value ranges retained for each parameter from preliminary tests are displayed in Table 3. Each sequence length was tested with the four values for the hidden units. For example, 4 × 5 = 20 versions of Model 1 were trained. Models were trained using the *adam* solver for 5 epochs with training batches containing 5 TBDPs. All computations were performed on an RTX 3060 12GB GPU and an AMD Ryzen 5 5600X 6-core CPU using Matlab.

The different model configurations were evaluated individually to select the best values for the number of hidden units and the length of the TBDP for each model. For example, Model 1 was assessed on its ability to differentiate between grazing and non-grazing sequences. The best parameters for each model were then used in the final hierarchical model.

## Hierarchical LSTM model evaluation

### Evaluation on the entire accelerometer time-series from the testing set

The final hierarchical model was evaluated based on its overall prediction performance (as illustrated in step 6 of Fig. 6) using the accelerometer time series from the animals selected in the testing set (see section *Splitting data into Training and Test sets*). We remind that the final hierarchical model is composed of the 4 LSTM models, where each one is setup with their optimal values of the number of hidden units and length of the TBDP (see previous section). The hierarchical model will be evaluated with common metrics for classification problem: F1-score, recall and precision.

It is important to note that models were evaluated here on their ability to predict behaviours from a raw accelerometer time-series. In this article, we derived the entire accelerometer time series from the animals selected in the testing set, computed the 13 features, inputed these features to the networks, and then compared the predicted behaviour to the labelled one, on each accelerometer record (i.e. time step 1/25 s). As described in Fig. 6, this is the entire final signal obtained in step 6 that is compared to the labelled one.

### Error and timestamp synchronization

As described in the *Timestamp synchronization* section, the accelerometer signals and behaviour labels were time-synchronized using a manual procedure. Unfortunately, it is hard to ensure a perfect time synchronization. As a result, if a behaviour label segment starts at time *t*, the corresponding acceleration segment might in reality starts at *t* ± *δ*, with *δ* << 1 second. In practice, it is impossible to down *δ* to 0, as far as the CCTV camera and accelerometer are not synchronized in real-time or physically. See Fig. 7 for an illustration.

Although *δ* is usually negligible, we were interested to quantify part of the classification error that was likely due to the offset between behaviour label and acceleration segments. In particular, *δ* represents a very small proportion of the segment length for long behaviour, such as grazing or resting, and thus represents a small proportion of error. But in contrary, it might represent an important proportion of the segment, and thus error, for short behaviour, such as other (e.g. grooming).

First, we compared the predicted and labelled behaviour, sequence by sequence. Then we recorded the location of all the differences inside the sequence. If error is located on accelerometer record *i*, for a sequence of length *p*, we computed the following error location index $\frac{i-1}{p}$. The index is close to zeros for the errors located on the beginning of the sequence, close to $\frac{1}{2}$ when it is located on the middle, and to one when it is located at the end of the sequence.

If we observed that most of the error are located at the start or end of the sequence, we might hypothesis that the error is not necessarily due to a misclassification from the algorithm, but rather from the timestamp synchronization procedure. Another possibility would be the capacity of the LSTM to switch from one behaviour to another.

## Comparison with non-hierarchical LSTM model

We also trained regular LSTM model as a baseline for comparison with our LSTM with the hierarchical structure. The regular model classifies the raw accelerometer signal into 5 classes directly.

The procedure applied for training was the same as the one used for the Hierarchical LSTM: a set of model parameters, i.e., number of hidden units and length of the TBDP, was tested to identify the optimal configuration for the final LSTM model. To save computation time and resources, we selected candidate parameters based on the best parameters obtained for model 1, 2, 3 and 4. We trained one regular LSTM for each possible configuration of the optimal number of hidden units and length of the TBDP of each model. We used the same training and test dataset, ensuring that both models were compared under the same conditions and data. Augmentation technic was also used during training and the 13 features were used as predictor variables.
<figure><img src="image_9.png" /><figcaption>**Fig. 6.** Schematic representation of the hierarchical model. For clarity, we only display the signal magnitude. The first model is used to determine the grazing and non-grazing segments. Then, Model 2 is applied to the non-grazing segments to identify segments where the animal was resting/ruminating/chewing (RRC) or not. Note that black signal segments are not analyzed at this step; they are classified as grazing for the remainder of the process. Model 3 is then applied to distinguish between resting and ruminating/chewing, while Model 4 selects between displacement and other activities. Models 3 and 4 can be applied in parallel but only after using Model 2, which in turn is applied after Model 1.</figcaption></figure>

<caption>**Table 3**</caption>

Number of hidden units and lengths of the training batch data points (TBDP, seconds) tested for each model. Each length was tested with the four values for the hidden units. For example, 4×5=20 configurations were trained for Model 1.

<table><thead><tr><td>Parameters</td><td>Number of hidden units</td><td>Length of the TBDP (seconds)</td></tr></thead><tbody><tr><td>Model 1 (Grazing vs non-grazing)</td><td>{100, 150, 200, 250}</td><td>{60, 120, 300, 600, 1800}</td></tr><tr><td>Model 2 (RRC vs non-RCC)</td><td>{100, 150, 200, 250}</td><td>{4, 8, 20, 40, 80, 120, 160, 180, 200}</td></tr><tr><td>Model 3 (Resting vs Ruminating/Chewing)</td><td>{100, 150, 200, 250}</td><td>{4, 8, 20, 40, 80, 120, 160, 180, 200}</td></tr><tr><td>Model 4 (Displacement vs Other)</td><td>{100, 150, 200, 250}</td><td>{2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 30, 40, 50, 60, 100}</td></tr></tbody></table>

## Results

### Best parameters for each LSTM model in the hierarchical approach

Values of the model parameters for the best models are provided in Table 4. F1-scores for each model depending on the values of the parameters are displayed in Fig. 8.

For Model 1, the F1-score is relatively consistent across all tested parameters, with a minimum value of 99.19 and a maximum value of 99.39, obtained with a length of 300 seconds and 100 hidden units. For Model 2, the best F1-score of 96.75 is obtained with a length of 160 seconds and 250 hidden units, although the latter does not have much influence on the prediction performance. However, model performance is lowest for the shortest batches, getting more stable from 80 seconds. For Model 3, the best F1-score of 96.18 is obtained with a length of 160 seconds, beyond which a plateau is reached. Best performance is achieved with 250 hidden units, although this parameter does not have much influence on the prediction performance. For Model 4, the length of 20 seconds combined with 200 hidden units leads to the best F1-score

<figure><img src="image_10.png" /><figcaption>**Fig. 7.** Example of a resting segment. After the dotted lines, we observed a change in signal magnitude. This change might be due to timestamp synchronization error, as far as the animal was possibly changing its behaviour.</figcaption></figure>
<figure><img src="image_11.png" /><figcaption>Fig. 8. Values of the F1-score for the different models and model parameters. The sequence length refers to the length of the batches during network training, in seconds. The different colors of the points indicate the number of hidden units used in the LSTM layer. The F1-score is averaged over all activities.</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>Fig. 9. Confusion matrix for the final (a) hierarchical and (b) non-hierarchical models.</figcaption></figure>

**Table 4**

Values of the average F1-score and model parameters for the best prediction models. Length refers to the length of the sequences within the batches during training, in seconds. Hidden units denote the number of hidden units used in the LSTM layer. The F1-score is averaged across all activities.

<table><thead><tr><th>Parameters</th><th>Model 1</th><th>Model 2</th><th>Model 3</th><th>Model 4</th></tr></thead><tbody><tr><td>Length</td><td>300</td><td>160</td><td>160</td><td>20</td></tr><tr><td>Hidden Units</td><td>100</td><td>250</td><td>150</td><td>200</td></tr><tr><td>F1-Score</td><td>99.39</td><td>96.75</td><td>96.18</td><td>94.67</td></tr></tbody></table>

of 94.67. Performance indeed decreases from 20 seconds onwards while the number of hidden units does not have much influence either.

The optimal length varies from one model to another, confirming the necessity of using hierarchical models for prediction (see Table 4). Indeed, the longest batch data points are used for Model 1, which differentiates between grazing and non-grazing. The shortest are used for Model 4, which differentiates between displacement and other activities, behaviours with typically the shortest average duration in the dataset. Models 2 and 3 used long training batch data points of 160 seconds, likely influenced by the ruminating/chewing and ruminating behaviours. Conversely, the lengths of the batches are shorter than for Model 1, probably due to the influence of the displacement and other behaviours that are still included in the dataset at that stage of the Hierarchical Model. Interestingly, increasing the number of hidden units in the LSTM layer does not necessarily improve model performance (see Fig. 8).

**Final hierarchical model**

The hierarchical model reached an F1-score of 87.8%. The confusion matrix is available in Fig. 9.a.

The model is extremely accurate in predicting grazing and resting behaviour, with precision and recall rates exceeding 99% for grazing and 98% for resting. Predictions for the ruminating/chewing behaviour are slightly less accurate, with a precision of 89% and a recall of 95.2%. Most errors in this category are due to confusion with the resting behaviour.

Other activities are relatively well predicted, with a precision of 92.6% and a recall of 87.7%. Again, most errors are due to confusion with resting and grazing behaviours.

The displacement behaviour is the hardest to predict, with a recall of only 51.2% and a precision of 67.8%. Most errors for this behaviour are due to confusion with resting and other activities. The low prediction performance for this behaviour could possibly be explained by the few number of sequences in the initial dataset (see Table 2).

**Errors location**

The location of the errors inside the sequences are available Fig. 10.

For the displacement behaviour, the location of the errors is relatively homogeneous. In contrast, the proportions of errors located at the beginning and at the end of the sequence are higher for the other behaviours.

Overall, 96.29% of the errors occur during the first 10% and the last 10% of the sequences. Interestingly, there is an increase in errors after the middle of the resting segments.
<figure><img src="image_13.png" /><figcaption>**Fig. 10.** Errors location index inside the sequence. The index is close to 0 when the error (i.e., the difference between prediction and label at one time step) is located at the beginning of the sequence, and close to 1 when located at the end.</figcaption></figure>

## Non-hierarchical model

Different versions of the regular LSTM model were trained, using the combination of the best parameter values obtained from the hierarchical one, available in Table 3. More precisely, we tested TBDP length of 20, 160 and 300. As mentioned earlier, the number of hidden units only have small impact on the prediction quality, and only models with 200 hidden units were tested, thus in total 3 models were trained. The best F1-score for the regular LSTM model was obtained for a sequence length of 300 and 200 hidden units. The model reached an F1-score of 86.5%, slightly below the F1-score obtained with the Hierarchical model (87.7%).

The confusion matrix is available in Fig. 9.b. Recall and precision are also slightly below those obtained with the Hierarchical model regardless of the behaviour, except for the recall of displacement only (+3.2% with the regular LSTM). It should be noted that a substantial improvement is observed for ruminating/chewing (RC) and displacement, with an increase of 7% in recall and precision, respectively.

The lowest performance was observed for displacement, as was the case with the hierarchical approach, with most confusions occurring with resting.

## Discussion

### A high-performance approach for classifying goat behaviour from accelerometer data

In this article, we presented the first hierarchical LSTM model for predicting livestock ruminant behaviour using acceleration data. We illustrated our method on acceleration data from adult female Creole goats, with accelerometers fitted on their horns. The hierarchical LSTM model's accuracy to predict the main grazing goat behaviours (grazing, ruminating, resting, displacement and other activities) is high (average precision: 89.44% and recall: 86.3%).

The proposed model represents a significant improvement compared to those in the literature. Although it is hard to compare with different studies due to variations in species, accelerometer models, placement on animals, and test procedures. For goat species, the performance in our study is much better than the one recently obtained by [8] when the Random Forest model is tested on Alpine ibex (F1 score: 37%) and pygmy goats (F1 score: 34%) not seen during model training. However, it is worth noting that the classification problem in the latter study is more complex, involving 11 behaviours to predict. In our study, the best performance is obtained for grazing prediction (recall: 99.4%; precision: 99.5%), probably because this behaviour cannot be associated with another behaviour since its signal magnitude is high, sequences are long, and it has a high labelled duration in the dataset. Excellent performance was also obtained for resting (recall: 98.0%; precision: 98.4%) and ruminating/Chewing (recall: 95.2%; precision: 89%). Most confusions occurred with the displacement (recall: 51.2%; precision: 67.8%), likely due to the low number of sequences in the dataset (0.42% of the dataset). This result is consistent with [8] since the recall (< 25%)

and precision (< 25%) of walking and trotting are much lower than those of resting and eating behaviours (> 75%) (model trained with pygmy goat behaviour to predict Alpine ibex behaviour; terrain slope included). In addition, our hierarchical LSTM model performed well for the other activities (recall: 87.7%; precision: 92.6%). However, we have not tried to predict the behaviours that make up this class (e.g., grooming, standing up, lying down, social interaction), as there is little annotated accelerometer data for all these rare and short behaviours. Indeed, grooming represented 46.85% of the other data, and 10.05% for social interaction. In addition, it is worth noting that 96.29% of the errors were located in the first 10% or last 10% of the sequences. This could be due to the synchronization errors between the video frames and the acceleration data. Perfect synchronization is hard to guarantee, leading to possible gaps where the behaviour does not exactly start at the beginning of the sequence or stop at the end. However, this can most likely be explained by the capacity of the LSTM to switch from one behaviour to another, due to the memory of the past and future segments. Indeed, we performed the same work, trimming 20% of the sequences, 10% at the beginning and 10% at the end, to remove possible behaviour annotation problem due to synchronization error but we still got similar results with the same optimal parameters (average recall: 87.12% and average precision: 89.12% leading to F1 score: 88.11% versus 87.8% with the non-trimmed dataset). Finally, it should be noted that predictions using hierarchical LSTM model are also fast to compute. For reference, predicting a one-hour sequence took 11.54 seconds on an Apple M3 Max using Matlab R2024a. This calculation time is therefore perfectly compatible with the applications under consideration.

### Look back to the development to address the current limitations

The lack of generalizability of the models when applied to new conditions (new animals, farms, sensors, etc.) is one of the main limitations of the general methodology for obtaining ruminant behaviours from raw accelerometer data [26]. Recently, [5] have applied Transfer Learning to improve the robustness of the models, but they still observe low accuracy when the models are trained and validated with different cows, sensors, reference data and environments. [9] have built Personalized Weighted AdaBoost models based on the similarity of the accelerometer signal between calves to address this issue, but none of similarity calculation technique achieved the performance of models trained and validated on the same individual. The small spectrum of accurately predicted behaviours is another main limitation highlighted in [26]. [2] recently highlighted that, despite the cutting-edge Multi-Layer Perceptron architecture developed in their study, achieving strong performance on rare cattle behaviour classes remains highly challenging. [17] also showed that performance decreases significantly when more than 5 behaviour classes are considered, even though they used an innovative approach based on time-frequency domain representation combined with a basic multi-layer perceptron Deep Neural Network. In our study, we tried to address these two limitations at each stage of the methodology.
## Data collection

We annotated 144 hours of accelerometer data from 59 Creole goats with behaviours in order to encompass as much inter-individual variability as possible in the dataset, going well beyond the recommendations (> 25 animals; > 40 hours of annotations; [26]). Getting such a comprehensive dataset is the first step to address both limitations.

## Data pre-processing

We have carefully accounted for the imbalance between behavioural labels, as this is a main issue for the prediction of the minority classes. In that regard, we applied data augmentation to the minority behavioural labels in the training set by generating noisy accelerometer sequences with random noise levels. This technique is innovative in the field: data augmentation is generally not applied, although window overlap [3] or SMOTE algorithm [28,21] have been used in recent studies. Furthermore, running features were computed so that the temporal structure of the accelerometer data was taken into account in the classification process. Indeed, each data point is a matrix of 13 features of a given length, rather than a vector of features where the temporal structure is completely lost. Preserving the structure of the data should improve the prediction of behaviours whose time series has a characteristic shape aligned over time [10], thereby increasing the spectrum of well predicted behaviours. Moreover, we performed classification on the entire sequence of accelerometer data rather than on truncated time-windows. This avoids arbitrarily withdrawing annotated accelerometer data whose duration is less than the fixed window size, which is a major issue when predicting short behaviours.

## Classification model development

Although the benefits of deep learning for enhancing model generalization are well established in Human Activity Recognition [22], its application within our domain is still in its early stages [26]. In this study, we implemented a LSTM model as it is particularly suited for time-series prediction. This is in line with [29] where LSTM models yield to slightly better performance than Convolutional Neural Network-based models for cattle behaviour classification from accelerometer data. We also used bi-directional LSTM networks that are more suitable when the entire time-series is known at the time of prediction. Supporting this, [31] found a substantial improvement in the prediction of 6 cattle behaviours when using a bi-directional LSTM model compared to its basic version. However, the main advance of our study lies in the development of a hierarchical version of the LSTM model. According to the author's knowledge, this approach has never been applied in our domain, although hierarchical models have already been introduced in Human Activity Recognition [6]. The core idea behind the hierarchical model is that fitting a single prediction model for all behaviours is challenging due to the differences in sequence length between activities. This is similar to the problem of the optimal window size of the accelerometer signal when using machine learning models, as highlighted in [26], but also in several recent studies [20,4]. In that regard, the hierarchical architecture allows us to merge behaviours with similar characteristics. For example, resting and ruminating/chewing have long sequences and relatively low signal magnitudes, while displacement and other activities have higher signal magnitudes and shorter sequences. In addition, withdrawing long sequences (e.g., grazing) upstream which are easy to predict, contributes to reduce label imbalance downstream. For these reasons, our hierarchical LSTM model is a way to increase the range of the behaviours correctly predicted. This is consistent with the substantial improvement observed for the prediction of ruminating/chewing (recall: +7%) using the hierarchical LSTM compared to the regular one. Finally, our hierarchical LSTM model was evaluated under ideal conditions to evaluate its generalizability. First, the model was tested on acceleration sequences from animals not present in the training dataset. Second, we used the entropy criterion to identify the animals that optimize behavioural label heterogeneity in the testing set. Finally, acceleration sequences of all animals were evaluated at once, not in

a sequence-to-sequence evaluation type. This means that the prediction does not focus on a signal window associated with a single behaviour but on a segment that may include different behaviours, from different animals. This scenario is much closer to real-life conditions, where we have no certainty that a window will be associated with a single behaviour [2]. Nevertheless, the agreement between the behavioural metrics (e.g., time budgets, episode duration, number of episodes) observed and predicted by the model also deserved to be assessed on a grazing day with new animals as an additional validation of the model's reliability for the targeted applications.

## Suggestion for further improvement

Although our approach is convincing in classifying the main grazing behaviours of Creole goats with a good generalizability from one animal to another, predicting short and/or rare behaviours such as displacement, is still challenging. One possibility is to merge displacement with other activities, which would likely improve the model's prediction metrics. Alternatively, increasing the dataset with displacement sequences is another option, though it could be time-consuming since most displacements occur during grazing sequences. A specific experiment could be organized for the displacement sequence, such as setting up a walking path on the farm and encouraging the animals to move along it. However, ensuring all animals are truly moving might be difficult, as some may stop or interact socially with others. It could also be worth exploring other data augmentation techniques to increase the number of sequences. In this study, data augmentation is based on the addition of random noise, but other techniques and combinations are worth investigating. Indeed, [19] compared several data augmentation techniques to classify cattle behaviours from sensor inertial data and they obtained substantial differences depending on the method. In particular, the combination of compensating and reversing techniques achieved the best performance, improving the baseline accuracy from 83.07% to 94.43%. Note that we also experimented with using class weights inversely proportional to the class frequencies during the computation of the training loss, but found this approach less effective than our augmentation technique. We also tried smoothing the predicted behaviour sequences with a mode filter of different window sizes to stabilize small segments where the predicted behaviour is oscillating between different behaviours. For example, a short (e.g. few micro-seconds) part of a resting segment could be predicted into grazing. The smoothing technique could turn the grazing prediction into a resting prediction, taking into account the fact that neighbouring predictions are resting. This however only slightly improve the prediction capacity. However, more sophisticated techniques could be used for post-processing of the prediction. One example would be to smooth the sequence of behaviours predicted by the LSTM models using transition probabilities between behaviours, as proposed in [25] using the Viterbi algorithm based on Hidden Markov Models. However, this approach results in only limited overall improvement (accuracy: +1%). Another possibility would be to use the output value of the softMax layer (see Fig. 5) from the LSTM network, as probabilities indicating the likelihood of the data belonging to a particular behaviour. Post-processing could then be applied only to predictions with a level of uncertainty above a given threshold, or more generally use the softMax value to apply any post-processing technique. Finally, based on this article and similar studies, classification models might not be well-suited for predicting rare and/or short-lived behaviours, whether using machine learning or deep learning approaches [10]. Indeed, change point detection method as proposed in [2] or unsupervised techniques for detecting anomalies in sensor data, as proposed in Human Activity Recognition [32], could be more adapted. In this respect, a hybrid approach combining (1) Hierarchical LSTM models to predict behaviours with long-term dependencies (e.g., grazing, ruminating, resting) and (2) change point and/or anomaly detection methods to detect rare behaviours within these sequences would be worth investigating.
Prospects for adopting new strategies to tackle gastrointestinal parasitism in goats

Hierarchical LSTM model developed in this study enables to mon-
itor grazing, ruminating, resting, displacement, and other activities in
goats continuously and individually. This will allow us to explore new
avenues for tackling the gastrointestinal parasites challenge. Fine mon-
itoring could reveal different animal feeding strategies, depending on
the grazing scenario (e.g., quantity of forage available, dry/wet sea-
son, etc.). If there is a link between feeding strategies and parasite
load, further research will be needed to explore the underlying factors
(genetics, maternal transmission, etc.) in order to make appropriate par-
asitism management decisions. Furthermore, parasitic infestation also
alters grazing behaviours on pasture. For example, parasitized lambs in-
fested with Teladorsagia circumcincta spend less time grazing and have
shorter grazing bouts [18]. Using our Hierarchical LSTM model to detect
these changes could help identify animals requiring treatment, thereby
reducing the need for widespread prophylactic anthelmintic use.

CRediT authorship contribution statement

Mathieu Bonneau: Writing – original draft, Visualization, Super-
vision, Resources, Project administration, Methodology, Investigation,
Funding acquisition, Formal analysis, Data curation, Conceptualization.
Laura Faillot: Writing – review & editing, Methodology, Formal anal-
ysis, Data curation. Willy Troupe: Supervision, Resources, Conceptual-
ization. Lucile Riaboff: Writing – original draft, Validation, Methodol-
ogy, Conceptualization.

Code and data-sharing

The data are described and shared in a data-paper [12] and the code
are publicly available on Gitlab.

Funding

The first and second authors received financial support from the French National Research Agency, under the project HealtBehavior ANR-22-CE32-0005-01. The accelerometers were founded by the Wait-4 project ANR-22-PEAE-0008. This work benefited from mobility financial support of SFI and the Department of Agriculture, Food and Marine on behalf of the Government of Ireland to the VistaMilk SFI Research Centre under Grant Number 16/RC/3835. The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Declaration of competing interest

The authors declare that they have no known competing financial
interests or personal relationships that could have appeared to influence
the work reported in this paper.

Data availability

Data available on line

References

[1] Andriamasinoro Lalaina Herinaina Andriamandroso, Frédéric Lebeau, Yves Beckers, Eric Froidmont, Isabelle Dufrasne, Bernard Heinesch, Pierre Dumortier, Guillaume Blanchy, Yannick Blaise, Jérôme Bindelle, Development of an open-source algorithm based on inertial measurement units (imu) of a smartphone to detect cattle grass intake and ruminating behaviors, Comput. Electron. Agric. 139 (2017) 126–137.

[2] Reza Arableouei, Liang Wang, Lachlan Currie, Jodan Yates, Flavio A.P. Alvarenga, Greg J. Bishop-Hurley, Animal behavior classification via deep learning on embedded systems, Comput. Electron. Agric. 207 (2023) 107707.

[3] Paolo Balasso, Cristian Taccioli, Lorenzo Serva, Luisa Magrin, Igino Andrighetto, Giorgio Marchesini, Uncovering patterns in dairy cow behaviour: a deep learning approach with tri-axial accelerometer data, Animals 13 (11) (2023) 1886.

[4] Jamie Barwick, David William Lamb, Robin Dobos, Mitchell Welch, Derek Schneider, Mark Trotter, Identifying sheep activity from tri-axial acceleration signals using a moving window classification model, Remote Sens. 12 (4) (2020) 646.

[5] Victor Bloch, Lilli Frondelius, Claudia Arcidiacono, Massimo Mancino, Matti Pastell, Development and analysis of a cnn-and transfer-learning-based classification model for automated dairy cow feeding behavior recognition from accelerometer data, Sensors 23 (5) (2023) 2611.

[6] Jing Chen, Xinyu Huang, Hao Jiang, Xiren Miao, Low-cost and device-free human activity recognition based on hierarchical learning model, Sensors 21 (7) (2021) 2359.

[7] M. Decandia, S.P.G. Rassu, V. Psiroukis, I. Hadjigeorgiou, S. Fountas, G. Molle, M. Acciaro, A. Cabiddu, M. Mameli, C. Dimauro, et al., Evaluation of proper sensor position for classification of sheep behaviour through accelerometers, Small Rumin. Res. 201 (2021) 106445.

[8] Eleanor R. Dickinson, Joshua P. Twining, Rory Wilson, Philip A. Stephens, Jennie Westander, Nikki Marks, David M. Scantlebury, Limitations of using surrogates for behaviour classification of accelerometer data: refining methods using random forest models in caprids, Mov. Ecol. 9 (1) (2021) 28.

[9] Oshana Dissanayake, Sarah McPherson, Joseph Allyndree, Emer Kennedy, Padraig Cunningham, Lucile Riaboff, Personalized weighted adaboost for animal behavior recognition from sensor data, in: 2023 31st Irish Conference on Artificial Intelligence and Cognitive Science (AICS), 2023, pp. 1–8, https://api semanticscholar org/ CorpusID:268541757.

[10] Oshana Dissanayake, Sarah E. McPherson, Joseph Allyndree, Emer Kennedy, Padraig Cunningham, Lucile Riaboff, Evaluating rocket and catch22 features for calf behaviour classification from accelerometer data using machine learning models, preprint, arXiv:2404.18159, 2024.

[11] Bertrand Dumont, Jeroen CJ Groot, Muriel Tichit, Make ruminants green again-how can sustainable intensification and agroecology converge for a better future?, Animal 12 (s2) (2018) s210-s219.

[12] W. Faillot, L. Troupe, M. Bonneau, Cabritrack: accelerometer data for automated behavioural monitoring of grazing creole goats, in: Data in Brief, 2025.

[13] Olivier Friard, Marco Gamba, Boris: a free, versatile open-source event-logging software for video/audio coding and live observations, Methods Ecol. Evol. 7 (11) (2016) 1325–1330.

[14] Felix A. Gers, Jürgen Schmidhuber, Fred Cummins, Learning to forget: continual prediction with lstm, Neural Comput. 12 (10) (2000) 2451–2471.

[15] Alex Graves, Jürgen Schmidhuber, Framewise phoneme classification with bidirectional lstm networks, in: Proceedings. 2005 IEEE International Joint Conference on Neural Networks, 2005, vol. 4, IEEE, 2005, pp. 2047–2052.

[16] Sepp Hochreiter, Jürgen Schmidhuber, Long short-term memory, Neural Comput. 9 (8) (1997) 1735–1780.

[17] Seyedhafaezeh Hosseininoorin, Siamak Layeghy, Brano Kusy, Raja Jurdak, Greg J. Bishop-Hurley, Paul L. Greenwood, Marius Portmann, Deep learning-based cattle behaviour classification using joint time-frequency data representation, Comput. Electron. Agric. 187 (2021) 106241.

[18] M.R. Hutchings, I.J. Gordon, E. Robertson, I. Kyriazakis, F. Jackson, Effects of par-
asitic status and level of feeding motivation on the diet selected by sheep grazing
grass/clover swards, J. Agric. Sci. 135 (1) (2000) 65–75.

[19] Guoming Li, Yanbo Huang, Zhiqian Chen, Gary D. Chesser Jr, Joseph L. Pur-
swell, John Linhoss, Yang Zhao, Practices and applications of convolutional neural
network-based computer vision systems in animal farming: a review, Sensors 21 (4)
(2021) 1492.

[20] Mei Liu, Yiqi Wu, Guangyang Li, Meiqi Liu, Rui Hu, Huawei Zou, Zhisheng Wang, Yingqi Peng, Classification of cow behavior patterns using inertial measurement units and a fully convolutional network model, J. Dairy Sci. 106 (2) (2023) 1351–1359.

[21] Mónica Mora, Lucile Riaboff, Ingrid David, Juan Pablo Sánchez, Miriam Piles, Classifying active and inactive states of growing rabbits from accelerometer data using machine learning algorithms, Smart Agric. Technol. 9 (2024) 100675.

[22] Henry Friday Nweke, Ying Wah Teh, Mohammed Ali Al-Garadi, Uzoma Rita Alo, Deep learning algorithms for human activity recognition using mobile and wearable sensor networks: state of the art and research challenges, Expert Syst. Appl. 105 (2018) 233–261.

[23] P.D. Penning, A technique to record automatically some aspects of grazing and rumina-
ming behaviour in sheep, Grass Forage Sci. 38 (2) (1983) 89–96.

[24] Emily Price, Joss Langford, Tim W. Fawcett, Alastair J. Wilson, Darren P. Croft, Classifying the posture and activity of ewes and lambs using accelerometers and machine learning on a commercial flock, Appl. Anim. Behav. Sci. 251 (2022) 105630.

[25] Lucile Riaboff, Sylvain Poggi, Aurélien Madouasse, Sébastien Couvreur, Sébastien Aubin, Nicolas Bédère, Etienne Goumand, Alain Chauvin, Guy Plantier, Development of a methodological framework for a robust prediction of the main behaviours of dairy cows using a combination of machine learning algorithms on accelerometer data, Comput. Electron. Agric. 169 (2020) 105179.

[26] Lucile Riaboff, Laurence Shalloo, Alan F. Smeaton, Sébastien Couvreur, Aurélien Madouasse, Mark T. Keane, Predicting livestock behaviour using accelerometers: a systematic review of processing techniques for ruminant behaviour prediction from raw accelerometer data, Comput. Electron. Agric. 192 (2022) 106610.
[27] J.F.J. Torres-Acosta, Hervé Hoste, Alternative or improved methods to limit gastro-intestinal parasitism in grazing sheep and goats, Small Rumin. Res. 77 (2-3) (2008) 159-173.

[28] Kirk E. Turner, Andrew Thompson, Ian Harris, Mark Ferguson, Ferdous Sohel, Deep learning based classification of sheep behaviour from accelerometer data with imbalance, Inf. Process. Agric. 10 (3) (2023) 377-390.

[29] Liang Wang, Reza Arablouei, Flavio A.P. Alvarenga, Greg J. Bishop-Hurley, Classifying animal behavior from accelerometry data via recurrent neural networks, Comput. Electron. Agric. 206 (2023) 107647.

[30] Paul J. Werbos, Backpropagation through time: what it does and how to do it, Proc. IEEE 78 (10) (1990) 1550-1560.

[31] Yiqi Wu, Mei Liu, Zhaoyuan Peng, Meiqi Liu, Miao Wang, Yingqi Peng, Recognising cattle behaviour with deep residual bidirectional lstm model using a wearable movement monitoring collar, Agriculture 12 (8) (2022) 1237.

[32] Kai Zhang, Shuqing Han, Jianzhai Wu, Guodong Cheng, Yali Wang, Saisai Wu, Jifang Liu, Early lameness detection in dairy cattle based on wearable gait analysis using semi-supervised lstm-autoencoder, Comput. Electron. Agric. 213 (2023) 108252.