entry detection approach based on the idea of counterfactual
explanations, which considers anomalous entry detection as
a task of providing interpretations to the detected anomalous
sequences. Third, the experimental results on three datasets
show that CFDet can detect anomalous sequences as well as
fine-grained anomalous entries with high accuracy.
II. RELATED WORK
Anomaly Detection in Sequential Data. As sequential data
become more and more ubiquitous, such as time series, video
frames, or event data, sequential anomaly detection plays an
important role in a wide spectrum of application scenarios
[11, 12, 13, 14]. Currently, due to a limited number of
anomalies, many unsupervised or one-class deep learning ap-
proaches are proposed to detect anomalous sequences by iden-
tifying the differences between normal and anomalous patterns
[1, 2, 3, 15]. A typical idea is to make use of recurrent neural
networks (RNNs) to capture the normal patterns from normal
sequences. Then, an anomalous sequence can be detected with
deviate patterns [1, 3]. For example, DeepLog [1] is trained
to predict the log entry by an RNN model based on a large
number of normal sequences so that RNN is able to capture
the normal patterns of sequences. The anomalous sequence can
then be detected when the RNN cannot correctly predict the
log entries, meaning the sequence does not follow the normal
patterns. However, the majority of approaches proposed so far
only focus on detecting the anomalous sequences and cannot
point out fine-grained subsequences or entries in the sequences
that actually lead to the anomalous outcomes.
Interpretable Anomaly Detection. Interpretability in ma-
chine learning is crucial for high-stakes decisions and trou-
bleshooting [8]. Interpretable machine learning techniques can
be categorized into two types, intrinsic interpretability and
post-hoc interpretability [16]. Intrinsic interpretability indi-
cates self-explanatory models that achieve interpretability di-
rectly based on their structures, while post-hoc interpretability
means the interpretability is achieved by applying another
model to provide explanations. There are two typical ap-
proaches to achieve the post-hoc interpretability, perturbation-
based and gradient-based approaches. The perturbation-based
approaches find the important features based on their impact
on the decision outcome by perturbation functions, such as
LIME and SHAP [17, 18], while the gradient-based ap-
proaches identify the important features based on the gradient
magnitudes, such as Grad-CAM and Integrated Gradients
[19, 20]. Many sequential anomaly detection models are
deployed on safety-critical systems. Hence, once anomalous
behaviors are detected, understanding them is imperative for
the domain users to locate the problems.
Only a few studies target interpretable anomaly detection
[21, 22]. To achieve intrinsic interpretation, the explainable
deep one-class classification model [22] provides intrinsic
interpretability for anomaly detection on image data but
cannot identify the discrete anomalous entries in sequences.
Meanwhile, the attention mechanism, which also provide
intrinsic interpretation based on the attention weights, is also
adopted fdetecting anomalous events from sequential data
[21]. However, the attention scores derived in the proposed
approach indicate the contributions to predicting the next
event in the sequence and are not strictly related to the
anomalous outcome. Some studies also achieve the post-hoc
interpretation based on the perturbation-based or gradient-
based interpretation approaches. Research in [23] develops
interpretable autoencoder models to identify features leading
to high reconstruction errors using Shapley values. Similarly,
research in [24] adopts variational autoencoder as the anomaly
detection model and identifies important features based on
the gradient values. OmniAnomaly achieves the interpretable
anomaly detection for multivariate time series data by a neural
network combining GRU and VAE, where the interpretation
is achieved based on the reconstruction probability of each
dimension of input data [25]. In this work, we target on
detecting anomalies in discrete sequence data, it is hard to
leverage the gradient-based approaches to achieve interpre-
tation. We leverage the idea of counterfactual interpretation
to achieve fine-grained anomaly detection, which provides
human-understandable post-hoc interpretations to anomalous
sequence detection.
III. FRAMEWORK
A. Overview
We denote a sequence with length Las S={el}L
l=1
where elindicates the l-th entry. We use e+and e−to
denote normal and anomalous entries respectively. In this
work, we assume that no labeled anomalous sequences/entries
are available as training signals. Formally, given a set of
normal sequences P={S+
n}N
n=1 and another set of unlabeled
sequences U={Sm}M
m=1 with a mixture of normal and
anomalous sequences, i.e., U=U+∪U−, we aim at detecting
the anomalous sequences in Uas well as their corresponding
anomalous entries.
We propose a two-phase framework called CFDet, as shown
in Figure 1. We first adopt the Deep SVDD approach to derive
an anomalous sequence detector f(·)based on the normal
sequence set P. Specifically, Deep SVDD is to minimize the
volume of a data-enclosing hypersphere in a latent space with
a center point cbased on P. Therefore, the anomalies can be
detected with a large distance to the center. Then, we deploy
the detector f(·)to classify the sequences in the unlabeled set
Uinto a subset of anomalous sequences ˜
U−and a subset of
normal sequences ˜
U+. For each detected anomalous sequence
set Z∈˜
U−, we further identify the fine-grained anomalous
entries. We propose a novel self-supervised learning approach
based on the idea of counterfactual explanation to train an
anomalous entry detector g(·). Then, we are able to identify
the anomalous entries from the anomalous sequences.
The Key Idea of Anomalous Entry Detection. Given a
detected anomalous sequence Z, we denote the subsequence
consisting of only anomalous entries in Zas Z−. Formally
we have
Z−=AZ, (1)