2021

[1]Fréjus A. A. Laleye

[1]Opscidia, Paris, France

2]Université de Parakou, Institut Universitaire de Technologie, Parakou, Bénin

# Attention-Based Recurrent Neural Network For Automatic Behavior Laying Hen
Recognition

<EMAIL_ADDRESS>Mikaël A. Mousse<EMAIL_ADDRESS>*
[

###### Abstract

One of the interests of modern poultry farming is the vocalization of laying
hens which contain very useful information on health behavior. This
information is used as health and well-being indicators that help breeders
better monitor laying hens, which involves early detection of problems for
rapid and more effective intervention. In this work, we focus on the sound
analysis for the recognition of the types of calls of the laying hens in order
to propose a robust system of characterization of their behavior for a better
monitoring. To do this, we first collected and annotated laying hen call
signals, then designed an optimal acoustic characterization based on the
combination of time and frequency domain features. We then used these features
to build the multi-label classification models based on recurrent neural
network to assign a semantic class to the vocalization that characterize the
laying hen behavior. The results show an overall performance with our model
based on the combination of time and frequency domain features that obtained
the highest F1-score (F1=$92.75$) with a gain of $17\%$ on the models using
the frequency domain features and of $8\%$ on the compared approaches from the
litterature.

###### keywords:

Laying hen vocalisation, RNN, Attention mechanism, Time and frequency domain
feature

##  1 Introduction

Animal vocalisations are associated with different animal responses and can be
used as useful indicators of the state of animal welfare. They are information
about animal behavior allowing to determine the needs of the animals,
providing personalized and optimal attention for the benefit of the production
(Banhazi and Black, 2009; Bardeli et al, 2010). There are two types of poultry
farming which coexist: traditional poultry farming and modern poultry farming
which is recent and is gaining more and more importance. Unlike traditional
poultry farming, which is less demanding, the establishment of modern poultry
farming is subject to investment no less negligible and, requires rigorous
conduct. Well conducted, modern poultry farming constitutes a source of
unquestionable fortune for Poultry Farmers. Indeed, with the increase in
demand for poultry products in the market and the presence of other factors
such as consumers demanding more transparency in reporting on the welfare,
environmental impact and safety of poultry products, it is essential to think
on a rationalization in the treatment of animals.

This work was carried out on farms in the cities of the Republic of Benin, a
West African country where the breeding of laying hens is common and practiced
by many families. The poultry farming sector is booming and growing on a large
scale in the country. Commercial poultry farming is dominated by the breeding
of laying hens for production of eggs which then experienced a spectacular
boom in recent years becoming for some families the primary activity and the
only source of income. However, the laying hen breeding is not an easy
activity. With advances in technology, commercial farming has become modern
and can use cameras, microphones, and sensors in proximity to animals to take
the place of farmers’ eyes and ears in monitoring animal health and welfare
effectively (Du et al, 2020).

In the context of poultry farming, laying hens always need more attention for
better productivity in the sense that each of their vocalizations has a
physiological meaning linked to their state of health. In this paper, we
propose a recognition system to recognize and interpret the laying hen
vocalizations, based on the sound calls that we collected ourselves, for
helping the farmers in their breeding. The main contributions of this work are
the following. First, we built an annotated dataset111Location will be public
after review of different laying hen calls. These are the laying hen
vocalizations that were recorded under different environment conditions with
specific sensors. Second, we carried out a study of the acoustic features of
laying hen vocalizations which led us to propose in a significant way the
optimal representations of each vocalization type. Finally, based on the rich
representations of vocalizations, our work has aimed to explore and develop an
optimal recognition multi-label model for classifying the laying hen
behaviours.
The rest of this article is organized as follows. Section 2 presents some
related works. Section 3 introduces and reformulates the task of behavior
laying hen recognition we addressed in this work. Section 4 presents the data
we collected for building our classifiers. Section 5 gives an overview of the
approach we proposed. Experimental setup and result analysis is given in
Section 6.

##  2 Related Works

Usually, farmers rely on their observations and experiences to manage their
animals. In commercial farming it is complicated to monitor the animals and
nowadays we see the use of the sensors (cameras and microphones) to help the
farmer in his management. Several research works have investigated the use of
sensors for the recognition of animal states. Liz et al.Liz et al (2020) and
Garcia et al.García et al (2020) have provided a comprehensive review of
techniques for monitoring the behavior and welfare of broilers and laying
hens. Du et al.Du et al (2020) proposed a hen vocalisation detection method
based on machine learning to assess their thermal comfort condition. They used
temporal and spectral features and developed a support vector machine (SVM)
based classifier to estimate thermal confort of the chicks. Pluk et al.Pluk et
al (2010) also used sound analysis to model the water intake of the broilers
as response to the light input. The results of their experimentations have
shown a high potential of using water intake for the monitoring of broiler
production over a complete growing period. Chelotti et al. Chelotti et al
(2016) proposed a method for an automated detection and classification of bite
and chew activity has been used as means of feed intake estimation in cattle.
Other research works use sound analysis to interepret the behaviour of pigs.
Thus, it has been demonstrated that respiratory diseases detected in pigs have
an influence on their cough (Ferrari et al, 2008; Van Hirtum and Berckmans,
2004). Vandermeulen et al. Vandermeulen et al (2016) proposed a method for the
early recognition of bovine respiratory diseases in calves through automated
continuous monitoring of cough sounds.

To analyze the vocalization sounds, several research works have based their
approach on the widely Mel-Frequency Cepstral coefficient features that have
competitive results in the litterature (Lee et al, 2006; Sharan and Moir,
2017; Pattanayak and Pradhan, 2021).

After the feature extraction, it is necessary to have a classification system
capable of recognizing the state of the animal. To this end, several machine
learning approaches have been proposed such as Support Vector Data
Descriptions (SVDD) (Chung et al, 2013a, b), Support Vector Machines (SVM)
(Bishop et al, 2017; Banakar et al, 2016; Lee et al, 2015), AdaBoost.M1 (Lee
et al, 2014), Deep Neural Networks (DNN)-pattern-recognition algorithms
(Cowton et al, 2018; Doulgerakis et al, 2019; Fonseca et al, 2019) and
Convolutional Neural Networks (CNN) (Mao et al, 2022). In (Cowton et al,
2018), the authors used the Recurrent Neural Networks (RNN) to describe and
evaluate a methodology for the early warning of anomalies pertaining to
respiratory disease in growing pigs, based on environmental factors.

In this paper, we propose a deep learning approach also based on RNN but
unlike the work proposed in Cowton et al (2018), we introduced in our model
the attention mechanism to recognize the behavior of laying hens. To do this,
we based our approach on the acoustic analysis of vocalizations that identify
behaviors. One of the challenges of our approach is the recognition of
semantically close vocalizations that may share acoustic features. In Lee et
al (2015), the authors tackled the challenge of laying hen vocalization
detection. Their approach involved a hierarchical combination of three binary
SVM classifiers, which were used to classify stress into two distinct semantic
classes: physical stress and mental stress. In (Mao et al, 2022), the authors
have presented compelling evidence that deep Convolutional Neural Network
(CNN) models are highly effective in identifying distress vocalizations.
Specifically, they fine-tuned a pre-trained CNN model using their dataset of
chicken vocalizations, resulting in a notable boost in performance for
identifying distress vocalizations. Despite yielding impressive accuracy
scores and irrespective of the deep learning models utilized, these two
approaches are not directly applicable to our work. We addressed a task that
involves a more diverse range of vocalizations from laying hens, which may
exhibit considerable variability and overlap. While these approaches have
shown promise in previous studies, our work presents unique challenges that
require a more tailored approach.

##  3 Task Formalization

In this work, we considered the problem of the automatic recognition of laying
hen calls as a problem of identification and classification of sounds
correlated with the environment in which the sounds are emitted. The aim is to
assign a semantic state to the input audio stream that characterizes the
condition in which the laying hen is – for example food calls, distress and
egg laying. The task therefore consists in extracting a characteristic
representation of the signals by assigning one or more semantic labels that
indicates the state of the laying hens. Every vocalization can be assigned to
multiple semantic labels, making this a multilabel classification problem. For
example, a cold hen may utter a continuous vocalization because it is unhappy
and in distress or in panic. Distress, fear and panic being distinct states
which can arise from the same vocalization. This demonstrates the difficulty
of the task addressed in this work in the sense that the objective is to
categorize vocalizations that are acoustically very close for humans but which
identify very distinct states for hens.

##  4 Data collection

Taking into account the diversity of breeds of hens and the context of
breeding which strongly depends on the production environment, a major
contribution of our work has been to build a database of vocalizations
associated with certain behaviors of laying hens that we make available for
future research in the field. We made recordings of hens from 10 different
farms with beninese poultry farmers. As they all come from modern commercial
poultry farming, the laying hens from the target farms are under very specific
veterinary treatment: deworming, anti-stress, regular vaccination. However, it
happens that some hens in the group are exposed to physical disorders.

For our work, only physically active laying hens were selected. Sound data
were acquired continuously in Waveform Audio File Format (1 channel, 32-bit
resolution, 16,000 Hz, recording at approximately 55s of each file). The
recordings were made by using cameras positioned in the center about 2m from
the hens and by considering the following vocalizations that are described in
Table 1: Alarm \- Food calls \- Gakel \- Egg laying \- Fear \- Distress \-
Panic \- Lonely calls. The recordings were then annotated by 4 poultry farmers
who assigned labels to the different vocalizations. A total of 205 laying hens
were recorded on all 8 vocalizations. Cross recordings were made so that
several vocalizations are obtained with the same hen. During this experiment,
135 hours of data were recorded. The third column in Table 1 presents the
number of signals obtained with the 8 vocalizations. The signal distribution
in Table 1 indicates that the labelled dataset contains imbalanced sample
sizes.

Table 1: Description of the hen calls studied in this work. Vocalization type |  Description |  Number of signals
---|---|---
Alarm |  A normal sound of long duration (< 6s) with interruptions of less than (< 0.5s) often emitted by the hen to keep everyone safe and aware of danger. |  955
Food calls |  These are repetitive clucks emitted for either calls to feed or when the hens are hungry. the sounds are emitted in short sequences (<4s) for a long duration as long as food is not available to them |  1000
Gakel calls |  These are sounds of variable frequencies emitted to indicate frustration with their environment. |  905
Egg laying |  The hens emit theses sounds (the signals of short sequences) when they are laying an egg or waiting to get into their favorite nest box. |  865
Fear |  These are sounds (high-pitched, repetitive, and fast-paced) that the hens make to express a fear behavior (running away from stressors, alerting of potential predators) |  1460
Distress |  These are sounds (very higher in pitch and repetitive) that indicate the hens are hungry (very similar to acoustic signals of the food calls) or annoyed by an unusual situation |  975
Panic |  Similar to a distress sound, this vocalization is also high-pitched and loud but more persistent with a long duration. |  975
Lonely calls |  The hens emit this call when they are alone and no company in their immediate environment. The signals are high-pitched and of very short duration ( 2s) |  840

##  5 Our Multi-Label classification approach

We developed our study in two stages: an acoustic analysis of each
vocalization sounds and the classification of the sound features based on
recurrent neural network models and attention mechanism.

###  5.1 Acoustic features

The acoustic analysis led to obtain the graphic representation of sound
parameters from the popular features widely used in the literature. The
following features were derived from the time and frequency domain. The time
domain features are calculated around the syllables identified in a sound of
the hen whereas the frequency domain features are directly from the raw
signal. These features are calculated by considering the syllable as acoustic
unit. A syllable is represented by a vocal activity. These sounds
(vocalizations) containing the syllables are interwoven between the parts of
the silence and signal segments, which are not useful such as noise and non-
vocal sound activities. The syllable therefore has a variable size in a
vocalization and depends on the presence or not of the silence markers in the
signal. To extract the vocal syllables from the raw signal, we used the vocal
activity detection algorithm proposed in (Mahdavian et al, 2020).

The obtained syllables are used to feed into the classification model. The
time domain features considered in our work are: tempo ( number of syllables
per second), energy, intensity, power and pitch.

The frequency domain features that we were considered are: formants (F1 to F4)
and spectral energy characterized by the decomposition of the raw temporal
signal into its constituent frequencies.

The formants and the spectral energy are augmented by the cepstral
coefficients widely used in acoustic speech processing in order to capture
more features and obtain a more robust representation of the hen
vocalizations. These are the Mel Frequency Cepstral Coefficients (MFCC) and
Linear Frequency Cepstral Coefficients (LFCC). They were calculated
individually then merge afterwards into the same vector to gather information
across the whole spectrum. The MFCC is based on a nonlinear cepstral
representation of the signal equally spaced on the Mel scale. This scale
approximates the response of the human auditory system more closely than
linear-spaced frequencies (Mahdavian et al, 2020; Du et al, 2021). These
cepstral coefficients are obtained by transforming from Hertz to Mel scale
that is calculated as follows:

$mel=2595log_{10}(\frac{f}{100}+1)$ (1)

The LFCC coefficients are the result of taking the Discrete Fourier Transform
(DFT) of the logarithm of the estimated spectrum of a signal (Noda et al,
2019). These coefficients have been calculated using a linear filter bank,
which has better resolution in higher frequency regions. AS described in (Noda
et al, 2019), we based the calculation of the LFCC coefficients on a log
energy filter bank applied to the discrete cosine transform as shown in 2,
where $j$ denotes the index of the LFCC giving the number of coefficients to
compute, $X_{i}$ is the log-energy output from the ith filter and $B$, the
number of triangular filters.

$L_{j}=\sum_{i=1}^{B}=X_{i}cos(j(i-\frac{1}{2})\pi/B)$ (2)

$40$ triangular filters are extracted as features for both MFCC and LFCC and
$20ms$ a frame size. To extract more significant information from the
vocalization signals, we merged the MFCC and LFCC coefficients to obtain a
robust representation to feed the classification model. The merge consisted of
creating a matrix by horizontally concatenating the LFCC and MFCC features.
The features merged have been compared with each taken individually for
comparison purposes.

###  5.2 Archiecture of classification system.

We have implemented a classification approach based on recurrent neural
networks (RNN) with attention mechanism that we have compared with standard
and Bayesian-type approaches. Our proposed system is composed of three modules
(Figure 1): input preprocessing, feature embedding, and the classifier. he
input preprocessing step extracts temporal and frequency features from the
vocalization sounds. The feature embedding module prepares the inputs for the
model. The classifier module is composed of a trainable features layer, a
stacked single head attention recurrent neural network, a Boom layer, and a
softmax classifier.

Figure 1: Architecture of the hen vocalization multi-label classification
system.

Our proposed model differs from transformer-based approaches Vaswani et al
(2017) in that we use a single attention head. This decision was inspired by
Merity (2019) and has resulted in improved performance in terms of the amount
of useful information extracted. We chose not to complicate the model by
adding multiple attention heads, as we were unsure of their benefits for the
less complex signals that we worked with. The attention mechanism is very
computationally efficient since the only matrix multiplication performed
during the process acts on the query Merity (2019).

The boom layer, in our work, has been very useful in that it allows to control
the explosion of the dimension of the vectors output from the attention
layers: the vectors are projected to a higher dimension and projected back to
original dimension.

Our model is loaded with large feed-forward layer steps at several points to
encode the features from vocalization sounds across each feature dimension to
produce dynamically vectors in hidden states.

The produced vectors are used by attention layers to weight the syllables
contained in the vocalizations deferentially when aggregating them into a
global representations. The attention mechanism led each syllable to
contribute to the final vector used to map a vocalization to a semantic label.
The Boom layer takes the final vector and uses the matrix multiplication
obtained with the attention weights to produce the final vector to Dense and
Softmax layers that output the predicted label. It is made up of connected
layers that at first blowing the input vector up to dimension 512 and then
projecting it back down to dimension 8 the number of calls to predict.

###  5.3 Objective

Since it’s basically impossible to have perfect predictions on close semantic
labels (classes to predict) that share the acoustic similarities, we
hypothesize that grouping in a semantic class, signals that are potentially
semantically close would reduce the prediction errors of the model on certain
labels. We have therefore created 4 master classes containing the primary
labels. Table 2 presents the master classes and the semantic labels they
contain. Given this previously mentioned difficulty, we used as an objective
function a customized Binary Cross Entropy (cBCE) loss (Jadon, 2020) that we
nested on each of the master classes. To do that, we firstly considered, in
loss calculation, 4 times the logits of each master class which are masked and
projected down onto the subclasses contained in each master class. This
consisted of taking the top 2 logists from each master class, mixing them to
compute the cBCE which is actually the weighted binary cross-entropy loss.
Then and based on Equation 3, two losses are calculated: one on the logits of
the subclasses and the other on the logits of the master classes. In Equation
3, $\alpha$ is used to tune the false negative and the false positive
predictions and $\hat{y}$ is the predicted value by the prediction model.
Finally, we take a weighted sum of the two losses for indicating to model
which priority it should give to master class loss over the subclass loss.

Table 2: Master classes. Master class | Label
---|---
Food calls | Food calls - Distress - Panic
Egg laying | Egg laying
Fear | Fear - Alarm - Gakel calls
Lonely calls | Lonely calls

$L(y,\hat{y})=-(\alpha*ylog(\hat{y})+(1-y)log(1-\hat{y}))$ (3)

##  6 Results and discussion

we have set up and conducted different experimental protocols based on
combinations of the different features in order to produce a more accurate
model for the recognition of vocalizations. For each experimental setup, we
used as input data the combination of features built and evaluated the
contribution of the acoustic information provided by each of them.

###  6.1 Experiment setup

Different configurations have been implemented to test the efficiency and
accuracy of the approach we propose. First, we compared our approach
implemented on different feature combination configurations to the techniques
commonly used in the state of the art for animal behavior recognition task
such as: Decision Tree (DT) Chelotti et al (2018), Support Vector Machine
Bishop et al (2017); Lee et al (2015), Random Forest (RF) Noda et al (2019)
and Gaussian Mixture Model (Du et al, 2021). In order to consolidate our
hypothesis of using a single model for all studied vocalizations and not
training multiple models per vocalization, we compared our model’s multi-label
approach, with nested loss calculation, to a cascading binary classification
approach followed by a majority vote. This evaluation served to determine
which approach was most effective in achieving our desired outcome.

We used all of the $\sim 8000$ samples for model evaluation with several
splits to build the training, validation and testing sets. First, we set aside
$\sim 20\%$ of the data to obtain the testing set, ensuring that all labels
are represented at almost equal rates so as not to penalize the models in
their evaluation. We used $10$-fold cross-validation for training and
validation with a ratio $90/10$ for splitting the dataset. The models were
trained on different training data obtained from the random generation at
different places. With validation set, we obtained the best-performing
parameters (Table 3) that are used for the evaluation of our model.

Table 3: Hyperparameter values Hidden size |  Boom dim |  Batch size |  cBCE ratio |  Dropout |  learning rate |  Optimizer
---|---|---|---|---|---|---
1024 |  512 |  16 |  0.1 |  0.2 |  0.001 |  Adamdelta

Experiments on binary classifiers are done by training a model by
vocalization, which yields 8 different models for the same input data
configuration. On all 8 models, we applied a decision-making strategy based on
both the majority voting of the models and a weighted linear interpolation of
the classification model results. This made it possible to obtain the better
performances of each of the models. The label predicted by a binary classifier
is the one that obtained the most votes from the 8 models. The final label is
given by the binary classifier having predicted a label with the highest
probability.

Since we are in a multilabel setup, we used as evaluation metric the sample-
average $F1$ score by computing the score of the predictions of the sample and
averaging that over all the samples. Also, F1 was chosen for this work because
of the imbalance of call classes present in our training dataset.

###  6.2 Using time domain features

Our first experiments are made using the features calculated only in the time
domain. The input vector used to train the different models is formed from the
concatenation of Tempo, Energy, Intensity, Power and Pitch. Table 4 and Table
5 present respectively the results of multi-output models and binary models on
testing set. Table 4 shows that the GMM model achieved the highest F1-score of
$33.15$, followed by the SVM model with $32.95$, indicating that they are
better suited for time domain features. However, our RNN-based model achieved
a significantly lower F1-score of $22.85$, suggesting that time domain
features may not provide sufficient information for capturing the acoustic
representations of vocalizations. The same observation can be made in Table 5
that shows the results of binary classifiers on the test data for different
types of vocalizations. Based on the performance provided by time domain
features, the SVM model performed the best using time domain features,
achieving a high accuracy in predicting panic and fear vocalizations. The GMM
model performed the best overall, achieving the highest accuracy in predicting
egg laying, panic, fear and alarm calls.

On average, when using majority voting, the SVM and GMM models demonstrate
superior performance in classifying all vocalizations compared to the other
models. Our model performs relatively poorly on both types of classification,
with an average increase of $10$ points in binary classification compared to
multi-output classification.

Table 4: Evaluation of multi-label models using time domain features on Test data  Model | F1-score
---|---
Decision Tree | 25.12
Support Vector Machine | 32.95
Random Forest | 22.65
GMM | 33.15
Our model | 22.85
Table 5: Evaluation of binary classifiers on test data. Model | Food calls | Egg Laying | Fear | Lonely calls | Majority voting
---|---|---|---|---|---
Food calls | Distress | Panic | Egg Laying | Fear | Alarm | Gakel calls | Lonely calls
Using time domain features
Decision Tree | 41.85 | 42.33 | 37.55 | 35.10 | 46,75 | 40.60 | 40.15 | 39.87 | 45.20
SVM | 43.15 | 44.13 | 49.65 | 46.10 | 46.70 | 42.45 | 41.75 | 39.88 | 47.12
Random Forest | 39.5 | 39.63 | 35.65 | 33.80 | 30.69 | 38.60 | 37.75 | 29.87 | 30.80
GMM | 45.01 | 46.01 | 49.88 | 51.15 | 49.75 | 48.88 | 43.12 | 41.15 | 47.75
Our model | 33.15 | 35.33 | 32.10 | 28.95 | 34,35 | 30.80 | 30.75 | 29.47 | 31.95
Using frequency domain features
Decision Tree | 51.35 | 61.45 | 47.65 | 45.10 | 56.45 | 52.20 | 50.75 | 41.87 | 50.20
SVM | 63.25 | 65.33 | 69.65 | 56.10 | 51.75 | 52.82 | 50.65 | 50.88 | 57.65
Random Forest | 59.55 | 59.63 | 55.65 | 54.85 | 57.09 | 53.40 | 54.75 | 49.67 | 54.88
GMM | 66.15 | 66.22 | 66.95 | 55.84 | 56.85 | 53.05 | 55.55 | 51.15 | 56.55
Our model | 73.05 | 65.33 | 69.95 | 60.75 | 54,75 | 58.88 | 57.45 | 57.47 | 60.05
Using Time-Frequency domain features
Decision Tree | 60.75 | 65.55 | 60.65 | 55.40 | 62.45 | 62.20 | 60.74 | 54.77 | 57.22
SVM | 68.75 | 72.30 | 76.25 | 66.40 | 56.25 | 58.52 | 55.75 | 59.78 | 62.25
Random Forest | 62.55 | 63.63 | 65.35 | 58.15 | 63.29 | 65.40 | 59.75 | 55.07 | 58.35
GMM | 70.25 | 70.15 | 77.85 | 66.45 | 64.25 | 59.75 | 60.15 | 58.58 | 65.12
Our model | 78.05 | 75.35 | 81.95 | 70.15 | 62.77 | 63.88 | 60.55 | 60.47 | 75.65

###  6.3 Using frequency domain features

Four combined features were considered in these experiments for training and
testing the different models such as Formants+Spectral energy, MFCCs, LFCCs,
MFCCs+LFCCs. These types of combination can be computationally intensive yet
provide valuable information on formants and spectral energy, hence motivating
their incorporation into feature combinations. Our choice to combine features
is influenced by the latest advances in research especially by the work in (Du
et al, 2021), where the authors demonstrated the effectiveness of combining
tristimulus values with formants to classify the different call types of
laying hens. Table 6 shows the evaluation evaluation of multi-label models
using frequency domain features on the test data. The MFCCs+LFCCs feature set
achieved the highest F1-score for all models, with our model achieving the
highest score of $79.85$, which is significantly higher than the other models.
This suggests that the combination of MFCCs and LFCCs provides the best
acoustic representation of vocalizations for our RNN-based model to accurately
classify different types of vocalizations.

Additionally, it is noteworthy that using only Formants+Spectral energy, the
models achieve twice the accuracy of the time feature models. These
observations are consistent with those in Table 5, where our model using
majority voting achieved significant performance with an F1-score of $60.05$
in binary classification, which approaches acceptable accuracies for a
vocalization recognition system of laying hens.

Table 6: Evaluation of multi-label models using frequency domain features on Test data  Features |  Decision Tree | SVM |  Random Forest |  GMM |  Our model
---|---|---|---|---|---
Formants+Spectral energy |  45.79 | 57.85 |  50.75 |  57.95 |  59.95
MFCCs |  52.05 | 60.15 |  53.65 |  62.62 |  72.63
LFCCs |  52 | 59.15 |  53.66 |  61.55 |  72.61
MFCCs+LFCCs |  54.15 | 66.67 |  55.67 |  68.45 |  79.85

###  6.4 Using Time-frequency domain features

In this experiment, we used three inputs to feed the models in parallel. Time
features, Formants+Spectral energy and MFCCs+LFCCs are used separately with
different acoustic representations that feed the LSTM cells that propagate
information so that it is shared efficiently across layers of neurons (see
Figure 1). Table 7 shows the results of this experiment. It can be observed
that the GMM and our model outperform the other models with F1-scores of
$89.55$ and $92.75$, respectively. The SVM model also achieves a high F1-score
of 84.65. In table 5, using time-domain features, our model again shows the
highest F1-score for all categories, with an outstanding F1-score of $81.95$
for the "Panic" category. This suggests that the frequency information
augmented by the time domain features enriched the models and made them more
accurate. In Figure 2, we can observed that our model was the most accurate
with $F1=92.75$ compared to other models ( GMM=$89.55$, SVM=$84.65$,
DT=$77.15$ and Random Forest=$68.65$ ) which, with this feature enrichment
strategy, outperformed their performance obtained with MFCCs+LFCCs as inputs.

In order to contextualize our approach, which relies on RNNs and feature
combination strategies, we conducted a comparative analysis between our model
and the GMM model explored in (Du et al, 2021) under similar settings. To
adapt to our own dataset, which differs from that used by the authors, we
implemented their feature calculation and extraction strategies. To ensure
consistency and a fair basis for comparison, we chose accuracy as the metric
for evaluating the models, rather than relying on the results reported by the
authors.

The accuracies obtained are listed in Table 8, indicating that our model
outperforms the GMM from (Du et al, 2021) for all feature combinations. The
authors observed a significant improvement in performance by introducing
Tristimulus-formant as a new feature and combining it with MFCCs. We were able
to replicate this result on our own dataset using Tristimulus-formant.
However, our proposed model and the combination MFCCs+LFCCs achieved even
higher performance compared to the feature combinations they proposed.

To delve deeper, we crafted the confusion matrices by evaluating our model
(see Table 9) and GMM (see Table 10) on the validation set, taking into
account their performance on other implemented models. Our objective is to
compare these two matrices to detect disparities in precision and recall for
each class. To do so, we utilized the master classes of the vocalizations of
laying hens. From the precision and recall values shown in Table 9, we can
infer that our model outperforms GMM in Table 10, with higher precision and
recall values for all classes. This suggests that, progressing hierarchically
in the master classes, our model is better equipped to accurately identify
laying hen calls than the GMM.

Table 7: Evaluation of multi-label models using the three inputs data. Model | F1-score
---|---
Decision Tree | 77.15
Support Vector Machine | 84.65
Random Forest | 68.65
GMM | 89.55
Our model | 92.75

$20$$30$$40$$50$$0.9$$0.92$$0.94$$0.96$$0.98$epochModel accuracy
(training)Decision treeSVMRandom ForestGMMOur
model$20$$30$$40$$50$$0.88$$0.9$$0.92$$0.94$$0.96$$0.98$epochModel F1-score
(testing)Decision treeSVMRandom ForestGMMOur model

$20$$30$$40$$50$$0.7$$0.8$$0.9$epochaccuracyModel accuracy (training)Decision
treeSVMRandom ForestGMMOur
model$20$$30$$40$$50$$0.5$$0.6$$0.7$$0.8$$0.9$epochF1 scoreModel F1-score
(testing)Decision treeSVMRandom ForestGMMOur model

Figure 2: Accuracies and F1 scores of models Table 8: Accuracy rate of our RNN-based model and the GMM calculated using the different combinations explored in (Du et al, 2021). TF meaning "tristimulus-forming", is the novel feature introduced by the authors to train their model of recognition of the laying hen calls. Model | MFCCs | Formants+TF | MFCCs+TF | MFCCs+LFCCs
---|---|---|---|---
GMM (Du et al, 2021) | 90.79 | 68.55 | 70.12 | 92.80
Our model | 93.45 | 60.15 | 82.50 | 96.25
Table 9: Confusion matrix from our model evaluation on a validation set using the three input data. |  Food calls | Egg laying |  Fear |  Lonely calls
---|---|---|---|---
Food calls |  490 | 0 |  20 |  0
Egg laying |  0 | 177 |  0 |  0
Fear |  70 | 30 |  570 |  20
Lonely calls |  10 | 0 |  40 |  216
Precision (%) |  86 | 86 |  90 |  92
Recall (%) |  96 | 1 |  83 |  81
Table 10: Confusion matrix from GMM evaluation on a validation set using the three input data. |  Food calls | Egg laying |  Fear |  Lonely calls
---|---|---|---|---
Food calls |  390 | 77 |  70 |  0
Egg laying |  10 | 100 |  0 |  0
Fear |  100 | 30 |  470 |  46
Lonely calls |  70 | 0 |  90 |  200
Precision (%) |  68 | 48 |  75 |  81
Recall (%) |  73 | 91 |  76 |  56

###  6.5 Discussion

As shown in Figure 2 and in Tables 7, 9, and 10, our proposed approach allowed
to train the best and optimal model for recognizing laying hen calls which
share the semantic similarities. Although the combination of MFCCs and LFCCs
allowed to obtain better scores ($F1=79.85$), their enrichment by the time
domain parameters and the formants using different input channels was the best
strategy of our approach of behavior recognition of laying hens. It achieves a
significant gain of $13\%$ using our model and an average of $18\%$ for other
models. The disadvantage of our approach is that it is very computationally
expensive during training and inference. Indeed, our model takes longer to
train and predict while the methods used in most state-of-the-art works (Du et
al, 2021; Noda et al, 2019) and used in this work for comparison purposes take
less time to train with no less negligible performance ($F1=89.55$ for GMM and
$F1=84.65$). Our model is, individually, more accurate on the Food call
classes ($F1=81.95$ for Panic and $F1=78.05$ for Food calls) and less accurate
on Lonely ($F1=60.47$) and Gakel ($F1=60.55$) calls. On the other hand, on the
master classes, our model produces a global performance on our data compared
to the approaches proposed in the state of the art. It is worth noting that it
is fair to compare the results of our approach to state-of-the-art methods
proposed (Du et al, 2021; Noda et al, 2019) on datasets they used for reasons
of accessibility and also, we have not studied the same types of laying hen
calls whose characteristics may vary according to breed, environment and diet.

Our proposed approach in this work achieved the best results for recognizing
laying hen calls that share semantic similarities, as illustrated in Figure 2
and in Tables 7, 9, and 10. By enriching the MFCCs and LFCCs with time domain
parameters and formants from different input channels, our approach obtained
an F1 score of $79.85$, which is $13\%$ better than the other models and
$18\%$ better on average. However, this improvement comes at the cost of
increased computational complexity during training and inference. While our
model is more accurate on Food call classes (with F1 scores of $81.95$ and
$78.05$ for Panic and Food calls, respectively), it is less accurate on Lonely
(F1 score of $60.47$) and Gakel (F1 score of $60.55$) calls. Nevertheless, our
model outperforms state-of-the-art approaches (Du et al, 2021; Noda et al,
2019) on master classes using our data. It should be noted that comparing our
results to those of state-of-the-art methods on their respective datasets may
prove challenging due to accessibility issues. Additionally, our study focused
on a specific type of laying hen call, which may vary in characteristics based
on factors such as breed, environment, and diet. Therefore, caution should be
taken when generalizing our findings to other datasets and types of laying hen
calls.

##  7 Conclusion

In this paper, we proposed a recognition system that makes it possible to
detect and recognize earlier states related to laying hen behaviour using
their vocalization sounds. We described a multi-label classification approach
based on intelligent combination of time and frequency domain features. Our
strategy has been to leverage from the acoustic information generated by MFCCs
and LFCCs features augmented by formants and spectral energy to build the rich
and robust acoustic representations. These representations allowed us to feed
our multi-label classification model which combines recurrent neural networks
and the attention mechanism. With MFCCs+LFCCs augmented by the formants and
time domain features, our system significantly improves its performance and
obtained the overall performance. The final system is more efficient on food
calls and more precisely on panic call despite having fewer signals than the
Food and fear calls. This can demonstrate that the impact of data imbalance in
modeling of a rich and robust representation of laying hen calls is relatively
low in our study context. That finding remains to be proven in cases where
each call would have the same number of signals and with more data to collect.
This is a limitation of our experiments. We are currently preparing equipment
and sensors to collect more audio data and add images from videos to build a
multimodal monitoring system for laying hens in Beninese poultry farms.

##  8 Availability of data and material

The data that support the findings of this study are available from the
corresponding author in the controlled access repository222Location:
https://github.com/laleye/ScreamAnalysis. Requests for material should also be
addressed to the corresponding authors.

##  9 Conflicts of interest

All authors certify that they have no affiliations with or involvement in any
organization or entity with any financial interest or non-financial interest
in the subject matter or materials discussed in this manuscript.

## References

  *   * Banakar et al (2016) Banakar A, Sadeghi M, Shushtari A (2016) An intelligent device for diagnosing avian diseases: Newcastle, infectious bronchitis, avian influenza. Computers and Electronics in Agriculture 127:744–753. https://doi.org/10.1016/j.compag.2016.08.006, URL https://www.sciencedirect.com/science/article/pii/S0168169916306020
  * Banhazi and Black (2009) Banhazi T, Black J (2009) Precision livestock farming: A suite of electronic systems to ensure the application of best practice management on livestock farms. Australian Journal of Multi-Disciplinary Engineering 7(1):1–14. 10.1080/14488388.2009.11464794, URL https://doi.org/10.1080/14488388.2009.11464794, https://arxiv.org/abs/https://doi.org/10.1080/14488388.2009.11464794
  * Bardeli et al (2010) Bardeli R, Wolff D, Kurth F, et al (2010) Detecting bird sounds in a complex acoustic environment and application to bioacoustic monitoring. Pattern Recognition Letters 31(12):1524–1534. https://doi.org/10.1016/j.patrec.2009.09.014, URL https://www.sciencedirect.com/science/article/pii/S0167865509002487, pattern Recognition of Non-Speech Audio
  * Bishop et al (2017) Bishop J, Falzon G, Trotter M, et al (2017) Sound analysis and detection, and the potential for precision livestock farming-a sheep vocalization case study. In: Proceedings of the 1st Asian-Australasian Conference on Precision Pastures and Livestock Farming, Hamilton-New Zealand, pp 1–7
  * Chelotti et al (2016) Chelotti JO, Vanrell SR, Milone DH, et al (2016) A real-time algorithm for acoustic monitoring of ingestive behavior of grazing cattle. Computers and Electronics in Agriculture 127:64–75. https://doi.org/10.1016/j.compag.2016.05.015, URL https://www.sciencedirect.com/science/article/pii/S0168169916303076
  * Chelotti et al (2018) Chelotti JO, Vanrell SR, Galli JR, et al (2018) A pattern recognition approach for detecting and classifying jaw movements in grazing cattle. Computers and Electronics in Agriculture 145:83–91. https://doi.org/10.1016/j.compag.2017.12.013, URL https://www.sciencedirect.com/science/article/pii/S0168169917302752
  * Chung et al (2013a) Chung Y, Lee J, Oh S, et al (2013a) Automatic detection of cow’s oestrus in audio surveillance system. Asian-Australasian journal of animal sciences 26(7):1030
  * Chung et al (2013b) Chung Y, Oh S, Lee J, et al (2013b) Automatic detection and recognition of pig wasting diseases using sound data in audio surveillance systems. Sensors 13(10):12,929–12,942
  * Cowton et al (2018) Cowton J, Kyriazakis I, Plötz T, et al (2018) A combined deep learning gru-autoencoder for the early detection of respiratory disease in pigs using multiple environmental sensors. Sensors 18(8):2521. 10.3390/s18082521, URL https://doi.org/10.3390/s18082521
  * Doulgerakis et al (2019) Doulgerakis V, Giannousis C, Kalyvas D, et al (2019) An animal welfare platform for extensive livestock production systems. In: AmI
  * Du et al (2020) Du X, Carpentier L, Teng G, et al (2020) Assessment of laying hens’ thermal comfort using sound technology. Sensors 20:473. https://doi.org/10.3390/s20020473, URL https://www.mdpi.com/1424-8220/20/2/473
  * Du et al (2021) Du X, Teng G, Wang C, et al (2021) A tristimulus-formant model for automatic recognition of call types of laying hens. Computers and Electronics in Agriculture 187:106,221. https://doi.org/10.1016/j.compag.2021.106221, URL https://www.sciencedirect.com/science/article/pii/S0168169921002386
  * Ferrari et al (2008) Ferrari S, Silva M, Guarino M, et al (2008) Analysis of cough sounds for diagnosis of respiratory infections in intensive pig farming. Transactions of the ASABE 51:1051–1055. 10.13031/2013.24524, URL https://elibrary.asabe.org/abstract.asp?aid=24524
  * Fonseca et al (2019) Fonseca FF, Mamatas L, Viana AC, et al (2019) Personalized travel itineraries with multi-access edge computing touristic services. In: 2019 IEEE Global Communications Conference (GLOBECOM), pp 1–6, 10.1109/GLOBECOM38437.2019.9013548
  * García et al (2020) García R, Aguilar J, Toro M, et al (2020) A systematic literature review on the use of machine learning in precision livestock farming. Computers and Electronics in Agriculture 179:105,826. https://doi.org/10.1016/j.compag.2020.105826, URL https://www.sciencedirect.com/science/article/pii/S0168169920317099
  * Jadon (2020) Jadon S (2020) A survey of loss functions for semantic segmentation. 2020 IEEE Conference on Computational Intelligence in Bioinformatics and Computational Biology (CIBCB) pp 1–7
  * Lee et al (2006) Lee CH, Chou CH, Han CC, et al (2006) Automatic recognition of animal vocalizations using averaged mfcc and linear discriminant analysis. Pattern Recognition Letters 27(2):93–101. https://doi.org/10.1016/j.patrec.2005.07.004, URL https://www.sciencedirect.com/science/article/pii/S0167865505001959
  * Lee et al (2014) Lee J, Zuo S, Chung Y, et al (2014) Formant-based acoustic features for cow’s estrus detection in audio surveillance system. In: 2014 11th IEEE International Conference on Advanced Video and Signal Based Surveillance (AVSS), IEEE, pp 236–240
  * Lee et al (2015) Lee J, Noh B, Jang S, et al (2015) Stress detection and classification of laying hens by sound analysis. Asian-Australasian Journal of Animal Sciences 28:592 – 598
  * Liz et al (2020) Liz N, Ren Z, Li D, et al (2020) Review: Automated techniques for monitoring the behaviour and welfare of broilers and laying hens: towards the goal of precision livestock farming. Animal 14:617–625. 10.1017/S1751731119002155, URL https://www.sciencedirect.com/science/article/pii/S1751731119002155
  * Mahdavian et al (2020) Mahdavian A, Minaei S, Yang C, et al (2020) Ability evaluation of a voice activity detection algorithm in bioacoustics: A case study on poultry calls. Computers and Electronics in Agriculture 168:105,100. https://doi.org/10.1016/j.compag.2019.105100, URL https://www.sciencedirect.com/science/article/pii/S0168169918305982
  * Mao et al (2022) Mao A, Giraudet CSE, Liu K, et al (2022) Automated identification of chicken distress vocalizations using deep learning models. Journal of The Royal Society Interface 19(191):20210,921. 10.1098/rsif.2021.0921, URL https://royalsocietypublishing.org/doi/abs/10.1098/rsif.2021.0921, https://arxiv.org/abs/https://royalsocietypublishing.org/doi/pdf/10.1098/rsif.2021.0921
  * Merity (2019) Merity S (2019) Single headed attention RNN: stop thinking with your head. CoRR abs/1911.11423. URL http://arxiv.org/abs/1911.11423, https://arxiv.org/abs/1911.11423
  * Noda et al (2019) Noda JJ, Travieso-González CM, Sánchez-Rodríguez D, et al (2019) Acoustic classification of singing insects based on mfcc/lfcc fusion. Applied Sciences 9(19). 10.3390/app9194097
  * Pattanayak and Pradhan (2021) Pattanayak B, Pradhan G (2021) Pitch-robust acoustic feature using single frequency filtering for children’s kws. Pattern Recognit Lett 150:183–188
  * Pluk et al (2010) Pluk A, Cangar O, Bahr C, et al (2010) Impact of process related problems on water intake pattern of broiler chicken. Curran Associates Inc., Red Hook, NY, USA, p 29
  * Sharan and Moir (2017) Sharan RV, Moir TJ (2017) Robust acoustic event classification using deep neural networks. Information Sciences 396:24–32. https://doi.org/10.1016/j.ins.2017.02.013, URL https://www.sciencedirect.com/science/article/pii/S0020025517304553
  * Van Hirtum and Berckmans (2004) Van Hirtum A, Berckmans D (2004) Objective recognition of cough sound as biomarker for aerial pollutants. Indoor Air 14(1):10–15. https://doi.org/10.1046/j.1600-0668.2003.00195.x, URL https://onlinelibrary.wiley.com/doi/abs/10.1046/j.1600-0668.2003.00195.x
  * Vandermeulen et al (2016) Vandermeulen J, Bahr C, Johnston D, et al (2016) Early recognition of bovine respiratory disease in calves using automated continuous monitoring of cough sounds. Computers and Electronics in Agriculture 129:15–26. https://doi.org/10.1016/j.compag.2016.07.014, URL https://www.sciencedirect.com/science/article/pii/S0168169916305105
  * Vaswani et al (2017) Vaswani A, Shazeer N, Parmar N, et al (2017) Attention is all you need. Curran Associates Inc., Red Hook, NY, USA, NIPS’17, p 6000–6010


# Number fluctuations induce persistent congestion

Verena Krall<EMAIL_ADDRESS>Chair for Network Dynamics, Institute
for Theoretical Physics and Center for Advancing Electronics Dresden (cfaed),
Technical University of Dresden, 01062 Dresden  Max F. Burg  Institute for
Theoretical Physics and Centre for Integrative Neuroscience, University of
Tübingen, Germany  Bernstein Center for Computational Neuroscience, Tübingen,
Germany  Malte Schröder  Chair for Network Dynamics, Institute for Theoretical
Physics and Center for Advancing Electronics Dresden (cfaed), Technical
University of Dresden, 01062 Dresden  Marc Timme<EMAIL_ADDRESS>Chair for Network Dynamics, Institute for Theoretical Physics, Center for
Advancing Electronics Dresden (cfaed) and Cluster of Excellence Physics of
Life, Technical University of Dresden, 01062 Dresden

###### Abstract

The capacity of a street segment quantifies the maximal density of vehicles
before congestion arises. Here we show in a simple mathematical model that
fluctuations in the instantaneous number of vehicles entering a street segment
are sufficient to induce persistent congestion. Congestion emerges even if the
average flow is below the segment’s capacity where congestion is absent
without fluctuations. We explain how this fluctuation-induced congestion
emerges due to a self-amplifying reduction of the average vehicle velocities.

##  I Research question and hypothesis

Stationary traffic flows of vehicles on street segments are commonly
characterized by the average number of vehicles passing the segment per unit
time manual2000highway . In reality, vehicles enter and leave a segment at
discrete points in time such that the density of vehicles on the segment
fluctuates over time. What is the effect of these fluctuations on traffic
flow? We hypothesize that stochastic number fluctuations alone may induce
congestion.

##  II Methods and Data

Vehicles travelling at a free-flow velocity $u_{f}$ pass through a street
segment of length $l_{0}$ in a time $t_{0}=l_{0}/u_{f}$. In the presence of
other vehicles, this time increases. We model the travel time of a vehicle
entering a street segment with a current vehicle density $k$ using
Greenshields’ model (greenshields1935study, ; rakha2002comparison, )

$\displaystyle
t_{\text{travel}}(k)=\frac{l_{0}}{u_{f}}\frac{k_{j}}{k_{j}-k}\quad\text{for}\;k<k_{j}\
,$ (1)

where $k_{j}$ is the jam density of the street segment: when $k\geq k_{j}$ ,
the travel time diverges as the velocity of all vehicles drops to zero.

A simple macroscopic model of this process describes the change of the average
density $\left<k(t)\right>$ of vehicles on the street segment over time as the
difference between the incoming flow of vehicles $q_{\text{in}}$ and the
outgoing flow
$q_{\text{out}}(\left<k(t)\right>)=\left<k(t)\right>\,u(\left<k(t)\right>)$,

$\displaystyle\frac{\mathrm{d}\left<k(t)\right>}{\mathrm{d}t}=\frac{1}{l_{0}}\left[q_{\text{in}}-q_{\text{out}}(\left<k(t)\right>)\right]=\frac{1}{l_{0}}\left[q_{\text{in}}-\left(u_{f}\left<k(t)\right>-\frac{u_{f}}{k_{j}}\left<k(t)\right>^{2}\right)\right]\
,$ (2)

where we substituted the average velocity
$u(\left<k(t)\right>)=l_{0}[t_{\text{travel}}(\left<k(t)\right>)]^{-1}$ using
Eq. (1). This model thus neglects stochastic fluctuations of $k(t)$ .

We contrast this macroscopic model for average vehicle density
$\left<k(t)\right>$ with a stochastic model for the instantaneous number
density $k(t)$ of vehicles, implemented in an agent-based simulation. Vehicles
enter the segment individually according to a Poisson process
TN_libero_mab21251955  with the rate $\nu_{\text{in}}=q_{\text{in}}$. Each
vehicle has a velocity which is determined by the present vehicle density when
it enters the segment and stays constant over time. We neglect here temporary
changes in the velocity due to, e.g., random braking nagel1992cellular  that
would not counter the mechanism described here but rather cause even more
frequent traffic breakdowns. We also do not consider a speed-up of vehicles
when others leave the segment in front of them.

As a specific setting, we consider a one-lane highway (HW) segment of length
$l_{0,\text{HW}}=$1\text{\,}\mathrm{k}\mathrm{m}$$ with free-flow velocity
$u_{f,\text{HW}}=$120\text{\,}\mathrm{k}\mathrm{m}\mathrm{/}\mathrm{h}$$ . We
estimate the critical density of vehicles $k_{c}$ simultaneously on the road
above which congestion is likely to occur by considering a critical distance
between vehicles of $d_{\text{crit}}\approx$33.3\text{\,}\mathrm{m}$$ , given
as the distance driven by a vehicle with velocity $u_{f,\text{HW}}$ in one
second. This critical density becomes
$k_{c}=1/d_{\text{crit}}=30\,$\mathrm{v}\mathrm{e}\mathrm{h}\mathrm{/}\mathrm{k}\mathrm{m}$$
in the deterministic setting.

The jam density is derived by noting that the outflow is maximal at the
critical density, thus

$\displaystyle\left.\frac{\partial q_{\text{out}}}{\partial
k}\right|_{k_{c}}=u_{f}-\frac{2u_{f}}{k_{j}}k_{c}$
$\displaystyle\overset{!}{=}0$ (3) $\displaystyle\Leftrightarrow k_{j}$
$\displaystyle=2k_{c}\ .$

Thus, the critical flow is

$\displaystyle
q_{\text{in}}^{c}=q_{\text{out}}^{c}=u_{f}\left(k_{c}-\frac{k_{c}^{2}}{k_{j}}\right)=\frac{u_{f}k_{c}}{2}\
.$ (4)

##  III Findings

Figure 1:  The constant in-flow entering the macroscopic model (a) does not
capture the stochastic vehicle number fluctuations resulting from a Poisson
process (b). However, these fluctuations may cause congestion, even though
stable fixed points (indicated by dashed lines) are predicted from the
differential equation (c). Considering a sample of 500 random realizations,
for
$q_{\text{in}}=28\,$\mathrm{v}\mathrm{e}\mathrm{h}\mathrm{/}\mathrm{m}\mathrm{i}\mathrm{n}$$
a majority of realizations eventually reaches a congested state (d).

In the stochastic model, where vehicles enter the street segment in a Poisson
process, the time $\Delta t$ between two subsequent vehicles is a random
variable drawn from the exponential probability density $\rho(\Delta
t)=q_{\text{in}}\exp{\left(-q_{\text{in}}\,\Delta t\right)}$
peebles1987probability . Hence, the higher $q_{\text{in}}$ , the more frequent
are small values of $\Delta t$. Several vehicles may enter during a small time
interval (Fig. 1b), temporarily increasing the density of vehicles $k(t)$ on
the segment above the expected mean value. As a result we observe two
different types of dynamics for $k(t)$ during a longer observation interval
(Fig. 1c). For low $q_{\text{in}}$ the density of vehicles fluctuates near
some fixed base level such that traffic flows freely. However, for a
sufficiently large in-flow, once $k$ surpasses a threshold value the density
of vehicles increases rapidly and the segment congests. When performing
repeated simulations we find that such emergent congestions are not negligible
outliers but instead are highly probable to occur over time.

Figure 2:  The higher the in-flow, the more easily the density of vehicles on
the street segment exceeds the threshold to congestion $k_{c}=k_{j}/2$. (a)
The out-flow-curve defined in equation (2) resembles the qualitative form of
the well-known fundamental diagram helbing2001traffic  . For each in-rate
below $q_{\text{max}}$ , a stable and an unstable equilibrium exist (filled
and open circle, respectively). (b) The effective potential resulting from Eq.
(2) resembles a valley-and-peak landscape and the dynamics of the vehicle
density is analogous to a block sliding in this potential. On the left side of
the valley, representing the stable state, a steep slope pushes the vehicle
density away from zero for small $k(t)$. For large $k(t)$ there is a deep
canyon, representing a congested state. This landscape changes depending on
the flow of vehicles entering the street segment. For small $q_{\text{in}}$,
the stable valley itself is also deep. The block within the valley is
prevented from falling into the canyon by a peak of large height $\Delta U$.
Thus, the chances that small displacements of the block (small fluctuations of
the in-flow of vehicles) push it outside the safe region are very low. With
increasing $q_{\text{in}}$ the distance to the peak and the height $\Delta U$
decrease. Smaller and smaller fluctuations may cause the block to slip over
the peak and into the canyon (congested state) more and more easily.

How does this spontaneous breakdown of traffic flow emerge? To answer this
question, we compare the deterministic model with the stochastic model. In Eq.
(2) , the out-flow $q_{\text{out}}(\left<k\right>)$ is a function of the
average number density of vehicles with a maximal value $q_{\text{max}}=q_{c}$
, which equals the maximal in-flow. For sufficiently small incoming flows
$q_{\text{in}}\ll q_{c}$, we find that small temporary changes in the
instantaneous number density of entering vehicles are counterbalanced by
changes in the instantaneous number of vehicles leaving the segment per time,
reflecting a stable equilibrium flow (Fig. 2a) near a fixed point
$k_{\text{stable}}^{\ast}$ of the differential equation Eq. (2). Fluctuations
of the number density of vehicles are small and thus, on average, the
equilibrium value serves well as a prediction of the traffic state. However,
already for $q_{\text{in}}$ below the maximal in-flow $q_{c}$ set by the
macroscopic model, small changes in $k(t)$ induce congestion: Once a second,
unstable equilibrium $k^{\ast}_{\text{unstable}}$ is exceeded, the instability
pushes $k(t)$ to grow further. The probability of return below
$k^{\ast}_{\text{unstable}}$ decreases as the density of vehicles increases,
thus causing the congestion to be persistent.

Roughly speaking, with an increasing density of vehicles on the segment, their
velocities become lower so rapidly that the number of vehicles leaving the
segment is persistently lower than the number of vehicles entering during a
given time interval, thus causing further velocity reductions in a self-
amplifying process. In reality, the system ultimately reaches a fully
congested state with vehicles lining up throughout the segment.

We can intuitively understand why the unstable state becomes more important
for larger values of $q_{\text{in}}$: consider the right-hand side of Eq. (2).
As we are interested in the dynamics of vehicle density when perturbed from
equilibrium, we picture a sliding block whose position corresponds to the
density value $k$ (Fig. 2b). In this image, the differential equation (2)
would determine the velocity of the block, which equals the negative
derivative of an effective potential, a valley-and-peak landscape, with a
minimum at $q_{\text{stable}}^{\ast}$ and a maximum at
$q_{\text{unstable}}^{\ast}$ (Fig. 2b). This potential is defined via

$\displaystyle\frac{\mathrm{d}U(k)}{\mathrm{d}k}=U^{\prime}(k):=-q_{\text{in}}+u_{f}k\left(1-\frac{k}{k_{j}}\right)\
.$ (5)

In our traffic flow scenario, the height difference $\Delta U$ and the
distance between the peak and valley reflect the proximity of the two
equilibria. The closer the in-flow $q_{\text{in}}$ is to the maximal flow
$q_{c}$, the closer the two equlibria are and the smaller the vehicle number
density fluctuations needed to end up in a congested state. Thus, the
randomness of the vehicle-entering process crucially underlies the spontaneous
transition from free flow to congestion.

Moreover, these fluctuations become increasingly more likely: Based on the
general theory of stochastic processes (van1992stochastic, ;
TN_libero_mab21251955, ), we predict a mean time $T_{\text{esc}}$ after which
a transition to congestion occurs. For a one-lane-highway with $q_{c}=1800$
vehicles per hour (see Methods), congestion emerges roughly once every 32
hours already if the in-flow is $15\%$ below the maximal in-flow, i.e.,
$q_{\text{in}}=1530$ vehicles per hour. If the in-flow is $10\%$ below the
maximal value ($q_{\text{in}}=1620$ vehicles per hour), the transition is
expected to occur already after just 2.75 hours.

There exist several studies discussing the instability of traffic flow caused
by stochasticity treiber2013traffic , for example, due to random route choices
andreotti2015modeling  or the emergence of vehicle clusters due to random
distance fluctuations kuhne2002probabilistic . Typically, explanations for
traffic fluctuations are random decelerations due to imperfect human driving
behavior nagel1992cellular , external factors such as weather conditions,
daytime kim2010likelihood  or the existence of bottlenecks kerner2019complex .
In contrast, our minimal model shows that spontaneous number fluctuations
alone already suffice to induce congestion. Although the aforementioned
factors that influence traffic have to be considered for (the prediction and
prevention of) traffic jams, we thus emphasize that even in the absence of
such external influences, congested states may arise due to pure number
fluctuation. As neither the model details for the stochastic process nor those
for the travel time are relevant for the fundamental mechanism inducing the
presented transition TN_libero_mab21251955 , we conclude that congestion may
emerge spontaneously even for, in general, subcritical traffic flows. Hence,
for analyzing traffic flow and planning infrastructure, one needs to go beyond
average quantities and take into account pure number fluctuations. Future
investigations should aim at quantifying the effect of number fluctuations in
isolation, by analyzing the emergence of traffic jams in the absence of other
external influences on traffic flow. A promising setup may be a highway where
traffic consists only of autonomous vehicles, to ensure that imperfect driving
behavior does not have to be taken into account in the analysis. Furthermore,
a thorough study of the described mechanism in the presence of varying traffic
conditions would be particularly valuable for estimating the relevance of
vehicle number fluctuations in real-world settings.

##  IV Acknowledgments

We thank Dirk Witthaut for valuable discussions. The authors thank the German
Academic Scholarship Foundation for its role in supporting the initiation of
the project. V.K. thanks the Evangelisches Studienwerk. M.F.B. thanks the
International Max Planck Research School for Intelligent Systems (IMPRS-IS).

##  V Data availability

All material has been made publicly available at GitHub and can be accessed at
https://doi.org/10.5281/zenodo.4314973 .

## References

  * [1] Eleonora Andreotti, Armando Bazzani, Sandro Rambaldi, Nicola Guglielmi, and P. Freguglia.  Modeling traffic fluctuations and congestion on a road network.  Advances in Complex Systems, 18(03n04):1550009, 2015.
  * [2] Crispin W. Gardiner.  Handbook of stochastic methods for physics, chemistry and the natural sciences.  Springer, Berlin, 3. ed. edition, 2004.
  * [3] BD Greenshields, JR Bibbins, WS Channing, and HH Miller.  A study of traffic capacity.  In Highway research board proceedings, volume 1935. National Research Council (USA), Highway Research Board, 1935.
  * [4] Dirk Helbing.  Traffic and related self-driven many-particle systems.  Reviews of modern physics, 73(4):1067, 2001.
  * [5] Boris S. Kerner.  Complex dynamics of traffic management.  Springer, 2019.
  * [6] Jiwon Kim, Hani S. Mahmassani, and Jing Dong.  Likelihood and duration of flow breakdown: modeling the effect of weather.  Transportation Research Record, 2188(1):19–28, 2010.
  * [7] Reinhart Kühne, Reinhard Mahnke, Ihor Lubashevsky, and Jevgenijs Kaupužs.  Probabilistic description of traffic breakdowns.  Physical Review E, 65(6):066125, 2002.
  * [8] Highway Capacity Manual.  Highway capacity manual.  Washington, DC, 2, 2000.
  * [9] Kai Nagel and Michael Schreckenberg.  A cellular automaton model for freeway traffic.  Journal de Physique I, 2(12):2221–2229, 1992.
  * [10] Peyton Z. Peebles Jr.  Probability, random variables, and random signal principles.  McGraw Hill Book Company, 1987.
  * [11] Hesham Rakha and Brent Crowther.  Comparison of greenshields, pipes, and van aerde car-following and traffic stream models.  Transportation Research Record, 1802(1):248–262, 2002.
  * [12] Martin Treiber and Arne Kesting.  Traffic flow dynamics.  Traffic Flow Dynamics: Data, Models and Simulation, Springer-Verlag Berlin Heidelberg, 2013.
  * [13] Nicolaas Godfried Van Kampen.  Stochastic processes in physics and chemistry, volume 1.  Elsevier, 1992.