liubayesiandeeplearningmethod2022.md 82 KB


category: literaturenote citekey: liubayesiandeeplearningmethod2022 title: A Bayesian deep learning method for freeway incident detection with uncertainty quantification authors: "Liu, Genwang; Jin, Haolin; Li, Jiaze; Hu, Xianbiao; Li, Jian" year: 2022 date: 2022-00-00 2022 doi: 10.1016/j.aap.2022.106796 publication: "Accident Analysis & Prevention" url: "https://doi.org/10.1016/j.aap.2022.106796" zotero_key: 6ASJMP94 zotero_storage: R94K8N65 collections: transpordi_planeerimine folder: 001_artiklid firstAuthor: "Liu, Genwang"

status: converted

Contents lists available at ScienceDirect

Accident Analysis and Prevention

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

A Bayesian deep learning method for freeway incident detection with uncertainty quantification

Genwang Liu a , Haolin Jin b , Jiaze Li c , Xianbiao Hu d , Jian Li a,*

  • a Key Laboratory of Road Traffic Engineering of the Ministry of Education, Tongji University, College of Transportation Engineering, Tongji University, 4800 Cao'an Road, Shanghai 201804, PR China
  • b Fujian Zhengfu Software Co., Ltd, PR China
  • c School of Software, Zhengzhou University, 450000, 97 Wenhua Road, Jinshui District, Zhengzhou, Henan, PR China
  • d Department of Civil and Environmental Engineering, Pennsylvania State University, University Park, PA 16802, USA

ARTICLE INFO

Keywords: Freeway incident detection Uncertainty quantification Bayesian deep learning Machine learning Intelligent transportation system

ABSTRACT

Incident detection is fundamental for freeway management to reduce non-recurrent congestions and secondary incidents. Recently, machine learning technologies have made considerable progress in the incident detection field, but many still face challenges in uncertainty quantification due to the aleatoric uncertainty of traffic data and the epistemic uncertainty of model deviations. In this study, a Bayesian deep learning method was proposed for freeway incident detection with uncertainty quantification. A convolutional neural network variant was designed on a Bayesian framework, and mechanisms of Bayes by backpropagation and local reparameterization technics were used to update the weight of the proposed model. The predictive uncertainty of the proposed method was modeled jointly by integrating the aleatoric and epistemic uncertainty. The proposed model was tested on the PORTAL dataset and compared with four benchmark models: standard normal deviate, wavelet neural network, long-short term memory neural network, and convolutional neural network. The results show that the proposed model outperforms the baseline methods in terms of accuracy, detection rate and false alarm rate. Perturbation experiments were used to test the robustness of the model against noise. The results indicated that the aleatoric uncertainty of the model remained almost constant under different noise levels. The proposed method may benefit future studies on uncertainty quantification while using machine learning method in incident management and other fields in intelligent transportation systems.

1. Introduction

Traffic congestion is a common problem in urban cities worldwide because it decreases traffic operation efficiency and increases air pollution (Yuan et al., 2014). Generally, recurrent and non-recurrent congestion are two types of traffic congestion (Ozbay and Kachroo, 1999). Recurrent congestion is typically caused by daily travel demand fluctuations, usually observed during morning and evening peaks, whereas non recurrent congestion is mainly incident-induced, since incidents abruptly and temporarily disrupt normal traffic flow. Incidents often cause reduced travel time reliability, secondary crashes and increased air pollution. Therefore, automatic incident detection is important for traffic managers to respond promptly and minimize the impacts of non-recurrent traffic congestions (Owens et al., 2010). Early incident detection can reduce both the economic and time costs. It was

proven to save \$3.06 million and 143.3 million man-hours in the 272 urban areas where improved incident management procedures were implemented in 2007 (Schrank and Lomax, 2007).

Thanks to the widely implemented sensors (e.g., loop detectors and video surveillance systems), many statistics and machine learning based methods have been developed for detecting traffic incidents. A universal method for traffic incidents detection is as follows: algorithms learn patterns of normal traffic conditions from historically recorded traffic data, and report incidents occurrence when the characteristics of real time traffic data significantly differ from the learned historical patterns (Chakraborty et al., 2019). For example, the well-known California algorithm (Payne and Tignor, 1978) and Minnesota algorithm (Stephanedes and Chassiakos, 1993) detected incidents by analyzing anomalies in traffic data collected by downstream and upstream detectors based on historical patterns. The standard normal deviate (Balke et al., 1996)

E-mail addresses: 2031343@tongji.edu.cn (G. Liu), jhl@stu.zzu.edu.cn (H. Jin), lijz@stu.zzu.edu.cn (J. Li), xbhu@psu.edu (X. Hu), jianli@tongji.edu.cn (J. Li).

* Corresponding author.

algorithm was designed from a statistical perspective to classify traffic patterns of incidents and non-incidents, by using historical average travel times and their normal deviates to represent normal traffic patterns. Recently, machine learning-based methods for incident detection received considerable attentions (El Hatri and Boumhidi, 2018; Li et al., 2020; Lin et al., 2020; Yang et al., 2020; Zhu et al., 2018). Machine learning methods have shown the advantages of extracting traffic features more effectively, as compared with traditional statistical methods (Li et al., 2020).

However, several challenges remain when using machine learningbased methods for traffic incident detection. First, most previous machine learning-based methods are unable to incorporate uncertainty quantification with the model performance. Uncertainty quantification is different from the accuracy and false alarm rate commonly used in previous studies, it aims to measure the probability of certain outcomes based on the nature of uncertainties and how they are dealt with. In safety application fields, uncertainty quantification is taken as an important prerequisite for the acceptance of proposed models. It has been widely applied in intelligent transportation systems for traffic prediction (Hoque et al., 2021; Lin et al., 2018; Liu et al., 2019; Li and Rose, 2011) and incident duration prediction (Hoque et al., 2021; Vlahogianni and Karlaftis, 2013). For freeway incident detection, the uncertainty quantification of the detection determines the confidence of the detection, and it is crucial for emergency management decisionmaking. Thus, it is important to identify which uncertainties in freeway incident detection can be reduced. Second, uncertainty quantification for model parameters during model training process is essential, because the uncertainty caused by data and models has nonnegligible effects on incident detection performance and application. Machine learning methods learn the model weights using point estimation during the training process. Models are typically run from scratch assuming the models have minimal prior knowledge. This limits the potential model performance. When the domain distribution of input data changes or out-of-data instances occur, such as, the road geometries and traffic characteristics vary, the models need to be calibrated or reconstructed, resulting in computational and repetitive costs in realworld applications. Excluding the inherent uncertainty, poor data quality and inaccurate model assumptions could also induce additional uncertainty (Senge et al., 2014). The scarcity of incident instances has an effect on the performance of incident detection models and could also cause epistemic uncertainty. Moreover, the inevitable noise in traffic datasets could cause aleatoric uncertainty, which have a negative impact or even fail the model. Learning from data carries unavoidable uncertainty, in large part because the ability to generalize beyond a limited set of observations is based on inductive inference, i.e., replacing specific observations with general models, but these models are commonly theoretical (Senge et al., 2014).

To bridge these gaps, this study proposed a Bayesian deep learning (BDL)-based framework for freeway incident detection with uncertainty quantification. This proposed method can model the uncertainty of incident detection caused by inherently random traffic data and model imperfections on the basis of accurate detection. Experiments were conducted on the PORTAL dataset to compare the performance of our proposed model with benchmark methods. Detection rate and false alarm rate were used as model evaluation criteria. In addition, perturbation analysis was deployed to test the robustness of the proposed model against noise. The results show that our model performs robustly as aleatoric uncertainty remaining almost constant. The proposed model is simple to apply to other locations, since no parameters or threshold values need to be calibrated. The following summarizes four major contributions of this study:

(1) This study proposed a new method for detecting freeway incidents by applying a Bayesian deep learning framework. The proposed method uses a variant of convolutional neural network to learn the underlying knowledge and patterns of traffic flow under normal and incident conditions. The proposed method was experimented on a realworld dataset and compared with baseline models. The results showed that the proposed model was able to detecting freeway incidents accurately with a high detection rate and a low false alarm.

  • (2) This study incorporated the uncertainty quantification theory into traffic incident detection based on the proposed Bayesian deep learning framework. The uncertainties of traffic incident detection results were decomposed into two categories of uncertainty, aleatoric uncertainty and epistemic uncertainty. The former addresses uncertainty arisen from poor traffic data quality and the latter quantifies uncertainty caused by traffic incident detection models imperfection.
  • (3) This study introduced a perturbation analysis for incident detection performance evaluation under noisy traffic data with Gaussian noise and Poisson noise perturbations. And sensitivity analysis using different traffic characteristics was deployed to investigate the model performance. Both analytical procedures helped to increase the knowledge in the field of traffic incident detection.

The rest of the paper is organized as follows: Section 2 provides a review of the related studies. Section 3 describes the proposed methodology. Section 4 introduces the experimental design. Section 5 provides results and discussions. Section 6 summarizes conclusions.

2. Literature review

Many algorithms for incident detection based on data collected from inductive loop detectors have been proposed. The process of incident detection can be viewed as anomaly detection: algorithms treat traffic patterns under incident conditions as outliers, and perform anomaly detection based on the learned historical data. In recent years, Bayesian deep learning methods have rapidly advanced and have shown great potential for anomaly detection.

2.1. Statistics-based methods

Statistics-based methods have been widely used for traffic incident detection. Two good examples of this method are the California algorithm and the Minnesota algorithm. Payne and Tignor (1978) proposed the well-known California algorithm, which is based on decision trees and uses occupancies and volumes as input features. Puangnak and Chivapreecha (2019) developed a method to find the best threshold of the California algorithm by using statistical mathematics techniques and breadth-first search algorithms. Balke et al. (1996) confirmed the Minnesota algorithm, based on low filtering. This algorithm used the average volume and occupancy. Persaud et al. (1990) proposed the McMaster algorithm which is based on catastrophe theory, and takes volume, occupancy and speed as variables. Levin and Krause (1978) employed a Bayesian algorithm using occupancy difference and upstream occupancy as features. Abdulhai and Ritchie (1999) used Euclidean distance to measure different patterns via Bayesian-based probabilistic neural network. Balke et al. (1996) developed SND (standard normal deviate) algorithm. This algorithm collected historical travel time patterns under incident-free conditions and reported incident while real-time travel time exceeded the confidence interval of normal travel time. Tang and Gao (2005) provided an improved nonparametric regression algorithm based on SND algorithm, and the algorithm is constructed by searching historical traffic states that are similar to current traffic state. To deal with the dynamics of traffic incidents, a multiple model particle filter was proposed by Wang et al. (2016).

2.2. Machine learning-based methods

Machine learning-based methods learn traffic patterns in incident and normal conditions from traffic dataset, and can be implemented without specialized transportation knowledge. Hsiao et al. (1994) proposed a method to deal with the uncertainty caused by threshold values suitability in incident detection. The method used fuzzy logic rules and

membership functions to determine threshold values. Adeli and Samant (2000) proposed an adaptive neural network that treated incident detection as identifying incident patterns from normal patterns, and exploited wavelet transform and linear discriminant analysis to preprocess traffic dataset. Samant and Adeli (2001) denoised traffic dataset by using discrete wavelet transform, and detected incidents with a fuzzy neural network algorithm. Xiao et al. (2014) employed resampling technology to generate a dataset, and presented an ensemble learning method based on support vector machine for incident detection. Jeong et al. (2011) presented a wavelet-based freeway automatic incident detection with varying threshold values, that were adaptively changed with the traffic levels. Ali et al. (2021) proposed a real-time monitoring framework for traffic event detection by using the OLDA method to label data, and Bi-LSTM method to traffic event detection. Mercader and Jack (2020) modelled traffic incident detection as unsupervised anomaly detection and adopted isolation forest to detect anomalous traffic conditions. Parsa et al. (2019) compared the SVM and PNN methods in detecting the occurrence of accidents.

Recently, the applications of deep learning algorithms in incident detection have been received increasing attention. Zhu et al. (2018) proposed a convolutional neural network (CNN) model for traffic incidents detection. Jiang et al. (2020) developed a long short-term memory (LSTM) framework for crash detection considering different temporal resolutions. Lin et al. (2020) employed SVM algorithm and a generative adversarial network (GAN) model to address the issue of incident sample scarcity. Li et al. (2020) proposed a method with a GAN model to expand the incident sample size and balance the datasets. Yang et al. (2020) used an autoencoder (AE) model to detect the occurrence site and time of traffic incidents by extracting nonlinear features from traffic flow data.

2.3. Bayesian deep learning for anomaly detection

Bayesian deep learning integrates probabilistic models and deep learning to consider with uncertainties from both model and data. Bayesian deep learning models exploit probabilistic layers that are trained using Bayesian inference to capture uncertainty over weights and activations. Because these probabilistic layers are designed as alternatives to their deterministic layers, Bayesian deep learning models create a straight-forward way to extend traditional deep learning models to endorse probabilistic deep learning. Previous studies have demonstrated that Bayesian deep learning is a promising technique for anomaly detection. For example, Hern´ andez and Lopez ´ (2020) developed a Bayesian deep learning techniques for detecting plant diseases and quantified the prediction uncertainty for out-of-sample instances. Peng et al. (2020) extended CNNs and LSTM networks into Bayesian neural networks to evaluate the uncertainty of health prognostics. Seebock ¨ et al. (2019) assumed that epistemic uncertainties related to anatomical deviations, and developed a method to detect anomalous regions in retinal optical coherence tomography images.

Current related studies can be divided into two categories: statisticsbased and machine learning-based. In summary, although machine learning methods have made considerable advancement, some problems remain unresolved. First, machine learning-based methods can learn powerful representations by mapping; however, these mappings are often taken at face value and assumed to be accurate (Kendall and Gal, 2017). As a result, machine learning models are effectively a black box for incident detection applications. Second, previous machine learning methods for incident detection did not account for uncertainty, making it difficult to estimate the reliability of the incident detection results. In this paper, we attempt to fill the gaps by presenting a Bayesian convolutional neural network model. This model quantifies aleatoric uncertainty arisen from the inherent random noise of data and epistemic uncertainty induced by model imperfections. In addition, the proposed method can detect incidents accurately and reliably.

3. Methodology

In this study, the Bayesian deep learning (BDL) method was used to incorporate uncertainty into freeway incident detection. The BDL method unifies deep learning with a Bayesian statistical framework. By incorporating the advantages of deep learning in representation learning and the perspective of Bayesian inference, the BDL framework ensembles the ability of perception and thinking. (Wang and Yeung, 2020).

The BDL framework for freeway incident detection contains two modules: the traffic characteristics perception module learns traffic feature representation, i.e., the ability of perception. The uncertainty quantification module evaluates the reliability of the model parameters and predictive confidence of incident detection, i.e., the ability of thinking. A distinct superiority of this method is its capacity to capture the complex effects of uncertainty. The method decomposes uncertainty into aleatoric and epistemic uncertainty for regression and classification applications (Kendall and Gal, 2017). The proposed methodology for incident detection is shown in Fig. 1. First, a data analytics process is proposed for preprocessing the original traffic data and generating a training dataset for training. Second, a model for automatic incident detection is developed as a variant of a Bayesian convolutional neural network. Third, the uncertainty of the incident detection results is estimated. Finally, the performance of the model is calculated based on different metrics.

3.1. Basic definitions

Freeway incidents, disrupting normal traffic condition abruptly, are ordinarily observed as anomalies in the traffic flow. Incident detection methods attempt to distinguish anomalies based on both historical and real-time observed traffic data. Formally, we formulate the freeway traffic incident detection as a supervised anomaly detection task, with incidents labelled as anomalous events.

The notations in this study can be seen in Table 1. Let X = {xn}N n=1 ∈ R*d*denote a set of d-dimensional input features, and Y = { yn }N n=1 ∈ R represent the true label. Given a traffic dataset D = {( xn, yn) }N n=1with N i.i.d. samples, the probabilistic predictive distribution p(y|x) is modeled

Fig. 1. The proposed Bayesian deep learning model workflow for automatic freeway incident detection.

Table 1 Notations.

| Notations | Meaning | | | |-----------|-------------------------------------------|--|--| | X | The training inputs | | | | Y | The prediction outputs | | | | ω | The model parameters | | | | x* | The new observed inputs | | | | y* | The predictions corresponding to x* | | | | D | The dataset for training and testing | | | | p | The prior distribution | | | | qθ | The approximated variational distribution | | |

by a neural network. Assuming a Bayesian deep learning model, a prior distribution p(ω) is placed on a parameter vector ω ∈ Ω, which includes the weights and bias vectors of the neural network; then a posterior distribution can be presented according to Bayes rule:

$$p(\omega|D) = \frac{p(\omega,D)}{(D)} = \frac{p(\omega)p(D|\omega)}{p(D)} = \frac{\prod_{i=1}^{N} p(y_i|x_i,\omega)p(\omega)}{p(D)}$$ (1)

For a new input feature x* and a new output label y*, the predictive distribution can be formulated as:

$$p(y^|x^,D) = \int_{\Omega} p(y^|x^,\omega)p(\omega|D)d\omega$$ (2)

For the parameter vector ω, the neural network last K-dimensional preactivated linear output can be denoted as fω(x) = [(fω 1 (x), ..., fω K (x)]T ; then, the predictive probability is calculated by:

$$p(y^{(k)} = 1 | x, \omega) = p{y^{(k)} = 1 | f^{\omega}(x)} = \frac{exp{fk^{\omega}(x)}}{\sum{j=1}^{K} exp{f_j^{\omega}(x)}}$$ (3)

Finally, the output of our model is transformed into a set of binary labels that indicate whether each test time tick is an anomaly or not, i.e., y = {0, 1}, where y = 1 indicates that the input x is anomalous.

3.2. Bayesian deep learning model description

For this study, the traffic occupancy data is converted into a grid size, with the horizontal axis direction denoting detector station locations and the vertical axis direction denoting the time. Each period is labeled based on whether an incident occurs. The convolutional neural network is chosen as the backbone model for the reason that CNN-based model could capture spatial and temporal dependency of traffic flow via convolutional operation, which have been proven in previous researches such as Zhang et al (2017), Ma et al (2017). Moreover, a fully Bayesian perspective on the CNN is achieved by estimating probability distributions of the weights in both the convolutional layers and the fully connected layers. This research refers to the LeNet5 structure (LeCun, 2015) to design the CNN architecture. Fig. 2 gives an intuitive illustration of the proposed Bayesian convolutional neural network.

3.3. Bayes by backpropagation for model training

For neural networks training, backpropagation is the most universally used technique. It is a continual iterative process in which the weights of the neural network are updated continually during training. This technique works in two steps. First, propagate the input features forward through the neural network and calculate the loss function to get the training loss with respect to the weights of neural network. Second, calculate the derivatives of the training loss and propagate them from the back to the front of the neural network. Then the neural network weights are updated according to the computed derivatives.

Although the backpropagation mechanism is widely used, a network trained with backpropagation makes overly confident predictions because the network only achieves point estimates of the weights and does not take uncertainty into consideration in the parameters. Because of the absence of uncertainty quantification, the network is apt to overfitting and requires regularization. To overcome this shortcoming, in this paper, we use the Bayes by Backpropagation technique (Blundell et al., 2015; Shridhar et al., 2018) to train the proposed deep neural network, which incorporates a Bayesian approach into backpropagation. Bayes by Backpropagation can be used to propagate uncertainty in parameter estimates into predictions. Additionally, this technique grants the model robustness against overfitting by averaging over parameter values rather than using single point estimates.

In backpropagation of the CNN model under a Bayesian perspective, variational inference is employed to search the true weights distribution. The objective of variational inference is to approximate the conditional probability of latent variables under observed variables. Because the true posterior distribution of weights is intractable to compute, a distribution qθ(ω|D) is defined to approximate the true posterior p(ω|D). The parameter θ represents the shape parameter of the probability distribution qθ(ω|D), and the distribution qθ(ω|D) decided by the optimal parameter θopt is the closest distribution to the true posterior p(ω|D). The Kullback-Leibler (KL) divergence is a statistical distance that measures differences between two probability distributions. In this research, the KL divergence is used to measure the distance between the true posterior distribution p(ω|D) and the approximate distribution qθ(ω|D), which is represented in Eq. (4):

$$KL\left[q{\theta}(\omega|D)\middle|p(\omega|D)\right] = \int q{\theta}(\omega|D)\log\frac{q_{\theta}(\omega|D)}{p(\omega|D)}d\omega \tag{4}$$

According to Eq. (1), because p(D) does not depend on ω and can be considered as a constant, an equivalent form that omits the factor p(D) is p(ω|D)∝p(ω)p(D|ω). Similarly, since logp(D) is constant, it can also be omitted from the optimization of θ. Hence, the KL divergence can be simplified in Eq. (5):

Fig. 2. Bayesian convolutional neural network model.

argminθ KL[qθ(ω|D)||p(ω|D)]

$$= \underset{\theta}{\operatorname{argmin}} \int q{\theta}(\omega|D) \log \frac{q{\theta}(\omega|D)}{p(\omega|D)} d\omega$$

$$= \underset{\theta}{\operatorname{argmin}} \int q{\theta}(\omega|D) \log \frac{q{\theta}(\omega|D)}{p(\omega)p(D|\omega)} d\omega \tag{5}$$

Taking ∫ qθ(ω|D)dω as the expectation of the random variable ω, the formulation can be derived in Eq. (6) as follows:

$$\int q{\theta}(\omega|D) \mathrm{log} \frac{q{\theta}(\omega|D)}{p(\omega)p(D|\omega)} d\omega$$

$$= (\log q{\theta}(\omega|D) - \log p(\omega) - \log p(D|\omega)) \int q{\theta}(\omega|D) d\omega$$

$$= E{q(\omega|D)}[\log q{\theta}(\omega|D)] - E{q(\omega|D)}[\log p(\omega)] - E{q(\omega|D)}[\log p(D|\omega)]$$ (6)

Hence, the optimal parameters θopt can be modeled as:

$$\theta^{opt} = \underset{\theta}{arg \min} KL[q_{\theta}(\omega|D)||p(\omega|D)]$$

$$= arg \min{\theta} \int q{\theta}(\boldsymbol{\omega}|\boldsymbol{D}) \log \frac{q_{\theta}(\boldsymbol{\omega}|\boldsymbol{D})}{p(\boldsymbol{\omega})p(\boldsymbol{D}|\boldsymbol{\omega})} d\boldsymbol{\omega}$$

$$= \underset{\theta}{arg \min} KL[q{\theta}(\omega|D)||p(\omega)] - E{q(\omega|\theta)} \left[\log{p}(D|\omega)\right] + \log{p}(D)$$

$$= \operatorname{argminKL}{\theta}[q{\theta}(\omega|D)||p(\omega)] - E{q(\omega|\theta)}[\log{p}(D|\omega)]$$ (7)

Since it is also difficult to calculate KL-divergence precisely, the weights ω are sampled from the variational distribution qθ(ω|D). The expectation of the random variable qθ(ω|D) can be approximated by sampling n times:

$$E{q(\omega|D)} = \sum{i=1}^{n} q_{\theta}(\omega|D)$$ (8)

Therefore, the loss function F(D, θ) is approximated:

$$F(D,\theta) \approx \sum{i=1}^{n} \log q{\theta}(\omega^{(i)}|D) - \log p(\omega^{(i)}) - \log p(D|\omega^{(i)})$$ (9)

The function is optimized to be minimized during training to obtain the optimal θ.

3.4. Local reparameterization technics

Reparameterization is one of the most universal tools utilized in statistics, which rewrites statistical problems in an equivalent but distinct formulation. This study uses a local reparameterization technique to transform the global uncertainty of weights into local uncertainty with an instance-independent formulation. Rather than sampling the weight matrix W, the local reparameterization technique samples the layer activations b. The posterior approximation is specified on the weights to be a fully factorized Gaussian:

$$q{\phi}(\omega{ij}) = N(\mu{ij}, \sigma{ij}) \tag{10}$$

Since sampling from the distribution is non-derivable, the weights are sampled as:

$$\omega{ij} = \mu{ij} + \sigma_{ij} \in ij \tag{11}$$

For a factorized Gaussian posterior on the weights, the posterior for the activations is also a factorized Gaussian:

$$q{\phi}(b{mj}|A) = N(\gamma{mj}, \delta{mj}) \tag{12}$$

Where N is the sample size. The activations from the Gaussian distri-

bution are sampled, using bm,j = γm,j + ̅̅̅̅̅̅̅ δm,j √ ζm,j = ∑N i=1am,iμi,j + ζm,j ̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ ∑ ̅̅̅ N i=1a2 *m,i σ*2 √ .

Therefore, the Eq. (13) for convolutional layer activations b becomes:

$$\delta{mj} = \sum{i=1}^{N} a{mj}^{2} \sigma{ij}^{2} \tag{13}$$

3.5. Uncertainty quantification in incident detection

Uncertainty quantification is the significant methodology of quantitative characterizing and reducing uncertainties in mathematical models and reality applications. In the context of machine learning modeling, uncertainty refers to a lack of confidence in the estimates of a certain model. Uncertainties into commonly classified into two categories, aleatoric uncertainty and epistemic uncertainty. Aleatoric uncertainty is thought to be caused by the inherent randomness of a phenomenon, whereas epistemic uncertainty is induced by insufficient knowledge (Kiureghian and Ditlevsen, 2009). Epistemic uncertainty tries to determine how likely certain outcomes are if some aspects of the system are not known exactly. For freeway incident detection, it is essential to quantify the uncertainty to improve transportation management. In our model, uncertainty is classified into two categories, aleatoric uncertainty and epistemic uncertainty.

(1) Aleatoric uncertainty

Aleatoric uncertainty, also called as statistical uncertainty, is caused by data uncertainty. Data uncertainty is common due to data noise and missing data. In this paper, aleatoric uncertainty is adopted to quantify the results uncertainty used by traffic noisy data. Aleatoric uncertainty is modeled by setting a distribution on the outputs of the proposed model, and its formula is shown in the first half of Eq. (14).

(2) Epistemic uncertainty

Epistemic uncertainty estimates the differences between the model and real world, that occur when the model neglects certain effects. The predictive distribution is quantified by the predictive variance. In this paper, epistemic uncertainty is used to evaluate the results uncertainty caused by model deviations. Epistemic uncertainty is modeled by setting a prior distribution on the weights of the model and capturing the weight variation on a given traffic dataset. The formula for epistemic uncertainty is shown in the second half of Eq. (14).

Formally, the mathematical description of aleatoric and epistemic uncertainty is:

T

$$\begin{split} & Var{q \sim (y^|\mathbf{x}^)}(\mathbf{y}^*) = E{q \sim (y^|\mathbf{x}^)}\left[\mathbf{y}^*\mathbf{y}^{T}\right] - E_{q \sim (y^|\mathbf{x}^)}[\mathbf{y}^]E{q \sim (y^|\mathbf{x}^)}[\mathbf{y}^*]^T \ &= \underbrace{\int \left[diag\left(E{p(y^|\mathbf{x}^,\omega)}[\mathbf{y}^]\right) - E_{p(y^|\mathbf{x}^,\omega)}[\mathbf{y}^]E{p(y^|\mathbf{x}^,\omega)}[\mathbf{y}^*]^T\right]q{\widehat{q}}(\omega|D)d\omega}_{alcatoric} \end{split}$$

[

$$+\int\underbrace{\left(E{p(\boldsymbol{y}^{}|\boldsymbol{x}^{},\boldsymbol{\omega})}[\boldsymbol{y}^{*}]-E{q{\widehat{\boldsymbol{g}}}(\boldsymbol{y}^{}|\boldsymbol{x}^{})}[\boldsymbol{y}^{*}]\right)\left(E{p(\boldsymbol{y}^{}|\boldsymbol{x}^{},\boldsymbol{\omega})}[\boldsymbol{y}^{}]-E{q{\widehat{\boldsymbol{g}}}(\boldsymbol{y}^{}|\boldsymbol{x}^{})}[\boldsymbol{y}^{}]\right)^{T}q{\widehat{\boldsymbol{g}}}(\boldsymbol{\omega}|\boldsymbol{D})d\boldsymbol{\omega}}{epistemic}$$

$$\tag{14}$$

Aleatoric uncertainty measures the intrinsic randomness of an output y*. Epistemic uncertainty arises from the variability of ω on a given dataset. The detailed derivation is provided in Appendix A.

4. Experiment design

4.1. Data description

The Portland Oregon Transportation Archive Listing (PORTAL) (Report) is an online database that is developed and maintained by Portland State University, to record occupancy, speed, and volume data

detected by dual loop detectors on the freeways in Portland area. The data is sampled every 20 s. In addition, the corresponding incident records are also provided in the database. The PORTAL database has been used in previous researches (Bertini et al., 2008; Horowitz and Bertini, 2007; Li and Bertini, 2010; Potter et al., 2007). This database is chosen as a data source for generating datasets under incident and non-incident conditions. The I-205 freeway is chosen as a testbed. The I-205 freeway data include 17,908,260 logs from September 15, 2011 to November 15, 2011. In addition, 684 incident records that occurred on I-205 are selected from the database.

The I-205 freeway has both southbound and northbound roads. These data cover a 12.01 miles section of I-205 SB and a 10.09 miles section of I-205 NB. The average distance from incident sites to downstream detectors is close to 0.619 miles, and the average distance from incident sites to upstream detectors is close to 0.958 miles.

4.2. Data preprocess

To generate a high-quality dataset for learning, first the loop data is preprocessed by data fixing, aggregation, and standardization. Then the incident record and the loop dataset are ensembled to extract the traffic dataset affected by incidents. The case-control principle is followed to choose the corresponding non-incident traffic dataset.

  • (1) Missing data imputation: In the process of loop data acquisition and storage, data missing problem is inescapable. For the data collected from the dual-loop detectors, the K-Nearest Neighbor (KNN) algorithm is adopted to fix the missing data.
  • (2) Data aggregation: Since the original dataset is sampled every 20 s, and the traffic conditions are unstable at this small granularity. The dataset is aggregated into 1-minute segments, which maintains the traffic characteristics while keeping the granularity as small as possible.
  • (3) Data ensemble: The traffic data are selected as shown in Fig. 3. This study selects occupancy from the four stations closest to the incident locations, with two stations upstream and two stations downstream. The detection response time is set to 30 min, and traffic data from the previous 30 min are used as traffic characteristics to detect whether the incident will occur in current time slice.

The case-control strategy (Abdel-Aty et al., 2004) is used to extract non-incident data. Several principles are obeyed to eliminate the influence of time and location on traffic conditions. The times of the nonincident instances are selected one or several days ahead, with the highest number of days ahead being 14. The day of week and the time of

day are also controlled similarly. In addition, the location and weather are kept the same. After these steps, 210,114 incident logs and 3,399,637 normal logs are generated.

  • (4) Over sampling: Due to the scarcity of traffic data under incident conditions, the dataset of incident and non-incident conditions is imbalanced. To resolve the imbalanced dataset, an over-sampling strategy is performed to the incident dataset. The over-sampling strategy balances the dataset by increasing the number of minority class samples. The synthetic minority oversampling technique (SMOTE) is a typical over sampling algorithm. For each instance in the minority class, the algorithm calculates the Euclidean distance between this instance and other instances and obtains its k-nearest neighbors. Then, the sampling ratio is chosen according to the imbalance ratio of the dataset. For each minority instance, several instances are selected from its knearest neighbors randomly. The python imbalanced-learn package is utilized to run the SMOTE algorithm on the dataset. After over sampling, the incident logs are expanded to 3,399,637, maintaining a 1:1 ratio with non-incident logs. After over sampling, the dataset for model training and evaluation is divided into a ratio of 8:2.
  • (5) Data normalization: To reduce the influence of some extreme values, Z-score is used to transform traffic data. The Z-score normalizes traffic data by subtracting the mean and scaling to unit variance. After the dataset is preprocessed, this study used the first 46 days for model training and the last 15 days for model test. The training size is 46 days and the testing dataset size is 15 days.

4.3. Evaluation criteria

In this study, three widely used measures were used to evaluate the performance of the proposed model.

(1) Detection Rate (DR)

$$\mathbf{DR} = \frac{\mathbf{total \ number \ of \ detected \ incidents}}{\mathbf{total \ number \ of \ actual \ incidents}} *_{100}$$ (15)

(2) False Alarm Rate (FAR)

$$FAR = \frac{\text{total number of false alarm cases}}{\text{total number of algorithm applications}} *100$$ (16)

(3) Accuracy (ACC)

$$ACC = \frac{\text{numbers of instances correctly classified}}{\text{total number of instances}} *100$$ (17)

Specifically, DR is used to assess the ability to detect incidents; the larger the value, the better the model performs. FAR is used to evaluate model false judgment; the smaller the value, the more accurate the model predictions. ACC represents the ability of the model to distinguish between incident and non-incident instances. A higher ACC indicates that the model has a better classification ability.

5. Results

5.1. Experiment specifications

The experiments are carried out on a Dell workstation with 128 GB RAM and an Intel(R) Xeon(R) 2.200 GHz CPU. To train the deep learning models, the experiments used a GPU node with an Nvidia Quadro P4000 Card. The BCNN model is implemented with the support of the PyTorch library. The proposed model consists of two convolution layers, one with a 3*3 convolution kernel and the other with a 4*4 convolution kernel. After each of the convolution operations, the inputs are routed through the pooling layer, which reduces the data matrix by half. At the bottom, there are two fully connected layers as hidden layers that have 120 neurons and 84 neurons, as well as an output layer that gives a twodimensional vector. Bayes by backprop with local reparameterization technics is used on all layers.

Fig. 3. Diagram of traffic data selection. The randomized search method is used in the experiment to fetch the

optimal combination of hyper-parameters, and the final hyperparameters are shown in Table 2. The learning rate is set to 0.001, and the batch size is 256. Adam is taken as the optimizer and softplus is used as the activation function. The training process of the proposed BCNN model is shown in Fig. 4.

5.2. Comparison methods

To verify the effectiveness of the developed model in freeway incident detection, this research compares its performance with the following state-of-the-art methods: 1) standard normal deviate (SND); 2) wavelets neural network (WNN); 3) convolutional neural network (CNN); 4) long-short term memory neural network (LSTM). The experimental settings of the baseline methods for comparison are listed as follows:

  • (1) SND (Balke et al, 1996). The SND algorithm is based on the statistical principle of standard normal deviates. In this experiment we follow the SND principle, and use traffic occupancy data to compare a current loop-provided traffic occupancy with the expected occupancy derived from historical data.
  • (2) WNN (Jeong et al, 2011). The WNN model is combines wavelet transform and neural networks. In this experiment, the WNN is implemented by two hidden layers and one output layer. The first hidden layer outputs a 32-dimensional vector, from data input in 12-dimensional form, while the second one is a 32 × 16 wt matrix. The output layer takes a 16-dimensional vector as input and outputs a 2-dimensional vector. The optimizer uses Adam, and the activation function uses the ReLU method.
  • (3) LSTM (Jiang et al, 2020). The LSTM model uses a 12-dimensional vector as an input, which is processed by one LSTM layer. The LSTM layer is a neural network with 256 hidden neurons.
  • (4) CNN (Zhu et al, 2018). The input data is a 12 × 32 matrix. The model has two convolutional layers, two pooling layers and three fully connected layers. The convolution kernel sizes of the two convolutional layers are 3 and 4 respectively. The optimizer uses Adam, and the activation function uses the softplus method.

5.3. Detailed baseline parameters settings

All baseline models are trained based on the best hyper-parameters chosen by using random search. The detailed hyper-parameters of the baseline models mentioned in our experiments are listed in this section.

  • (1) SND. Five critical SND (2.0, 2.5, 3.0, 3.5 and 4.0) values are selected to test the model performance, and find that when the SND is equal to 2.0, the model performs best in the dataset used.
  • (2) WNN. 16 and 32 neurons are set in two hidden layers of the WNN. The best result of learning rate is 0.001. The batch sizes of 64, 128, 512, 1024 and 2048 are tested, and find that 128 is the best batch size. A total of 100 epochs is trained.
  • (3) LSTM. After testing four learning rates (0.1, 0.01, 0.001 and 0.0001) and three kinds of batch size (64, 128 and 256), the learning rate of 0.001 and the batch size of 128 performs optimum in our LSTM model. The final model is obtained after 100 epochs of training.
  • (4) CNN. The learning rate is tested ranging from 0.1 to 0.0001, and finally the optimal learning rate of 0.001 is taken. In addition, the batch size is chosen as 128. During the training, a total of 100 epochs is

Table 2 Hyper-parameters of the BCNN model.

Variable Value
Learning rate 0.001
Batch size 256
epochs 100
Optimizer Adam
Activation function softplus

performed. In addition, 12 filters for the first convolutional layer and 32 filters for the second convolutional layer were used, respectively.

5.4. Experimental results

The comparisons of the BCNN model and other baselines on the given dataset are shown in Table 3. The BCNN model obtains better detection performance than the other models based on the evaluation metrics, proving the effectiveness of the proposed model in freeway incident detection.

  • (1) Higher detection rate. To verify the ability to detect traffic incidents, the detection rates of all models are calculated. The results demonstrate that the BCNN model achieves a higher detection rate of 90.53 %, which is 22.54 %, 3.07 %, and 25.58 % higher than that of the WNN model, CNN model, and LSTM model, respectively.
  • (2) More accurate detection. The results demonstrate that the CNNbased methods, including the BCNN model and the CNN model, generally achieve better detection accuracy than the other baselines, such as the LSTM model, the WNN model and the SND model. The BCNN model achieves a 92.54 % accuracy rate, which is 27.91 %, 9.92 %, and 19.92 % higher than that of the WNN model, SND model, and the LSTM model, respectively. A conceivable explanation for this phenomenon is the CNN-based methods accentuate the importance of capturing spatial–temporal patterns. Compared with the CNN model which is trained by frequentist inference, the accuracy rate of the BCNN model is increased by 1.27 %, indicating that the regularization effect of Bayesian variational inference can promote the detection performance of the same network architectures.
  • (3) Lower false alarm rate. To investigate the false judgment of algorithms for traffic incident detection, this study compared the false alarm rate of the BCNN model with other baselines. The BCNN model has a false alarm rate of 5.09 %, which is close to the 5.05 % false alarm rate of the CNN model. This phenomenon is easy to understand since both the BCNN model and the CNN model have the same network architectures. The SND model achieves the lowest false alarm rate, at the cost of the lower detect rate whereas. Although the BCNN model does not achieve the best performance among the baseline models, it maintains a lower false alarm rate and higher detection rate simultaneously. The BCNN has a false alarm rate approximately 82.56 % and 64.10 % lower than the WNN and LSTM model, respectively.

5.5. Perturbation analysis and robustness

Noise is inevitable during real-world traffic data acquisition and storage. Hence, the noise immunity of incident detection models is of great importance. Perturbation analysis experiments was deployed to test the robustness of the BCNN against noise. Two common types of random noises, Gaussian noise and Poisson noise, which have been widely used in perturbation experiments of previous researches (Bai et al., 2021; Li et al., 2018; Zhao et al., 2019) are added to the dataset for experiments. The noise obeys different levels of the Gaussian distribution N(0, σ)(σ ∈ (0, 0*.1,* 0*.2,* 0*.*3)) or the Poisson distribution P(λ)(λ ∈ (1, 2, 4)). The noise matrices are normalized in the range of 0 to 1. An intuitive display of the performance of the proposed model against different noise levels are shown in Fig. 5. The metrics fluctuate slightly under Gaussian and Poisson disturbances. As shown in Table 4, the proposed BCNN model performs robustly against different types of noise since the change in the metrics is minor regardless of the noise distribution. DR, FAR, and ACC fluctuate slightly, at approximately 0.90, 0.05, 0.92 with different levels of Gaussian noise. With different levels of Poisson noise, DR, FAR, and ACC change slightly at approximately 0.90, 0.05, and 0.92, respectively. Therefore, the proposed model is robust against noise and capable of consistently detecting incidents stably in traffic data with high noise.

For further investigation, this research estimates the aleatoric uncertainty affected by different noises. Results in Table 5 indicate that

Fig. 4. Train process of BCNN.

Table 3 Performance comparison of the BCNN model and other baselines on the Portland dataset.

| Model | Accuracy
(decimal) | DR
(decimal) | FAR
(decimal) | | |---------------------------------|-----------------------|-----------------|------------------|--| | BayesianCNN (Proposed
model) | 0.9254 | 0.9053 | 0.0509 | | | WNN | 0.7235 | 0.7388 | 0.2918 | | | SND | 0.8419 | 0.0655 | 0.0475 | | | CNN | 0.9138 | 0.8783 | 0.0505 | | | LSTM | 0.7717 | 0.7209 | 0.1418 | |

aleatoric uncertainty is independent of different noise levels, and the values of aleatoric uncertainty appropriate remain stable around 0.058. The results confirm that the proposed model can detect incidents stably under traffic data with noise. And the values of epistemic uncertainty are in a small range of 0.017 to 0.018, indicating that our proposed model has strong capabilities of generalization for mapping the real traffic flow.

5.6. Sensitivity analysis

To investigate the generalization and transferability of the proposed model, two sensitivity analysis experiments are conducted. Firstly, the performance of the proposed model on traffic speed is tested to investigate effects of different traffic characteristics. Secondly, dataset is sampled and regenerated to simulate different collection intervals and validate the impact of different data collection intervals on the model performance.

(1) Effects of different traffic characteristics. The traffic speed in portal dataset is chosen as the input features. The dataset preprocess process is described in section 4. In this experiment, both the proposed model and the baselines are adjusted to the optimal parameters using grid search approach. As a result, the learning rate for the CNN model is set to 0.002, and the batch size for the CNN model is 128. The optimizer is Adam and softplus is taken as activation function in the CNN model. For the LSTM model, the learning rate is set to 0.002, and the batch size is 128. The optimizer is Adam and the activation function is softplus in the LSTM model. For the WNN model, the learning rate is set to 0.001, the batch size is 128. The optimizer is Adam and the activation function is softplus in the WNN model. For the BCNN model, the learning rate is set to 0.002, and the batch size is 128. The optimizer is Adam and the activation function is softplus in the BCNN model. The training process of BCNN is visualized in Fig. 6.

The experimental result demonstrates that comparing with other

Fig. 5. The results of Perturbation analysis. (a) Gaussian perturbations on the Portland dataset (b) Poisson perturbations on the Portland dataset.

Table 4 Detection performance for BCNN with different levels of noise.

Perturbation type DR (decimal) FAR (decimal) Accuracy (decimal)
Gaussian noise (σ = 0) 0.9036 0.0502 0.9321
Gaussian noise (σ = 0.1) 0.9000 0.0658 0.9152
Gaussian noise (σ = 0.2) 0.8981 0.0521 0.9235
Gaussian noise (σ = 0.3) 0.8963 0.0722 0.9142
Poisson noise (λ = 0) 0.9036 0.0502 0.9321
Poisson noise (λ = 2) 0.9119 0.0658 0.9224
Poisson noise (λ = 4) 0.9009 0.0557 0.9231

Table 5 Aleatoric and epistemic uncertainty for BCNN with different levels of noise.

Perturbation type Aleatoric uncertainty
(decimal)
Epistemic
Uncertainty
(decimal)
Accuracy
(decimal)
Gaussian noise (σ = 0) 0.058327 0.018279 0.9321
Gaussian noise (σ = 0.1) 0.057925 0.018014 0.9152
Gaussian noise (σ = 0.2) 0.058335 0.017700 0.9235
Gaussian noise (σ = 0.3) 0.058880 0.017939 0.9142
Poisson noise (λ = 0) 0.058327 0.018279 0.9321
Poisson noise (λ = 2) 0.058455 0.018080 0.9224
Poisson noise (λ = 4) 0.058650 0.017783 0.9231

baselines, the proposed model still achieves a better performance with traffic speed features. As shown in Table 6, the BCNN model performs a 87.81 % accuracy rate, which is 16.64 %, 5.78 %,11.42 % higher than that of the WNN, the CNN and the LSTM model, respectively. The detection rate of the BCNN model is 85.09 %, which is 19.02 %, 43.65 %, 2.52 % higher than that of the WNN, the CNN and the LSTM model. The false alarm rate of the BCNN model is 2.19 %, which is 91.31 %, 23.96 % lower than that of the WNN and LSTM model. The false alarm of the CNN model is 1.61 %, which is 26.48 % lower than the BCNN model.

(2) Impact of different data collection intervals. The PORTAL dataset is collected by loop detectors with 20-second interval. However, due to the diversity of types of traffic sensors and the setting of different devices, there exists diversity in traffic data collection intervals in real world. To investigate the impacts of data collection intervals on the proposed model, a sensitivity analysis is conducted. Firstly, the PORTAL dataset is reproduced by average sampling method to simulate different traffic data collection intervals. Secondly, the proposed model is tested on four datasets with 20-second, 40-second, 60-second and 80-second collection interval. The results are shown in Fig. 7 and Table 7. From the results, the incident detection accuracy and the detection rate of the proposed model increase as the traffic data collection interval decreases, while the false alarm rate decreases as the traffic data collection interval decreases. One possible reason is that when the traffic data collection interval is smaller, the underlying traffic features are richer as the quantity of traffic data collected is larger. Moreover, both aleatoric uncertainty and epistemic uncertainty increase with the traffic data collection interval increases. This is consistent with the uncertainty theory that the data scarcity increases, the model predictive uncertainty increases.

6. Conclusions

This study proposed a Bayesian deep learning model for freeway

incident detection with uncertainty quantification. Based on a realworld dataset in the Portland area, experiments were conducted to investigate the performance and robustness of the proposed model. The results show that the proposed model can increase the detection rate from 87.83 % to 90.53 % and reduce the false alarm rate from 29.18 % to 5.09 %. In addition, the aleatoric uncertainty caused by data and the epistemic uncertainty caused by the models are estimated. The results indicate that the proposed model is robust with detecting incidents stably against noise.

The proposed framework can be further developed from the following perspectives: 1) Various types of incidents can be tested with the proposed model framework, such as lane closures and accidents, etc. Additionally, incidents of different severity levels can be considered. Uncertainty quantification for incidents of different types and severity levels will improve the interpretability and broaden the understanding of underlying traffic knowledge. 2) The proposed model mainly considers occupancy and speed as input features. Other traffic features, such as volume, and road topology, can be used in the future to improve prediction accuracy. Hence, a mechanism designed to jointly capture inter-series correlations of traffic variables and spatial dependencies jointly, is also important and merits future investigation. 3) The current model framework is designed for the data source from inductive loop detectors. Performance and uncertainty quantification on other data sources, such as probe vehicle data and social media data can be explored with the proposed model framework. 4) Due to the scarcity of dataset used in this research, the influence of different detection response time on the performance of the proposed algorithm is not further explored. Moreover, the effect of incident detection under different traffic conditions is also worth exploring. 5) The proposed model framework can also be applied to related tasks in intelligent transportation systems, such as traffic accident prediction and secondary incident detection.

Table 6 Detection performance for BCNN with traffic speed features.

Model Accuracy
(decimal)
DR
(decimal)
FAR
(decimal)
BayesianCNN (Proposed
model)
0.8781 0.8509 0.0219
WNN 0.7319 0.6891 0.2522
CNN 0.8273 0.4795 0.0161
LSTM 0.7778 0.8295 0.0288

Fig. 6. Training process of BCNN with traffic speed features.

Fig. 7. BCNN performance under different data collection intervals.

Table 7 Detection performance for BCNN with different data collection intervals.

Data collection
intervals (s)
ACC DR FAR Aleatoric
uncertainty
Epistemic
uncertainty
20 s 0.9254 0.9001 0.0928 0.0583 0.0183
40 s 0.8433 0.8049 0.3955 0.0902 0.0229
60 s 0.7909 0.7456 0.5083 0.1153 0.0232
80 s 0.7549 0.6985 0.4822 0.1551 0.0215

CRediT authorship contribution statement

Genwang Liu: Conceptualization, Data curation, Methodology, Formal analysis, Writing – original draft, Writing – review & editing. Haolin Jin: Data curation, Methodology, Formal analysis. Jiaze Li: Data curation, Methodology, Formal analysis. Xianbiao Hu: Conceptualization, Writing – original draft, Writing – review & editing. Jian Li: Conceptualization, Data curation, Methodology, Formal analysis, Writing – original draft, Writing – review & editing. All authors reviewed the results and approved the final version of the manuscript.

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

The authors do not have permission to share data.

Acknowledgment

This research is supported by the National Key R&D Program of China under Grant No. 2018YFB1601100.

Appendix A

Recall that the posterior distribution p(ω|D) is approximated by the tractable variational distribution qθ(ω) indexed by a variational parameter θ. According to the definition of variance, the variance of the variational predictive distribution *q̂θ* (y*|x*) can be given by:

$$Var{q{\sim}}(\mathbf{y}^) = E{q{\sim}(\mathbf{y}^|\mathbf{x}^)}[\mathbf{y}^\mathbf{y}^{T}] - E{q{\sim}(\mathbf{y}^|\mathbf{x}^)}[\mathbf{y}^]E{q{\sim}(\mathbf{y}^|\mathbf{x}^)}[\mathbf{y}^*]^T$$ (A.1)

From the definition of Eq ̂θ (y* |x* )[y*] and the Fubini theorem, it is intuitive to derive:

] can be derived as:

$$\begin{split} E{q{\theta}^{}(y^{}|x^{})}[y^{}] &= \int y^{}q_{\theta}^{}(y^{}|x^{})dy^{} \ &= \int y^{}\int{\Omega} p(y^{}|x^{},\omega)q{\theta}^{}(\omega)d\omega \ &= \int_{\Omega} \int y^{}p(y^{}|x^{},\omega)dy^{}q_{\theta}^{}(\omega)d\omega \ &= \int{\Omega} E{p(y^{}|x^{},\omega)}(y^{})q_{\theta}^{}(\omega)d\omega \end{split} \tag{A.2}$$

$$E{q{\widehat{\boldsymbol{\theta}}}(\mathbf{y}^|\mathbf{x}^)}[\boldsymbol{y}^*\boldsymbol{y}^{T}] = \int \boldsymbol{y}^\boldsymbol{y}^{T}q_{\widehat{\boldsymbol{\theta}}}(\boldsymbol{y}^|\mathbf{x}^)d\boldsymbol{y}^$$

(y* |x* )[y*y*T

Similarly, Eq

$$= \int y^* y^{T} \int_{\Omega} p(y^ | x^, \omega) q_{\widehat{\theta}}(\omega) d\omega dy^$$

$$= \int{\Omega} \int y^* y^{T} p(y^ | x^, \omega) dy^ q{\widehat{\theta}}(\omega) d\omega$$

$$= \int{\Omega} E{p(y^* | x^, \omega)} [y^ y^{*T}] q_{\widehat{\theta}}(\omega) d\omega$$

$$= \int{\Omega} {V{PP}, \dots, [y^] + E_{PP}, \dots, [y^] }{PP} q{\widehat{\theta}}(\omega) d\omega$$

= Varp(y* |x* ,ω)[y* ] + Ep(y* |x* ,ω)[y* ]Ep(y* |x* ,ω) y*T]}*q̂θ* (ω)dω (A.3)

While y is a binary variable, it can be deduced:

$$Var{p(y^|x^,\omega)}[y^*] = E{p(y^|x^,\omega)}[y^*y^{T}] - E_{p(y^|x^,\omega)}[y^] E_{p(y^|x^,\omega)}[y^{*T}]$$

$$= E{p(y^|x^,\omega)}[diag(y^*)] - E{p(y^|x^,\omega)}[y^] E_{p(y^|x^*,\omega)}[y^{*T}]$$ (A.4)

where diag([y*]) is a diagonal matrix with elements of the vector y*.

Hence, from Eq. (14) it can be deduced that:

$$\begin{split} E{q{\theta}(y^|x^,\omega)} \big[ y^* y^{T} \big] - E{q{\theta}(y^|x^,\omega)} \big[ y^ \big] E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big] q{\theta}(\omega) d\omega - E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big] \ = \int{\Omega} \Big{ Var{p(y^|x^,\omega)} \big[ y^* \big] + E{p(y^|x^,\omega)} \big[ y^* \big] E{p(y^|x^,\omega)} \big[ y^* \big] \Big} q{\theta}(\omega) d\omega - E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big] \ = \int{\Omega} Var{p(y^|x^,\omega)} \big[ y^* \big] q{\theta}(\omega) d\omega + \int{\Omega} \Big{ E{p(y^|x^,\omega)} \big[ y^* \big] E{p(y^|x^,\omega)} \big[ y^{T} \big] - E{q{\theta}(y^|x^,\omega)} \big[ y^ \big] E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} q{\theta}(\omega) d\omega \ = \int{\Omega} \Big( E{p(y^|x^,\omega)} \big[ diag(y^*) \big] - E{p(y^|x^,\omega)} \big[ y^* \big] E{p(y^|x^,\omega)} \big[ y^{*T} \big] \Big) q{\theta}(\omega) d\omega + \int{\Omega} \Big{ E{p(y^|x^,\omega)} \big[ y^* \big] E{p(y^|x^,\omega)} \big[ y^* \big] - E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} q{\theta}(\omega) d\omega + \int{\Omega} \Big{ E{p(y^|x^,\omega)} \big[ y^* \big] E{p(y^|x^,\omega)} \big[ y^* \big] - E{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \big[ y^* \big] \Big} e{q{\theta}(y^|x^,\omega)} \Big} e{q{\theta}(y^|x^,\omega)} \Big} e{q{\theta}(y^|x^,\omega)} \Big} e{q{\theta}(y^|x^,\omega)} \Big} e{q{\theta}(y^|x^,\omega)} \Big} e{q_{\theta}($$

References