Next Article in Journal
Skew Convolutional Codes
Next Article in Special Issue
Modeling Spectral Properties in Stationary Processes of Varying Dimensions with Applications to Brain Local Field Potential Signals
Previous Article in Journal
Data-Driven Model Reduction for Stochastic Burgers Equations
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Functional Kernel Density Estimation: Point and Fourier Approaches to Time Series Anomaly Detection

1
Department of Mathematics, University of California, Los Angeles, CA 90024, USA
2
Global Aviation Data Management, International Air Transport Association (IATA), Montréal, QC H2Y 1C6, Canada
3
Department of Decision Sciences, HEC Montréal, Montréal, QC H2Y 1C6, Canada
*
Author to whom correspondence should be addressed.
Entropy 2020, 22(12), 1363; https://doi.org/10.3390/e22121363
Submission received: 16 November 2020 / Accepted: 27 November 2020 / Published: 30 November 2020
(This article belongs to the Special Issue Time Series Modelling)

Abstract

:
We present an unsupervised method to detect anomalous time series among a collection of time series. To do so, we extend traditional Kernel Density Estimation for estimating probability distributions in Euclidean space to Hilbert spaces. The estimated probability densities we derive can be obtained formally through treating each series as a point in a Hilbert space, placing a kernel at those points, and summing the kernels (a “point approach”), or through using Kernel Density Estimation to approximate the distributions of Fourier mode coefficients to infer a probability density (a “Fourier approach”). We refer to these approaches as Functional Kernel Density Estimation for Anomaly Detection as they both yield functionals that can score a time series for how anomalous it is. Both methods naturally handle missing data and apply to a variety of settings, performing well when compared with an outlyingness score derived from a boxplot method for functional data, with a Principal Component Analysis approach for functional data, and with the Functional Isolation Forest method. We illustrate the use of the proposed methods with aviation safety report data from the International Air Transport Association (IATA).

1. Introduction

Being able to detect anomalies has many applications, including in the fields of medicine and healthcare management [1,2]; in data acquisition, such as filtering out anomalous readings [3]; in computer security [4]; in media monitoring [5]; and many in the realm of public safety such as identifying thermal anomalies that may precede earthquakes [6], identifying potential safety issues in bridges over time [7], detecting anomalous conditions for trains [8], system level anomaly detection among different air fleets [9], and identifying which conditions pose increased risk in aviation [10]. Given a dataset, anomaly detection is about identifying individual data that are quantitatively different from the majority of other members of the dataset. Anomalous data can come in a variety of forms such as an abnormal sequence of medical events [11] and finding aberrant trajectories of pantograph-caternary systems [12]. In our context, we look for time series of aviation safety incident frequencies for fleets of aircrafts that differ substantially from the rest. By identifying the aircraft types or airports that have significant different patterns of frequencies of specific incidents, our model can provide insights on the potential risk profile for each aircraft type or airport and highlight areas of focus for human analysts to perform further investigations.
Identifying anomalous time series can be divided into different types of anomalous behaviour [13] such as: point anomalies (a single reading is off), collective anomalies (a portion of a time series that reflects an abnormality), or contextual anomalies (when a time series behaves very differently from most others). Identifying anomalous time series from a collection of time series, as in our problem, can be done through dimensionality reduction (choosing representative statistics of the series, applying PCA, and identifying points that are distant from the rest) and through studying dissimilarity between curves (a variant of classical clustering like kmeans) [14]. After reducing the dimension, some authors have used entropy-based methods, instead, to detect anomalies [15]. Archetypoid analysis [16] is another method, which selects time series as archetypeoids for the dataset and identifies anomalies as those not well represented by the archetypeoids. Very recently, authors have used a generalization of Isolation Forests to identify anomalies [17] and have examined the Fourier spectrum of time series and looked at shifting frequency anomalies [18]. Our approach, like Functional Isolation Forest, is geometric in flavor and we employ Kernel Density Estimation and analysis of Fourier modes to detect anomalies.
In this manuscript, we present two alternative means of anomaly detection based on Kernel Density Estimation (KDE) [19]. We use two approaches: the first and simplest considers each time series as element of a Hilbert space H and employs KDE, treating each time series in H as if it were a point in one-dimensional Euclidean space, placing a Gaussian kernel at each curve with scale parameter ξ > 0 . We refer to this as the point approach to Functional KDE Anomaly Detection, because each curve in H is treated as a point. This approach then formally generates a proxy for the “probability density” over H . Anomalous series are associated with smaller values of this density. This is distinct from considering a single time series as collection of points sampled from a distribution and using KDE upon points in the time series as has been done before [20]. This is a very simple, and seemingly effective method, with ξ chosen as a hyper-parameter. We also present a Fourier approach, which approximates a probability density over H through estimating empirical distributions for each Fourier mode with KDE. This allows us to estimate the likelihood of a given curve. Curves with lower likelihoods are more anomalous. Both methods naturally handle missing data, without interpolating. In real flight operations, sometimes it is not possible to capture and record complete information because incident data is documented from voluntary reporting, which may result in incomplete datasets. Therefore, model robustness to the impact of missing data is crucial to derive the correct understanding, which may save human lives and prevent damaged aircrafts.
The rest of our paper is organized as follows: in Section 2, we present the details and implementation of our methods; in Section 3, we conduct some experiments to investigate the strengths and weaknesses of the approaches and compare them with three other methods (Functional Isolation Forest available in Python and the PCA and functional boxplot methods available in R); following this, we apply our techniques to data from the International Air Transport Association (IATA); finally, in Section 4, we discuss our results and present some recommendations.

2. Functional Kernel Density Estimation

2.1. Review of Kernel Density Estimation

We first recall KDE over R d , d N . Given a sample S R d of n points from a distribution with probability density function (pdf) f : R d [ 0 , ) with R d f ( x ) d x = 1 , KDE provides an empirical estimate for the probability density given by [19]
f ˜ ( x ) = 1 n y S | Ξ | 1 / 2 K ( Ξ 1 / 2 ( x y ) )
where Ξ is a symmetric, positive definite matrix known as the bandwidth matrix and K is a Kernel function. We choose the form of a multivariate Gaussian function so
f ˜ ( x ) = 1 n y S e 1 2 ( x y ) T Ξ 1 ( x y ) ( 2 π ) d / 2 | Ξ | 1 / 2 , x R d
and we choose [19]
Ξ = α diag ( σ ˜ 1 , σ ˜ 2 , , σ ˜ d )
where σ ˜ i is the sample standard deviation of the i th -coordinate of the sample points in S and
α = 4 ( d + 2 ) n 1 / ( d + 4 ) .
We used tilde (~) rather than hat ( ^ ) to denote estimators as later on we use the hats for Fourier Transform modes and wish to avoid ambiguities. In general tildes will be used for estimates derived from samples.

2.2. Setup, Assumptions, and Notation

The proposed methods are applicable to situations where we look for anomalous time-series relative to the sample we have. We study time series, which we consider more abstractly as being discrete samples from curves of form x ( t ) where x : [ 0 , T ] R for some T > 0 . The space of all such curves is quite general and we limit the scope to Hilbert spaces on [ 0 , T ] . For example, we may consider spaces H = L 2 ( [ 0 , T ] ) or H 1 ( [ 0 , T ] ) , the space of square integrable functions or the space of square integrable functions whose derivative is also square integrable, respectively. Within our Hilbert space, H , there is an inner product ( · , · ) : H 2 C and an induced norm, | | · | | : H [ 0 , ) where | | x | | = ( x , x ) 1 / 2 . With this norm, we can define distances between elements of H .
Observations are made at p different times, t 0 , t 1 , …, t p 1 where t i = i Δ with Δ = T / p and i = 0 , 1 , , p 1 . We also have t p = T , but this time is not included in the data. Although observations are made at these times, some time series could have missing values. When a value is missing, we will say its "value" is Not-a-Number (NaN). While the set of observation points are uniformly spaced, the times at which a given time series has non-NaN values may not be.
We denote by n the number of time series observed, given to us as a sample of form X = { { ( t j ( k ) , x j ( k ) ) } j = 0 P k 1 } k = 1 n , where k = 1 , , n indexes the time series, P k is the number of available (i.e., non-NaN) points for time series k, 0 t 0 ( k ) < t 1 ( k ) < < t P k 1 ( k ) < T are the times for series k, with corresponding non-NaN values x 0 ( k ) , x 1 ( k ) , , x P k 1 ( k ) R .

2.3. Preprocessing

The methods often performed better if we normalized the data by a standard centering and rescaling. At each fixed observation time, the values of the time series were shifted to have mean zero and then rescaled to have unit variance. When the variance was already zero, the values were mapped to 0. Further remarks are given in Section 4.
Even though our methods do not assume stationary or other similar properties, applying transformations to the data before applying them can be done. For example, we may wish to make the series stationary, or to extract some characteristics (e.g., the cyclical part, or the seasonal part). This can be useful if we want to focus on finding specific types of anomalies.

2.4. Point Approach to Functional KDE Anomaly Detection

Our first method can be summarized as follows: treat each x H as a point in one dimension. Select a value for the KDE scale hyper-parameter ξ > 0 , and define a score functional over H by
S P [ a ] = x X e | | x a | | 2 2 ξ 2 , a H ,
which, at least formally, can be thought of as a proxy to a “probability density” functional. More rigorously, one should consider measures on Hilbert spaces [21]. Assuming anomalous curves are truly rare, they should be very distant from the majority of curves and S P [ · ] should be smaller at such curves. See Figure 1 for a conceptual illustration. We find that choosing ξ to be the mean of { | | a | | } a X to work well; another natural choice would be the median. These choices are natural because they represent a natural size/scale for the series. This approach can also be interpreted from a Fourier perspective which we remark on in Appendix A.
This method can be implemented with the following steps:
  • Choose ξ > 0 .
  • For each x X , compute its score from (5) where, for example, in the case of H = L 2 ( [ 0 , T ] ) ,
    | | x a | | 2 = 0 T | ( x ( t ) a ( t ) | 2 d t .
  • Identify anomalies as curves with the lowest score.
The integral in (6), even with some data points missing, can be computed as below:
  • To compute I = 0 T | ( x ( t ) a ( t ) | 2 d t , determine all t-values where both x and a are not NaN. Call these t 0 * , t 1 * , , t r 1 * .
  • Define t r * = T t r 1 * + t 0 * , x r * = x 0 * and y r * = y 0 * .
  • Estimate the integral as
    I 1 2 m = 0 r 1 ( t m + 1 * t m * ) ( | x ( t m * ) y ( t m * ) | 2 + | x ( t m + 1 * ) y ( t m + 1 * ) | 2 ) .
This is a second-order accurate (trapezoidal) approximation to I where we have extended the signal periodically at the endpoint. This ensures that in a pathological case such as there being only a single point of observation for the integrand with value v, then the inner product evaluates to T v .

2.5. Fourier Approach to Functional KDE Anomaly Detection

We first observe that most Hilbert spaces of interest such as L 2 ( [ 0 , T ] ) have a countable, orthogonal basis B = { exp ( 2 π i k t / T ) | k Z } . By considering time series as being represented by these basis vectors, we can more accurately consider a true probability density over H . In practice, we pick L N large and represent a H by
a ( t ) j = L L a ^ k e 2 π i k t / T .
Then, up to a Fourier mode of size L, we can define a probability density at a H by k = L L ζ k ( a ^ k ) where ζ k is a pdf over C for mode k.
Our time series are discrete with finitely many points so we consider a Non-Uniform Discrete Fourier Transform (NUDFT). To estimate the probability density over H at a, we:
  • Compute p * = min { P 1 , P 2 , , P n } .
  • Compute the Discrete Fourier coefficients
    x ^ j ( k ) = 1 P k m = 0 P k 1 exp ( 2 π i j t m / T ) x ( k ) ( t m )
    for each k = 1 , , n and for j = 0 , 1 , , p * 1 .
  • For each 0 j p * 1 , use KDE to estimate the pdf over C for x ^ j , by using KDE (Equations (2)–(4)) for R or R 2 when the coefficients are all purely real/imaginary or contain a mix of real and imaginary components, respectively. Call the empirical distribution ζ ˜ j for each j .
  • For any a H define an estimated pdf via
    ρ F [ a ] = j = 0 p * 1 ζ j ( a ^ j ) .
  • Let the score of a H be
    S F [ a ] = log ρ F [ a ] .
  • Identify anomalies in X as those whose scores given by (8) are smallest.
Due to missing data, this method does lose some information since the higher Fourier modes necessary to fully reconstruct a given time series may be discarded. Additionally, as the missing data may result in non-uniform sampling, the typical aliasing of the Discrete Fourier Transform does not take effect. In general for one of the series x ( k ) , we will not have x ^ P k j ( k ) = x ^ j ( k ) ¯ , where the bar denotes complex conjugation. See the remark on aliasing in Appendix B.
In multiplying the pdfs in each mode to estimate the probability density at a point in the Hilbert space, we have implicitly assumed the modes are independent. It may seem intuitive to decouple the modes by applying a Mahalanobis transformation upon the modes prior to KDE, but this results in poor outcomes. Thus, this implicit independence seems to work well in practice, without adjustments.
A Discrete Fourier transform of a signal x 0 , x 1 , , x P S 1 measured at times t ˜ 0 , t ˜ 1 , , t ˜ P S 1 is a representation in a new basis { e ( k ) } k = 0 P S 1 where e j ( k ) = e 2 π i k t ˜ j / T for j = 0 , , P S 1 . In general, such a basis of vectors for a NUDFT will not be orthogonal [22]. However, if m = p P S p and the t ˜ ’s are a subset of a uniformly spaced set of times, we can show that the vectors are almost orthogonal with a cosine similarity of size O ( m / p ) . Details appear in Appendix C. This orthogonality is not strictly necessary to run the method, but doing so allows a deeper justification of multiplying the pdfs in each mode if the Fourier modes are truly independent because the Discrete Fourier Transform is then approximately a projection onto an orthogonal basis of modes, each of which are independent.

3. Method Performance

We begin by illustrating the performance of our methods for some synthetic data and compare Functional KDE to other methods. The first one is the Functional Boxplot (FB) [23]. The fbplot function in the R package fda is used to obtain a center outward ordering of the time series based on the band depth concept which is a generalization to functional data of the univariate data depth concept [24]. The idea is that anomalous curves will be the ones with the largest ranks, that is, the ones that are farther away from the center. The second method is the recently proposed Functional Isolation Forest (FIF) [17], which is also depth-based and assigns a score to a curve, with higher values indicating that it is more anomalous. We used the code provided for FIF directly on GitHub [25] with the default settings given. The third is the method proposed in [26] and implemented in the R package anomalousACM [27]. This method works in three steps: (i) extract features (e.g., mean, variance, trend) from the time-series; (ii) use Principal Component Analysis (PCA) to identify patterns; (iii) Use a two dimensional outlier detection algorithm with the first two principal components as inputs. It will be referenced as the PCA method in what follows After testing them on synthetic data, we apply our techniques to real data to identify anomalies in time series for aviation events.
The methods against which we compare our methods did not have standard means of managing missing entries. For these methods, we replace missing data (NaN) in a series using Python’s default interpolation scheme. For the methods proposed in this paper, we do not have to use imputation.

3.1. Synthetic Data

We apply the Point and Fourier Approaches to Functional KDE, Functional Boxplot, and Functional Isolation Forest to the two scenarios described below.
Scenario 1: we define a base curve
x 0 ( t ) = a 0 ( 1 + tanh ( b 0 ( t t 0 ) ) ) + c 0 sin ( ω 0 t / T ) ,
with a 0 = 5 , b 0 = 2 , T = 50 , t 0 = T / 2 = 25 , and ω 0 = 2 π . Ordinary curves are generated via
x 0 ( t ) + ϵ ( t ) ,
where ϵ ( t ) represents Gaussian white noise at every t with mean μ g = 0 and standard deviation σ g = 0.05 . We then consider a series of 7 anomalous curves:
  • C 1 ( t ) = x 0 ( t ) 1 + r 1 ( t t * ) 2 1 + ( t t 0 ) 2 Θ ( t t 0 ) + ϵ ( t ) , where r 1 = 0.05 and Θ denotes the Heaviside function. Thus, the function is scaled up after t 0 .
  • C 2 ( t ) = x 0 ( t ) + 1 + r 2 Θ ( t t 0 ) ϵ ( t ) , where r 2 = 3 . Thus, the noise is larger after t 0 .
  • C 3 ( t ) = x 0 ( t ) r 3 ( t t 0 ) Θ ( t t 0 ) + ϵ ( t ) , where r 3 = 0.05 . Thus, there is a decreasing component added to the function after t 0 .
  • C 4 ( t ) = 2 a 0 Θ ( t t 0 ) + c 0 sin ( ω 0 t / T ) + ϵ ( t ) , i.e., the tanh is replaced by a discontinuous function.
  • C 5 ( t ) = x 0 ( t ) + E ( t ) , where E ( t ) represents an exponential random variable at every t with mean 0.05 .
  • C 6 ( t ) = a 0 ( 1 + tanh ( 2 b 0 ( t t 0 ) ) ) + c 0 sin ( ω 0 t / T ) + ϵ ( t ) , which has a slightly steeper transition rate than the base curve.
  • C 7 ( t ) = a 0 ( 1 + tanh ( b 0 ( t t 0 ) ) + c 0 sin ( ( 1 + r 7 t / T ) ω 0 t / T ) + ϵ ( t ) , where r 7 = 0.1 so the frequency increases with time.
Over 50 trials, we generate 70 time series, 63 normal curves, and 7 anomalous curves with each of C 1 through C 7 being used once. See Figure 2 for an illustration. We used a uniform mesh with 50 points, 0 , 1 , , 49 . Since we used a 9 : 1 ratio of regular to anomalous series, successful methods, after ranking curves in ascending order of “regular,” should rank anomalous curves as among the bottom 10 % . We can also determine the 95th percentile for the percentile rank of each curve, to give an estimate for how much of the data would need to be re-examined to capture such anomalies. These trials can also be done by dropping data points independently at random with a fixed probability to simulate missing data. We  ran sets of trials with 0 % and 10 % of drop probabilities. Results for the mean percentile rank and 95th percentile of the percentile ranks are presented in Table 1 and Table 2.
Scenario 2: we utilized the testing examples of Staerman et al. [17]. The data consist of 105 time series over [ 0 , 1 ] with 100 time points. There are 100 regular curves defined by x ( t ) = 30 ( 1 t ) q t q where q is equi-spaced in [ 1 , 1.4 ] –thus there is a large family of normal curves. Then, there are 5 anomalous curves:
  • D 1 ( t ) = 30 ( 1 t ) 1.2 t 1.2 + β χ [ 0.2 , 0.8 ] , where β is chosen from a Normal distribution with mean 0 and standard deviation 0.3 and χ I is the characteristic function of I (there is a jump discontinuity at 0.2 and 0.8 ).
  • D 2 ( t ) = 30 ( 1 t ) 1.6 t 1.6 , being anomalous in its magnitude.
  • D 3 ( t ) = 30 ( 1 t ) 1.2 t 1.2 + sin ( 2 π t ) .
  • D 4 ( t ) = 30 ( 1 t ) 1.2 t 1.2 + 2 χ { τ } , where τ = 0.7 is a single point.
  • D 5 ( t ) = 30 ( 1 t ) 1.2 t 1.2 + 1 2 sin ( 10 π t ) .
Each curve was sampled uniformly at 100 points. We did not drop any data points and, owing to the limited randomness, we only present the results of one trial. The results are presented in Table 3.
Our method is unsupervised and thus the distinction as to what constitutes an anomaly requires considering a curve’s score relative to the others and making a decision based upon this. This can involve human judgment. However, since our method returns a scalar score, we can also use a univariate outlier test on the score to formally test the hypothesis H 0 : There are no anomalies. The Rosner test [28] is such a test and is available in the R package EnvStats [29]. In Appendix D, by considering scenarios where anomalies are present or absent, we show the validity of this approach.

3.2. Aviation Safety Reports

We now consider how our methods behave in identifying anomalous time series for aviation safety events. A discussion on method performance is deferred to Section 4.
We were provided IATA data for safety-related events of different types on a month-by-month basis from 2018–2020 for different aircraft types and airports. Aircraft types were given IDs from 1 to 64 (not every ID in the range was included). We were also given separate data pertaining to flight frequency in order to normalize and obtain event rates (cases per 1000 flights). Events of interest could include phenomena occurring during a flight such as turbulence or striking birds, or physical problems such as a damaged engine. We study two events: A and B. Event Type A is a contributing factor for one specific type of accident; Event Type B is the aircraft defense against that type of accident. To illustrate our method while preserving the confidentiality of the data, we do not state what A and B represent.
We plot histograms for the scores of Type A and B Events in Figure 3. These histograms suggest that, for events A and B, anomalous curves could be those with scores below 10 for the Point approach. Then, we consider curves anomalous by the Fourier method if they have scores below 60 for event A and 30 for event B. As the method is unsupervised, the notion of where to draw the line of being anomalous is somewhat subjective. The idea here is to raise a flag so that experts can investigate the anomalous cases more closely. The aircraft types identified as anomalous for both methods are presented in Table 4. It appears for these data, the curves deemed anomalous by the Fourier method are a subset of the curves deemed anomalous by the Point method. In Figure 4, we plot the anomalous curves (with markers) along with the normal curves (dotted lines) for the fleet IDs that were common to both approaches.

4. Discussion and Conclusions

4.1. Method Performance

From Table 1 and Table 2 with regards to Scenario 1, the Point method and FB are superior. They correctly classify C 1 C 3 and C 7 as anomalous. The Point and PCA methods significantly outperform the other methods in the more difficult C 4 C 6 curves. With these data, the Point method generally performs better without normalization. Generally all methods failed to identify the replacement of Gaussian white noise with exponential noise ( C 5 ) as anomalous, although the un-normalized Point approach succeeded. Additionally, all methods considered, except PCA, had difficulty identifying the discontinuous replacement of the hyperbolic tangent ( C 4 ) and a slightly steeper hyperbolic tangent ( C 6 ). The PCA method was not as good as the others for identifying the noise increases ( C 2 ) and the frequency increase with time ( C 7 ). This suggests that not all methods are effective at detecting the same types of anomalies and that they may be complementary.
From Table 3 for Scenario 2, the Fourier approach with normalized data, FIF on un-normalized data, and PCA classify equally correctly. Data can always be normalized and this is therefore not a problem for the Fourier method. In this example, the Point approach fares better with normalization. However, this method and the FB method are not as effective as the FIF, PCA, and Fourier methods.
From our experiments, when there was a large family of curves as with Scenario 2, the Fourier method performed better at detecting anomalies, especially when provided normalized data. But when the family of curves were all close to the same, except for noise, the Point method was better, with or without normalization. Providing more theoretical understanding as to whether these are general phenomena is left for future work.

4.2. Aviation Safety Data

From Figure 4, it appears the methods can detect different sorts of anomalies. In the case of Type A events, the anomalous curves appear to have anomalously large values at an isolated point or over small range of values. The anomalies in Type B events are more interesting and subtle. Even some of the normal curves have sizeable event frequencies, sometimes even exceeding the anomalous curves. But on the average it seems the anomalous curves are higher. In the case of curve 9, the reason it is deemed anomalous is not immediately intuitive. Whether such differences are of a concern to safety would require follow-up from safety inspectors.
To prevent aviation accidents, identifying the potential hazards and risks before they evolve into accidents is the key to proactive safety management. While collecting and analyzing data manually is a time-consuming process, especially on a global scale, the risk identification process may remain reactive process if there is not an automated process. The application of the anomaly detection will enable proactive data-driven risk identification in global aviation safety, by continuously monitoring aviation safety data across multiple criteria (e.g., airport, aircraft type and date), then automatically raising a flag when the model detects any anomalous patterns.
The proposed model shows potential value in automatically detecting potential risk areas with robustness from missing data; however, the interpretation of the model still requires future study. As safety risk is an outcome of complex interactions between multiple factors, including human, machine, environment, and other hidden factors, understanding the full context of such risk requires in-depth investigation and validation from multiple experts. While the model can identify some anomalous patterns, this does not take into consideration the interactions. For example, some aircraft fleets fly more frequently over certain pathways than others. Thus, some differences identified as anomalous due to aircraft type may actually stem from location. Therefore, there will always be a human layer between the model and the interpretation of the model.

4.3. Comments on the Models

There are various degrees of freedom the proposed methods allow for, which are worth noting. Firstly, the point method could be generalized to compute H 1 ( [ 0 , T ] ) , and higher Sobolev norms too, but that could lead to additional hyper-parameters in how heavily to weigh the derivative terms. With the Fourier approach, it may seem more appropriate to replace the NUDFT with a weighted combination of terms that more accurately reflects the non-uniform spacing, i.e., a Riemann Sum. Interestingly such an approach tends to make the results slightly worse, hence our choice to use the standard NUDFT.
We anticipate these methods perform well when the time series are sampled at regular intervals and a small portion of entries are missing. If the number of missing entries is very large, this makes inner products computed with the Point method less accurate (without additional interpolations) and the preprocessing of shifting and rescaling could result in poorer outcomes due to a limited sample size upon which to base the normalizations. For many applications, however, most data are present.

4.4. Future Work

We note that our proposed methods aim to identify anomalous time series relative to the sample taken. In general, even if all time series are sampled from the same distribution, due to low probability events, some time series could still be anomalous relative to the sample given. As such, our work has mostly been an empirical investigation of the methods; however, by adding further assumptions on the underlying distribution of time series, it could be possible to obtain a more theoretical basis for the method performance. This would be worth investigating, but is beyond our current work. Going hand-in-hand with this theory it would be interesting to investigate the optimal choice of ξ in the point approach, to understand how the Fourier modes being treated as independent works as effectively as it does, or to more rigorously establish classes of problems when the Point or Fourier approaches are superior.
In conclusion, we have presented two approaches to detecting anomalous time series using KDE to generate functionals to score a series for its degree of anomalousness. The methods handle missing data and perform well in comparison to other methods.   

Author Contributions

M.R.L. contributed to conceptualization, methodology, software, formal analysis, investigation, visualization, writing–original draft preparation, writing–review and editing. H.J. contributed to data curation, writing–original draft preparation, and writing–review and editing. D.L. contributed to methodology, funding acquisition, writing–original draft preparation, and writing–review and editing. All authors have read and agreed to the published version of the manuscript.

Funding

This research was supported by the Natural Sciences and Engineering Research Council of Canada (NSERC) and by Fondation HEC Montréal.

Acknowledgments

The authors wish to thank the Associate Editor and two reviewers for their interesting and constructive comments that helped prepare an improved version of the paper. The authors would like to express gratitude to Odile Marcotte for her seamless organization of the Tenth Montréal Industrial Problem Solving Workshop held virtually in 2020. The IATA workshop problem led to these ideas. The authors also thank IATA for providing data.

Conflicts of Interest

The authors declare no conflict of interest.

Appendix A. Fourier Perspective of the Point Method

From Parseval’s identity [31], we can also write the terms of (5) as
e | | x a | | 2 2 ξ 2 = e k Z | x ^ k a ^ k | 2 2 T ξ 2 ,
i.e., each kernel can be thought of as a Gaussian in C with constant variance in all directions. Unfortunately this thinking can only be true in spirit because such a series would not be in L 2 ( [ 0 , T ] ) as k Z | a ^ k | 2 would almost surely diverge.

Appendix B. Aliasing

Observe that if the real time series x 0 , x 1 , , x N 1 is observed at p equally spaced points t j = j Δ , Δ = T / p , j = 0 , , p 1 then for j = 1 , , p 1 :
x ^ p j = m = 0 p 1 e 2 π i t p j m Δ / T x m = m = 0 p 1 e 2 π i ( p j ) m Δ / T x m = m = 0 p 1 e 2 π i j m Δ / T x m = x ^ j ¯
where in getting from the first to second line we used exp ( 2 π i p m Δ / T ) = exp ( 2 π i m ) = 1 . On the other hand, if data are only observed at t ˜ 0 < t ˜ 1 < < t ˜ P S , a subset of the times t 0 , , t p with P S < p then t ˜ j is not, in general j Δ and the identity does not hold.

Appendix C. Approximate Orthogonality

Before our approximate orthogonality result, we first define the standard inner product for vectors over C N :
( x , y ) = j = 1 N x ¯ i y i .
Theorem A1
(Approximate Orthogonality). Let t j = j Δ for j = 0 , 1 , , p 1 where Δ = T / p for T > 0 . Let { t ˜ j } j = 0 P S 1 { t 0 , t 1 , , t p 1 } . Define m = p P S and define the basis vectors { e ( k ) = e 2 π i k t ˜ j / T , j = 0 , , P S | k = 0 , , P S } . Then
( e ( k ) , e ( k ) ) | e ( k ) | | e ( k ) | = 1 , k = k O ( m / p ) , k k .
In other words the cosine similarity of the two vectors is either 1 or O ( m / p ) .
Proof. 
We trivially note that | e ( k ) | = P S for any k. Next, if k = k then
( e ( k ) , e ( k ) ) | e ( k ) | | e ( k ) | = 1 P S j = 0 P S 1 1 = 1 .
Let us define the set B = { j | t j { t ˜ k | k = 0 , , P S } for j = 0 , , p } , i.e., it is a listing of all regular time values that have been lost in only observing at the t ˜ ’s. Note that | B | = m . Also let q = k k so that when k k :
( e ( k ) , e ( k ) ) | e ( k ) | | e ( k ) | = 1 P S j = 0 N S 1 exp ( 2 π i q t ˜ j / T ) = 1 P S j = 0 p 1 exp ( 2 π i q t j / T ) j B exp ( 2 π i q t j / T ) = 1 P S j B exp ( 2 π i q t j / T )
where in arriving at the final equality we used that the sum of e 2 π i q t j over j = 0 , , p 1 is 0 ( 1 + η + η 2 + + η p 1 = 0 if η p = 1 and η 1 ). As each term in the remaining sum is bounded by 1 and | B | = m , we have that
( e ( k ) , e ( k ) ) | e ( k ) | | e ( k ) | = O ( m / P S ) = O ( m / p ) .
 □

Appendix D. Rosner Test on the Scores

We briefly explore the capacity of our methods to test the hypothesis H 0 : There are no anomalies. The idea is to compute the scores from our methods, which are scalars, and use a univariate outlier test on them. In this experiment, we use Rosner test [28] with the R package EnvStats [29]. Specifically, we test H0 for each of the 50 trial datasets of Scenario 1 and report the proportion of time the null hypothesis is rejected at the α = 0.05 level. In this case, the proportion of rejection measures the power of the test and we wish to have the highest values possible. However, to verify the validity of the test, we also run the tests on the samples containing only the 63 normal curves. This time, we want the proportion of rejection to be close to the level α = 0.05 . The results, presented in Table A1, show that this method is working. Setting aside the un-normalized Fourier approach (Fourier-U) with 10% of missing data, the proportion of rejection varies between 0.02 and 0.08 when the data contain no anomalies, showing that the test is able to maintain its prescribed level. When the data contain anomalies, the power ranges between 0.98 and 1, showing that the anomalies are detected in almost all cases. The only exception is the Fourier-U method with 10% of missing data, which never rejects H 0 whether or not the data contain anomalies. But this is consistent with the fact that this method had a very poor performance in this case and was not able to detect the anomalies as seen in Table 1.
Table A1. Proportions of time the null hypothesis H 0 is rejected at the α = 0.05 level. See Table 1 caption of main manuscript for -N vs -U distinction.
Table A1. Proportions of time the null hypothesis H 0 is rejected at the α = 0.05 level. See Table 1 caption of main manuscript for -N vs -U distinction.
MethodLostAnomalies PresentH0 Reject Fraction
Point-N0%No0.04
Point-N0%Yes1
Point-U0%No0.08
Point-N0%Yes1
Fourier-N0%No0.08
Fourier-N0%Yes0.98
Fourier-U0%No0.02
Fourier-U0%Yes1
Point-N10%No0.04
Point-N10%Yes1
Point-U10%No0.08
Point-N10%Yes1
Fourier-N10%No0.06
Fourier-N10%Yes1
Fourier-U10%No0
Fourier-U10%Yes0

References

  1. Cleophas, T.J.; Zwinderman, A.H.; Cleophas-Allers, H.I. Machine Learning in Medicine; Springer: Berlin/Heidelberg, Germany, 2013; Volume 9. [Google Scholar]
  2. Howedi, A.; Lotfi, A.; Pourabdollah, A. An Entropy-Based Approach for Anomaly Detection in Activities of Daily Living in the Presence of a Visitor. Entropy 2020, 22, 845. [Google Scholar] [CrossRef]
  3. Chen, X.; Li, Z.; Wang, Y.; Tang, J.; Zhu, W.; Shi, C.; Wu, H. Anomaly detection and cleaning of highway elevation data from google earth using ensemble empirical mode decomposition. J. Transp. Eng. Part Syst. 2018, 144, 04018015. [Google Scholar] [CrossRef]
  4. Siboni, S.; Cohen, A. Anomaly Detection for Individual Sequences with Applications in Identifying Malicious Tools. Entropy 2020, 22, 649. [Google Scholar] [CrossRef]
  5. Bernikova, O.; Granichin, O.; Lemberg, D.; Redkin, O.; Volkovich, Z. Entropy-Based Approach for the Detection of Changes in Arabic Newspapers’ Content. Entropy 2020, 22, 441. [Google Scholar] [CrossRef] [Green Version]
  6. Saradjian, M.; Akhoondzadeh, M. Thermal anomalies detection before strong earthquakes (M > 6.0) using interquartile, wavelet and Kalman filter methods. Nat. Hazards Earth Syst. Sci. 2011, 11, 1099. [Google Scholar] [CrossRef]
  7. Xu, X.; Ren, Y.; Huang, Q.; Fan, Z.Y.; Tong, Z.J.; Chang, W.J.; Liu, B. Anomaly detection for large span bridges during operational phase using structural health monitoring data. Smart Mater. Struct. 2020, 29, 045029. [Google Scholar] [CrossRef]
  8. Holst, A.; Bohlin, M.; Ekman, J.; Sellin, O.; Lindström, B.; Larsen, S. Statistical anomaly detection for train fleets. AI Mag. 2013, 34, 33. [Google Scholar] [CrossRef] [Green Version]
  9. Das, S.; Matthews, B.L.; Lawrence, R. Fleet level anomaly detection of aviation safety data. In Proceedings of the 2011 IEEE Conference on Prognostics and Health Management, Montreal, QC, Canada, 20–23 June 2011; pp. 1–10. [Google Scholar]
  10. Ketabdari, M.; Giustozzi, F.; Crispino, M. Sensitivity analysis of influencing factors in probabilistic risk assessment for airports. Saf. Sci. 2018, 107, 173–187. [Google Scholar] [CrossRef]
  11. Huang, Z.; Lu, X.; Duan, H. Anomaly detection in clinical processes. In AMIA Annual Symposium Proceedings; American Medical Informatics Association: Bethesda, MD, USA, 2012; Volume 2012, p. 370. [Google Scholar]
  12. Aydin, I.; Karakose, M.; Akin, E. Anomaly detection using a modified kernel-based tracking in the pantograph–catenary system. Expert Syst. Appl. 2015, 42, 938–948. [Google Scholar] [CrossRef]
  13. Braei, M.; Wagner, S. Anomaly Detection in Univariate Time-series: A Survey on the State-of-the-Art. arXiv 2020, arXiv:2004.00433. [Google Scholar]
  14. Blázquez-García, A.; Conde, A.; Mori, U.; Lozano, J.A. A review on outlier/anomaly detection in time series data. arXiv 2020, arXiv:2002.04236. [Google Scholar]
  15. Martos, G.; Hernández, N.; Muñoz, A.; Moguerza, J.M. Entropy measures for stochastic processes with applications in functional anomaly detection. Entropy 2018, 20, 33. [Google Scholar] [CrossRef] [Green Version]
  16. Vinue, G.; Epifanio, I. Robust archetypoids for anomaly detection in big functional data. In Advances in Data Analysis and Classification; Springer: Berlin/Heidelberg, Germany, 2020; pp. 1–26. [Google Scholar]
  17. Staerman, G.; Mozharovskyi, P.; Clémençon, S.; d’Alché-Buc, F. Functional Isolation Forest. Proc. Mach. Learn. Res. 2019, 101, 332–347. [Google Scholar]
  18. Jackson, A.C.; Lacey, S. Seasonality and Anomaly Detection in Rare Data Using the Discrete Fourier Transformation. In Proceedings of the 2019 First International Conference on Digital Data Processing (DDP), London, UK, 15–17 November 2019; pp. 13–17. [Google Scholar]
  19. Hyndman, R.L.; Zhang, X.; King, M.L. Bandwidth selection for multivariate kernel density estimation using mcmc. In Proceedings of the Econometric Society 2004 Australasian Meetings, Melbourne, Australia, 7–9 July 2004. number 120. [Google Scholar]
  20. Guo, Y.; Xu, Q.; Li, P.; Sbert, M.; Yang, Y. Trajectory shape analysis and anomaly detection utilizing information theory tools. Entropy 2017, 19, 323. [Google Scholar] [CrossRef]
  21. Maniglia, S.; Rhandi, A. Gaussian measures on separable Hilbert spaces and applications. Quaderni di Matematica. 2004. Available online: http://siba-ese.unisalento.it/index.php/quadmat/issue/view/775 (accessed on 30 November 2020).
  22. Mobli, M.; Hoch, J.C. Nonuniform sampling and non-Fourier signal processing methods in multidimensional NMR. Prog. Nucl. Magn. Reson. Spectrosc. 2014, 83, 21–41. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  23. Sun, Y.; Genton, M.G. Functional boxplots. J. Comput. Graph. Stat. 2011, 20, 316–334. [Google Scholar] [CrossRef]
  24. Ramsay, J.O.; Graves, S.; Hooker, G. fda: Functional Data Analysis; R Package Version 5.1.5.1. Available online: https://cran.r-project.org/web/packages/fda/index.html (accessed on 30 November 2020).
  25. Staerman, G.; Mozharovskyi, P.; Clémençon, S.; d’Alché-Buc, F. FIF: Functional Isolation Forest. Available online: https://github.com/GuillaumeStaermanML/FIF (accessed on 15 September 2020).
  26. Hyndman, R.J.; Wang, E.; Laptev, N. Large-scale unusual time series detection. In Proceedings of the 2015 IEEE international conference on data mining workshop (ICDMW), Atlantic City, NJ, USA, 14–17 November 2015; pp. 1616–1619. [Google Scholar]
  27. Hyndman, R.J.; Wang, E.; Laptev, N. anomalousACM: Unusual Time Series Detection; R Package Version 0.1.0. Available online: https://github.com/robjhyndman/anomalous-acm (accessed on 30 November 2020).
  28. Rosner, B. Percentage points for a generalized ESD many-outlier procedure. Technometrics 1983, 25, 165–172. [Google Scholar] [CrossRef]
  29. Millard, S.P. EnvStats: An R Package for Environmental Statistics; Springer: New York, NY, USA, 2013. [Google Scholar]
  30. Sturges, H.A. The choice of a class interval. J. Am. Stat. Assoc. 1926, 21, 65–66. [Google Scholar] [CrossRef]
  31. Folland, G.B. Real Analysis: Modern Techniques and Their Applications; John Wiley & Sons: Hoboken, NJ, USA, 1999; Volume 40. [Google Scholar]
Figure 1. A visual depiction of the Point method. The curves are time series in a Hilbert space H but after applying KDE, there is a score associated to each point in H . In the cartoon, curves 1 and 2 are similar and curve 3 is anomalous. (Left): the time series. (Right): a representation of them with associated scores in the color scale. In reality, the space is infinite dimensional and this is only a conceptual illustration.
Figure 1. A visual depiction of the Point method. The curves are time series in a Hilbert space H but after applying KDE, there is a score associated to each point in H . In the cartoon, curves 1 and 2 are similar and curve 3 is anomalous. (Left): the time series. (Right): a representation of them with associated scores in the color scale. In reality, the space is infinite dimensional and this is only a conceptual illustration.
Entropy 22 01363 g001
Figure 2. Plot of 63 normal curves and the 7 anomalous curves C i ( t ) , i = 1 , , 7 . Left: un-normalized. Right: normalized.
Figure 2. Plot of 63 normal curves and the 7 anomalous curves C i ( t ) , i = 1 , , 7 . Left: un-normalized. Right: normalized.
Entropy 22 01363 g002
Figure 3. Histogram of scores for Point and Fourier methods for Type A Point (top-left), Type A Fourier(top-right), Type B Point (bottom-left) and Type B Fourier (bottom-right). The dashed vertical line represents the division we chose between anomalous (left of line) and normal (right of line). The Sturges estimate was used to set bin widths [30].
Figure 3. Histogram of scores for Point and Fourier methods for Type A Point (top-left), Type A Fourier(top-right), Type B Point (bottom-left) and Type B Fourier (bottom-right). The dashed vertical line represents the division we chose between anomalous (left of line) and normal (right of line). The Sturges estimate was used to set bin widths [30].
Entropy 22 01363 g003
Figure 4. Plots of the time series for Type A and Type B events. Anomalous are dotted curves with markers in the legend; normal curves are solid black curves.
Figure 4. Plots of the time series for Type A and Type B events. Anomalous are dotted curves with markers in the legend; normal curves are solid black curves.
Entropy 22 01363 g004
Table 1. Mean percentiles (out of 100) for curves C 1 C 7 in Scenario 1. A correct classification is a percentile less than or equal to 10 (in bold in the table). The -N suffix denotes the data were normalized by the pre-processing described in Section 2.3; the -U suffixed denotes the data were un-normalized. Note that method FB is not affected by the normalization.
Table 1. Mean percentiles (out of 100) for curves C 1 C 7 in Scenario 1. A correct classification is a percentile less than or equal to 10 (in bold in the table). The -N suffix denotes the data were normalized by the pre-processing described in Section 2.3; the -U suffixed denotes the data were un-normalized. Note that method FB is not affected by the normalization.
MethodLost C 1 C 2 C 3 C 4 C 5 C 6 C 7
Point-N0%4.35.81.42112242.9
Point-U0%4.35.71.4148.8162.9
Fourier-N0%4.71.92.82851298.5
Fourier-U0%5.84.02.83843351.7
FIF-N0%51247256795813
FIF-U0%192.24.81853195.3
PCA0%7.520.4.37.5539.411
FB0%4.55.61.83621372.5
Point-N10%4.36.01.42318292.9
Point-U10%4.35.71.420.14232.9
Fourier-N10%4.34.52.52843364.0
Fourier-U10%45595046495349
FIF-N10%50.217548745113
FIF-U10%45152942484432
PCA10%3220.6.13647357.7
FB10%7.58.74.24724495.1
Table 2. The 95th percentile of the percentile ranks (out of 100) for curves C 1 C 7 in Scenario 1. See Table 1 caption for -N vs. -U distinction.
Table 2. The 95th percentile of the percentile ranks (out of 100) for curves C 1 C 7 in Scenario 1. See Table 1 caption for -N vs. -U distinction.
MethodLost C 1 C 2 C 3 C 4 C 5 C 6 C 7
Point-N0%4.36.51.44742622.9
Point-U0%4.35.71.430.12462.9
Fourier-N0%8.63.64.367997413
Fourier-U0%5.74.34.28494772.9
FIF-N0%846992901009630
FIF-U0%577.51155975311
PCA0%25677.117962747
FB0%5.75.72.97574752.9
Point-N10%4.37.11.45251722.9
Point-U10%4.35.71.44643592.9
Fourier-N10%6.510.5.16191895.7
Fourier-U10%84979293939289
FIF-N10%81679791999539
FIF-U10%84275688959456
PCA10%8260.3173947319
FB10%111310.7575759.4
Table 3. Percentiles (out of 100) for curves D 1 D 5 in Scenario 2. A correct classification is a percentile less than or equal to 4.8 (in bold in the table) since 5 / 105 = 4.8 % . See Table 1 caption for -N vs. -U distinction.
Table 3. Percentiles (out of 100) for curves D 1 D 5 in Scenario 2. A correct classification is a percentile less than or equal to 4.8 (in bold in the table) since 5 / 105 = 4.8 % . See Table 1 caption for -N vs. -U distinction.
Method D 1 D 2 D 3 D 4 D 5
Point-N740.956.7731.9
Point-U830.95448571
Fourier-N3.84.81.92.90.95
Fourier-U1.98.6300.952.9
FIF-N1.9283.8100.95
FIF-U1.92.93.84.80.95
PCA4.82.93.81.90.95
FB750.95217575
Table 4. IDs of anomalous flights for events A and B. Columnwise, the bolded IDs are common to both methods for a given event type.
Table 4. IDs of anomalous flights for events A and B. Columnwise, the bolded IDs are common to both methods for a given event type.
MethodType AType B
Point14, 21, 22, 23, 351, 2, 4, 5, 6, 7, 8, 9, 25, 34
Fourier14, 21, 22, 351, 2, 4, 7, 8, 9
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Lindstrom, M.R.; Jung, H.; Larocque, D. Functional Kernel Density Estimation: Point and Fourier Approaches to Time Series Anomaly Detection. Entropy 2020, 22, 1363. https://doi.org/10.3390/e22121363

AMA Style

Lindstrom MR, Jung H, Larocque D. Functional Kernel Density Estimation: Point and Fourier Approaches to Time Series Anomaly Detection. Entropy. 2020; 22(12):1363. https://doi.org/10.3390/e22121363

Chicago/Turabian Style

Lindstrom, Michael R., Hyuntae Jung, and Denis Larocque. 2020. "Functional Kernel Density Estimation: Point and Fourier Approaches to Time Series Anomaly Detection" Entropy 22, no. 12: 1363. https://doi.org/10.3390/e22121363

APA Style

Lindstrom, M. R., Jung, H., & Larocque, D. (2020). Functional Kernel Density Estimation: Point and Fourier Approaches to Time Series Anomaly Detection. Entropy, 22(12), 1363. https://doi.org/10.3390/e22121363

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop