TIMEAUTOML: AUTONOMOUS REPRESENTATION LEARNING FOR MULTIVARIATE IRREGULARLY SAM-PLED TIME SERIES

Abstract

Multivariate time series (MTS) data are becoming increasingly ubiquitous in diverse domains, e.g., IoT systems, health informatics, and 5G networks. To obtain an effective representation of MTS data, it is not only essential to consider unpredictable dynamics and highly variable lengths of these data but also important to address the irregularities in the sampling rates of MTS. Existing parametric approaches rely on manual hyperparameter tuning and may cost a huge amount of labor effort. Therefore, it is desirable to learn the representation automatically and efficiently. To this end, we propose an autonomous representation learning approach for multivariate time series (TimeAutoML) with irregular sampling rates and variable lengths. As opposed to previous works, we first present a representation learning pipeline in which the configuration and hyperparameter optimization are fully automatic and can be tailored for various tasks, e.g., anomaly detection, clustering, etc. Next, a negative sample generation approach and an auxiliary classification task are developed and integrated within TimeAutoML to enhance its representation capability. Extensive empirical studies on real-world datasets demonstrate that the proposed TimeAutoML outperforms competing approaches on various tasks by a large margin. In fact, it achieves the best anomaly detection performance among all comparison algorithms on 78 out of all 85 UCR datasets, acquiring up to 20% performance improvement in terms of AUC score.

1. INTRODUCTION

The past decade has witnessed a rising proliferation in Multivariate Time Series (MTS) data, along with a plethora of applications in domains as diverse as IoT data analysis, medical informatics, and network security. Given the huge amount of MTS data, it is crucial to learn their representations effectively so as to facilitate underlying applications such as clustering and anomaly detection. For this purpose, different types of methods have been developed to represent time series data. Traditional time series representation techniques, e.g., Discrete Fourier Transform (DCT) (Faloutsos et al., 1994) , Discrete Wavelet Transform (DWT) (Chan & Fu, 1999) , Piecewise Aggregate Approximation (PAA) (Keogh et al., 2001) , etc., represent raw time series data based on specific domain knowledge/data properties and hence could be suboptimal for subsequent tasks given the fact that their objectives and feature extraction are decoupled. More recent time series representation approaches, e.g., Deep Temporal Clustering Representation (DTCR) (Ma et al., 2019) , Self-Organizing Map based Variational Auto Encoder (SOM-VAE) (Fortuin et al., 2018) , etc., optimize the representation and the underlying task such as clustering in an end-to-end manner. These methods usually assume that time series under investigation are uniformly sampled with a fixed interval. This assumption, however, does not always hold in many applications. For example, within a multimodal IoT system, the sampling rates could vary for different types of sensors. Unsupervised representation learning for irregularly sampled multivariate time series is a challenging task and there are several major hurdles preventing us from building effective models: i) the design of neural network architecture often employs a trial and error procedure which is time consuming and could cost a substantial amount of labor effort; ii) the irregularity in the sampling rates constitutes a major challenge against effective learning of time series representations and render most existing methods not directly applicable; iii) traditional unsupervised time series representation learning approach does not consider contrastive loss functions and consequently only can achieve suboptimal performance. To tackle the aforementioned challenges, we propose an autonomous unsupervised representation learning approach for multivariate time series to represent irregularly sampled multivariate time series. TimeAutoML differs from traditional time series representation approaches in three aspects. First, the representation learning pipeline configuration and hyperparameter optimization are carried out automatically. Second, a negative sample generation approach is proposed to generate negative samples for contrastive learning. Finally, an auxiliary classification task is developed to distinguish normal time series from negative samples. In this way, the representation capability of TimeAu-toML is greatly enhanced. We conduct extensive experiments on UCR time series datasets and UEA multivariate time series datasets. Our experiments demonstrate that the proposed TimeAu-toML outperforms comparison algorithms on both clustering and anomaly detection tasks by a large margin, especially when time series data is irregularly sampled.

2. RELATED WORK

Unsupervised Time Series Representation Learning Time series representation learning plays an essential role in a multitude of downstream analysis such as classification, clustering, anomaly detection. There is a growing interest in unsupervised time series representation learning, partially because no labels are required in the learning process, which suits very well many practical applications. Unsupervised time series representation learning can be broadly divided into two categories, namely 1) multi-stage methods and 2) end-to-end methods. Multi-stage methods first learn a distance metric from a set of time series, or extract the features from the time series, and then perform downstream machine learning tasks based on the learned or the extracted features. Euclidean distance (ED) and Dynamic Time Warping (DTW) are the most commonly used traditional time series distance metrics. Although the ED is competitive, it is very sensitive to outliers in the time series. The main drawback of DTW is its heavy computational burden. Traditional time series feature extraction methods include Singular Value Decomposition (SVD), Symbolic Aggregate Approximation (SAX), Discrete Wavelet Transform (DWT) (Chan & Fu, 1999) , Piecewise Aggregate Approximation (PAA) (Keogh et al., 2001) , etc. Nevertheless, most of these traditional methods are for regularly sampled time series, so they may not perform well on irregularly sampled time series. In recent years, many new feature extraction methods and distance metrics are proposed to overcome the drawbacks mentioned above. For instance, Paparrizos & Gravano (2015) ; Petitjean et al. (2011) combine the proposed distance metrics and K-Means algorithm to achieve clustering. Lei et al. (2017) first extracts sparse features of time series, which is not sensitive to outliers and irregular sampling rate, and then carries out the K-Means clustering. In contrast, end-to-end approaches learn the representation of the time series in an end-to-end manner without explicit feature extraction or distance learning (Fortuin et al., 2018; Ma et al., 2019) . However, the aforementioned methods need to manually design the network architecture based on human experience which is time-consuming and costly. Instead, we propose in this paper a representation learning method which optimizes an AutoML pipeline and their hyperparameters in a fully autonomous manner. Furthermore, we consider negative sampling and contrastive learning in the proposed framework to effectively enhance the representation ability of the proposed neural network architecture.

Irregularly Sampled Time Series Learning

There exist two main groups of works regarding machine learning for irregularly sampled time series data. The first type of methods impute the missing values before conducting the subsequent machine learning tasks (Shukla & Marlin, 2019; Luo et al., 2018; 2019; Kim & Chi, 2018) . The second type directly learns from the irregularly sampled time series. For instance, Che et al. (2018) ; Cao et al. (2018) propose a memory decay mechanism, which replaces the memory cell of RNN by the memory of the previous timestamp multiplied by a learnable decay coefficient when there are no sampling value at this timestamp. Rubanova et al. (2019) combines RNN with ordinary differential equation to model the dynamic of irregularly sampled time series. Different from the previous works, TimeAutoML makes use of the special characteristics of RNN (Abid & Zou, 2018) and automatically configure a representation learning pipeline to model the temporal dynamics of time series. It is worthy mentioning that there are many types of irregularly sampled time series, which may be caused by sensor failure or sampling time error. And what we put emphasis on analyzing in this paper is a special type of irregularly sampled time series, which have many missing timestamps compared to regularly sampled time series. AutoML Automatic Machine Learning (AutoML) aims to automate the time-consuming model development process and has received significant amount of research interests recently. Previous works about AutoML mostly emphasize on the domains of computer vision and natural language processing, including object detection (Ghiasi et al., 2019; Xu et al., 2019; Chen et al.) , semantic segmentation (Weng et al., 2019; Nekrasov et al., 2019; Bae et al., 2019) , translation (Fan et al., 2020) and sequence labeling (Chen et al., 2018a) . However, AutoML for time series learning is an underappreciated topic so far and the existing works mainly focus on supervised learning tasks, e.g., time series classification. Ukil & Bandyopadhyay propose an AutoML pipeline for automatic feature extraction and feature selection for time series classification. Van Kuppevelt et al. (2020) develops an AutoML framework for supervised time series classification, which involves both neural architecture search and hyperparameter optimization. Olsavszky et al. (2020) proposes a framework called AutoTS, which performs time series forecasting of multiple diseases. Nevertheless, to our best knowledge, no previous work has addressed unsupervised time series learning based on AutoML.

Summary of comparisons with related work

We next provide a comprehensive comparison between the proposed framework and other state-of-the-art methods, including (WaRTEm (Mathew et al., 2019) , DTCR (Ma et al., 2019) , USRLT (Franceschi et al., 2019) and BeatGAN (Zhou et al., 2019) ), as shown in Table 1 . In particular, we emphasize on a total of seven features in the comparison, including data augmentation, negative sample generation, contrastive learning, selection of autoencoders, similarity metric selection, attention mechanism selection, and automatic hyperparameter search. TimeAutoML is the only method that has all the desired properties.  3 TIMEAUTOML FRAMEWORK 3.1 PROPOSED AUTOML FRAMEWORK Let X = {x 1 , x 2 , • • • x N } denote a set of N time series in which x i ∈ R Ti , where T i is the length of the i th time series x i . We aim to build an automated time series representation learning framework to generate task-aware representations that can support a variety of downstream machine learning tasks. In addition, we consider negative sample generation and contrastive self-supervised learning. The contrastive loss function focuses on building time series representations by learning to encode what makes two time series similar or different. The proposed TimeAutoML framework can automatically configure an representation learning pipeline with an array of functional modules, each of these modules is associated with a set of hyperparameters. We assume there are a total of M modules and there are Q i options for the i th functional module. Let k i ∈ {0, 1} Qi denote an indicating vector for i th module, with the constraint 1 k i = Qi j=1 k i,j = 1 ensuring that only a single option is chosen for each module. Let θ i,j be the hyperparameters of j th option in i th module, where θ C i,j and θ D i,j are respectively the continuous and discrete hyperparameters. Let Θ and K denote the set of variables to optimize, i.e., Θ = {θ i,j , ∀i ∈ [M ], j ∈ [Q i ]} and K = {k 1 , . . . , k M }. We further let f (K, Θ) denote the corresponding objective function value. Please note that the objective function differs for different tasks. For anomaly detection, we use Area Under the Receiver Operating Curve (AUC) as objective function while we use the Normalized Mutual Information (NMI) as objective function for clustering. The optimization problem of automatic pipeline configuration is shown below. max K,Θ f (K, Θ) subject to k i ∈ {0, 1} Qi , 1 k i = 1, ∀i ∈ [M ], θ C i,j ∈ C i,j , θ D i,j ∈ D i,j , ∀i ∈ [M ], j ∈ [Q i ]. (1) We solve problem (1) by alternatively leveraging Thompson sampling and Bayesian optimization, which will be discussed as follows. 负责活动前期准备以 及后期扫尾工作 

3.1.1. PIPELINE CONFIGURATION

We first assume that the hyperparameters Θ are fixed during the pipeline configuration. We aim at selecting the better module option K to optimize objective function f (K, Θ), we can delineate it as a K -max problem: K = max K f (K, Θ) + χ K (K), χ K (K) = 0, if K ∈ K -∞, else , ( ) where K is the feasible set, i.e., K = {K : K = {k i }, k i ∈ {0, 1} Qi , 1 k i = 1, ∀i ∈ [M ]} and χ K (K) is a penalty term that makes sure K fall in the feasible region. Thompson sampling is utilized to tackle problem (2). In every iteration, Thompson sampling assumes the sampling probability of every option in each module follows Beta distribution, and the one corresponding to the maximum sampling value in each module will be chosen to construct the pipeline. After that, Beta distribution of the chosen options will be updated according to the performance of the configured pipeline. Due to space limitation, more details about Thompson sampling and the search space for pipeline configuration are shown in Appendix B and Appendix C, respectively. The representation learning pipeline consists of eight modules, namely data augmentation, auxiliary classification network, encoder, attention, decoder, similarity selection, estimation network and EM estimator, as elucidated in Figure 1 . The goal of data augmentation is to increase the diversity of samples. The auxiliary classification network aims at distinguishing the positive samples from generated negative samples, which will be discussed in detail in Section 3.2. And we combine encoder, attention, decoder and similarity selection together to generate the low-dimensional representation of the input time series. Given an input time series x i , we can generate the latent space representation y i , which is an concatenation of the output of h i and reconstruction error z i , as shown below: h i = f en (x i ), x rec i = f de (h i ), z i = f sim (x i , x rec i ), y i = [h i ; z i ], where f en and f de refer to an encoder and a decoder, respectively. There are three options for the encoder and decoder, namely, Recurrent Neural Network (RNN), Long Short Term Memory (LSTM), Gated Recurrent Unit (GRU). f sim is a similarity function that characterizes the level of similarity between the original time series and the reconstructed one. Three possible similarity functions are considered in this paper, i.e., relative Euclidean distance, Cosine similarity, or concatenation of both. After obtaining the latent space representation of the input time series, EM algorithm is then invoked to estimate the mean and convariance of GMM. Assuming there are H mixture components in the GMM model, the mixture probability, mean, covariance for component h in the GMM module can be expressed as φ h , µ h , h , respectively. Assuming there are a total of N samples, the key parameters of GMM can be calculated as follows: γ i = f est (y i ), ∀i ∈ [N ], φ h = N i=1 γ i,h N , ∀h ∈ [H], µ h , h = f EM ({y i , γ i,h } N i=1 ), ∀h ∈ [H], where f est is the estimation network which is a multi-layer neural network, and γ i ∈ R H is the mixture-component membership prediction vector. f EM is the EM estimator which can estimate the mean and convariance of GMM via the EM algorithm. The h th entry of this vector represents the probability that y i belongs to the h th mixture component. The sample energy E(y i ) is given by, E(y i ) = -log( H h=1 φ h • exp(-1 2 (y i -µ h ) -1 h (y i -µ h )) |2π h | ). (5) The sample energy can be used to characterize the level of anomaly of an input time series, that is, the sample with high energy will be deemed as an unusual time series. It is worth noticing that TimeAutoML may suffer from the singularity problem as in GMM. In this case, the training algorithm may converge to a trivial solution if the covariance matrix is singular. We prevent this singularity problem by adding 1e -6 to the diagonal entries of the covariance matrices.

3.1.2. HYPERPARAMETERS OPTIMIZATION

Once the representation learning pipeline is constructed, we then emphasize on optimizing the hyperparameters for the given pipeline. Here we make use of the Bayesian Optimization (BO) (Shahriari et al., 2015) to tackle this Θ -max task, as given below, max Θ C ,Θ D f (K, {Θ C , Θ D })+χ C (Θ C )+χ D (Θ D ), χ C (Θ C ) = 0, if Θ C ∈ C -∞, else , χ D (Θ D ) = 0, if Θ D ∈ D -∞, else , where the set C and D denote respectively feasible region of the hyperparameters, and f (•) is the objective function given in problem (1). χ C (Θ C ) and χ D (Θ D ) are penalty terms that make sure the hyperparameters fall in the feasible region. Unlike random search (Bergstra & Bengio, 2012) and grid search (Syarif et al., 2016) , BO is able to optimize hyperparameters more efficiently. More details about BO are discussed in Appendix A. Algorithm 1 depicts the main steps in TimeAutoML and more details are given in Appendix B. 2019), the structure of the encoder has a direct impact on the representation learning performance. Take anomaly detection as an example, the semi-supervised anomaly detection methods (Pang et al., 2019; Ruff et al., 2019) assume that there are a few labeled anomaly samples in the training dataset, which is more effective in representation learning than unsupervised methods. Instead, the proposed contrastive self-supervised loss does not require any labeled anomaly samples. It uses generated negative samples as anomalies for model building. The goal is to allow the encoder to distinguish the positive samples from generated negative samples. Given a normal time series x i ∈ R T , which is deemed as a positive sample. We then generate the negative sample x neg i by adding noise randomly over a few selected timestamps of x i , that is, x neg i = g(x i ), where g(•) is the negative sample generation trick. In the experiment, the noise amplitude is randomly selected within the interval [min(x i ), max(x i )]. In the experiment, we generate one negative sample x neg i for each positive sample x i . The proposed contrastive self-supervised loss L self aims to distinguish the positive time series sample from the negative ones, which can be given as: h pos i = f en (x i ), h neg i = f en (x neg i ), o pos i = f clas (h pos i ), o neg i = f clas (h neg i ), L self (x i ) = f BCE (o pos i , 0) + f BCE (o neg i , 1), where h pos i ∈ R S and h neg i ∈ R S are respectively the latent space representations of positive samples and negative samples, S represents the length of latent space representation. f clas is the auxiliary classification network, o pos i ∈ R 1 and o neg i ∈ R 1 are the outputs of the classifier. f BCE represents binary cross entropy and we label the positive time series and negative time series as 0 and 1, respectively. More details about the proposed self-supervised loss L self are shown in Figure 1 , we can see that minimizing L self allows the encoder to distinguish the positive samples from the negative samples in the latent space, and consequently entails better latent space representations.

3.3. OVERALL LOSS FUNCTION AND JOINT OPTIMIZATION

Given a dataset with N time series, for fixed pipeline configuration and hyperparameters, the neural network is trained by minimizing an overall loss function containing three parts: L overall = 1 N N i=1 D(x i , x rec i ) + λ 1 1 N N i=1 E(y i ) + λ 2 1 N N i=1 L self (x i ), where D(x i , x rec i ) represents reconstruction error. E(y i ) is the sample energy function which represents the level of abnormality for a given sample. L self (x i ) is the proposed contrastive selfsupervised loss. λ 1 and λ 2 are two weighting factors governing the trade-off among these three parts.

4. EXPERIMENT

The performance of the proposed time series representation learning framework has been assessed via two machine learning tasks, i.e., anomaly detection and clustering. The primary goal is to answer the following two questions in the experiment, 1) Effectiveness: can the proposed representation learning framework effectively model and capture the temporal dynamics of a time series? 2) Robustness: can TimeAutoML remain effective in the presence of irregularities in sampling rates and contaminated training data? Dataset We first conduct experiments on a total of 85 UCR univariate time series datasets (Chen et al., 2015) to assess the anomaly detection performance. Next, we also assess the performance of the proposed TimeAutoML on a multitude of UEA multivariate time series datasets (Bagnall et al., 2018) . We follow the method proposed in Chandola et al. (2008) to create the training, validation, and testing dataset. AUC (Area under the Receiver Operating Curve) is employed to evaluate the anomaly detection performance. For clustering, we carry out experiments on a total of 3 UCR univariate datasets and 2 UEA multivariate datasets. NMI (Normalized Mutual Information) is used to evaluate the clustering results. Baselines For anomaly detection, the proposed TimeAutoML is compared with a set of state-ofthe-art methods including latent ODE (Rubanova et al., 2019) , Local Outlier Factor (LoF) (Breunig et al., 2000) , Isolation Forest (IF) (Liu et al., 2008) , One-Class SVM (OCSVM) (Schölkopf et al., 2001) , GRU-AE (Malhotra et al., 2016) , DAGMM (Zong et al., 2018) and BeatGAN (Zhou et al., 2019) . For clustering, the baseline algorithms for comparison include K-means, GMM, K-means+DTW, K-means+EDR (Chen et al., 2005) , K-shape (Paparrizos & Gravano, 2015) , SPIRAL (Lei et al., 2017) , DEC (Xie et al., 2016) , IDEC (Guo et al., 2017) , DTC (Madiraju et al., 2018) , DTCR (Ma et al., 2019) .

4.1. ANOMALY DETECTION

We present the AUC scores of the proposed TimeAutoML and other state-of-the-art anomaly detection methods for the 85 univariate time series datasets of UCR archive (Chen et al., 2015) . Due to the space limitation, we choose a portion of the time series datasets and the corresponding anomaly detection results are summarized in Table 2 . The anomaly detection results for the remaining datasets are summarized in Appendix D, Table A2 , A3. It is seen that TimeAutoML achieves best anomaly detection performance over the majority > 90% of the UCR datasets no matter the time series are regularly or irregularly sampled. In addition, we evaluate the performance of TimeAutoML on a multitude of multivariate time series datasets from UEA archive (Bagnall et al., 2018) . Effectiveness We assess the anomaly detection performance when time series are irregularly sampled (β = 0.5) and regularly sampled (β = 0), where β is the irregular sampling rate representing the ratio of missing timestamps to all timestamps (Chen et al., 2018b) . Note that we put emphasis on analyzing time series with missing timestamps, which is a special type of irregular sampling time series. Table 2 presents the AUC scores of the proposed TimeAutoML and state-of-the-art anomaly detection methods on a selected group of UCR datasets and UEA datasets. We observe that the performance of BeatGAN severely degrades in the presence of irregularities in sampling rates since it is designed for fixed-length input vectors. We also notice that the proposed TimeAutoML exhibits superior performance over existing state-of-the-art anomaly detection methods in almost all cases for irregularly sampled time series. In addition, the negative sampling combined with the contrastive loss function can further boost the anomaly detection performance. Table 2 : AUC scores of TimeAutoML and state-of-the-art anomaly detection methods when time seires are regularly sampled (β = 0) and irregularly sampled (β = 0.5). Bold and underlined scores respectively represent the best and second-best performing methods. 

4.2. VISUALIZATION

In this section, we use a synthetic dataset to elucidate the underlying mechanism of TimeAutoML model for detecting time series anomalies. Figure 3 shows the latent space representation learned via TimeAutoML model from a synthetic dataset. In this dataset, smooth Sine curves are normal time series. The anomaly time series is created by adding noise to the normal time series over a short interval. It is evident from Figure 3 that the latent space representations of normal time series lie in a high density area that can be well characterized by a GMM; while the abnormal time series appears to deviate from the majority of the observations in the latent space. In short, the proposed encoder-decoder structure allows us to project the time series data in the original space onto vector representations in the latent space. In doing so, we can detect anomalies via clustering-based methods, e.g., GMM, and easily visualize as well as interpret the detected time series anomalies. 

4.3. CLUSTERING

Apart from anomaly detection, TimeAutoML can be tailored for other machine learning tasks as well, e.g., multi-class clustering. In particular, the clustering process is carried out in the latent space via the GMM model, along with other modules in the pipeline. We evaluate the effectiveness of TimeAutoML on three univariate time series datasets as well as two multivariate time series datasets. The NMI of TimeAutoML and state-of-the-art clustering methods are shown in Table 3 . We observe that TimeAutoML generally achieves superior performance compared to baseline algorithms. This is because: i) it can automatically select the best module and hyperparameters; ii) the auxiliary classification task can enhance its representation capability. 

5. CONCLUSION

Representation learning on irregularly sampled time series is an under-explored topic. In this paper we propose a TimeAutoML framework to carry out unsupervised autonomous representation learning for irregularly sampled multivariate time series. In addition, we propose a self-supervised loss function to get labels directly from the unlabeled data. Strong empirical performance has been observed for TimeAutoML on a plurality of real-world datasets. While tremendous efforts have been undertaken for time series learning in general, AutoML for time series representation learning is still in its infancy and we hope the findings in this paper will open up new venues along this direction and spur further research efforts. A APPENDIX A: BAYESIAN OPTIMIZATION Let f (θ) denote the objective function. Given function values during the preceding T iterations v = [f (θ 1 ), f (θ 2 ), • • • , f (θ T )], we pick up the variable for sampling in the next iteration via solving the maxmization problem that involves the acquisition function i.e., expected improvement (EI) based on the postetior GP model. Specifically, the objective function is assumed to follow a GP model (Shahriari et al., 2015) and can be expressed as f (θ) ∼ GP (m(θ), K), where m(θ) represents the mean function. And K represents the covariance matrix of {θ i } T i=0 , namely, K ij = κ(θ i , θ j ), where κ(•, •) is the kernel function. In particular, the poster probability of f (θ) at iteration T + 1 is assumed to follow a Gaussian distribution with mean µ(θ * ) and covariance σ 2 (θ * ), given the observation function values v : µ(θ * ) = κ T [K + σ 2 n I] -1 v, σ 2 (θ * ) = κ(θ * , θ * ) -κ T [K + σ 2 n I] -1 κ, where κ is a vector of covariance terms between θ * and {θ i } T i=0 , and σ 2 n denotes the noise variance. We choose the kenel function as ARD Matérn 5/2 kernel (Shahriari et al., 2015) in this paper: κ(p, p ) = τ 2 0 exp(- √ 5r)(1 + √ 5r + 5 3 r 2 ), where p and p are input vectors, r 2 = d i=1 (p i -p i ) 2 /τ 2 i , and ψ = {{τ i } d i=0 , σ 2 n } are the GP hyperparameters which are determined by minimizing the negative log marginal likelihood log(y|ψ) : min ψ log det(K + σ 2 n I) + v T (K + σ 2 n I) -1 v. ( ) Given the mean µ(θ * ) and covariance σ 2 (θ * ) in ( 9), θ T +1 can be obtained via solving the following optimization problem: θ T +1 = arg max θ * EI(θ * ) = arg max θ * (µ(θ * )-y + )Φ( µ(θ * )-y + σ(θ * ) )+σφ( µ(θ * )-y + σ(θ * ) ), where y + = max[f (θ 1 ), f (θ 2 ), • • • , f (θ T )] represents the maximum observation value in the previous T iterations. Φ is normal cumulative distribution function and φ is normal probability density function. Through maximizing the EI acquisition function, we seek to improve f (θ T +1 ) monotonically after each iteration.

B APPENDIX B: DETAILED VERSION OF TIMEAUTOML

Algorithm 2: Detailed Version of TimeAutoML Input: L: pre-defined threshold for maximum number of iterations. B: pre-defined threshold for maximum Bayesian optimization iterations. α 0 and β 0 : pre-defined Beta distribution priors. f upp and f low : pre-defined upper bound and lower bound to objective function f . Set: α i (t) ∈ R Qi , β i (t) ∈ R Qi : the cumulative reward and punishment for i th module for the t th iteration, specifically, α i (1) = α 0 and β i (1) = β 0 . for t = 1, 2, • • • , L do for i = 1, 2, • • • , M do Sample w ∼ Beta(α i (t), β i (t)) end Obtain the TimeAutoML pipeline configuration by solving the following optimization problem:  maxmize K M i=1 (k i ) w i subject to k i ∈ {0, 1} Qi , 1 k i = 1, ∀i ∈ [M ], for b = 1, 2, • • • , B 1. Let f (t) = max{f (K(t), Θ b (t)), b = 1, • • • , B} denote the performance of TimeAutoML model at the t th iteration. 2. Compute the continuous reward ∼ r : ∼ r = max{0, f (t)-f low fupp-f low } 3. Obtain the binary reward r ∼ Bernoulli( ∼ r ). for i = 1, 2, • • • , M do α i (t + 1) = α i (t) + k i • r β i (t + 1) = β i (t) + k i • (1 -r) end end Output: A TimeAutoML model with optimized hyperparameters. It is seen that TimeAutoML consists of two main stages, i.e., pipeline configuration and hyperparameter optimization. In every iteration of TimeAutoML, Thompson sampling is utilized to refine the pipeline configuration at first. After that, Bayesian optimization is invoked to optimize the hyperparameters of the model. Finally, the Beta distribution of the chosen options will be updated according to the performance of the configured pipeline. In the experiment, the upper limit to number of entire TimeAutoML iterations, BO iterations are set as 40 and 25 respectively. The Beta distribution priors are set respectively as α 0 = 10 and β 0 = 10. • Scaling: increasing or decreasing the amplitude of the time series. There are two hyperparametes, the number of data augmentation samples N aug ∈ [0, 100] and the scaling size h amp ∈ [0.5, 1.8].

C APPENDIX C: SEARCH SPACE: OPTIONS AND HYPERPARAMETERS

• Shifting: cyclically shifting the time series to the left or right. There are two hyperparametes, the number of data augmentation samples N aug ∈ [0, 100] and the shift size h shift ∈ [-10, 10]. • Time-warping: randomly "slowing down" some timestamps and "speeding up" some timestamps. For each timestamp to "speed up", we delete the data value at that timestamp. For each timestamp to "slow down", we insert a new data value just before that timestamp. There are two hyperparametes, the number of data augmentation samples N aug ∈ [0, 100] and the number of time-warping timestamps h tm ∈ [T /10, T /4].

C.2 ENCODER

For all encoders, i.e. RNN, LSTM, and GRU, there is only one hyperparameter, i.e., the size of the encoder hidden state. And we assume it is no larger than 32, i.e., h enc ∈ [1, 32].

C.3 ATTENTION

Self-attention mechanism has been considered in this framework.

C.4 DECODER

For all decoders, i.e. RNN, LSTM, and GRU, there is only one hyperparameter, i.e., the size of decoder hidden state h dec . For univariate time series, we assume it is no larger than 32, i.e., h 

E APPENDIX E: ILLUSTRATION OF IRREGULAR SAMPLING

We provides an illustrative example to demonstrate how TimeAutoML remain robust against the irregularities in the sampling rates. Both regularly and irregularly sampled time series (β = 0.5) are presented in Figure A3 . And for the purpose of illustration we assume the normal time series is a Sine curve. The anomalous time series is obtained via adding noise to the normal time series over a short time interval. The irregularly sampling rate is set as 0.5 in this example. As evident from the figure, the unusual pattern of the anomalous time series preserves after the irregular sampling. And such unusual pattern appears to be different from the distortion caused by irregular sampling. Due to the special characteristics of TimeAutoML, e.g., embedded LSTM encoder and attention mechanism, it is capable of learning both the short term and long term correlations among the training time series and therefore can detect such unusual pattern even in the presence of irregularity in the sampling. 

F APPENDIX F: RESULTS OF TIME SERIES CLASSIFICATION

The representation generated by TimeAutoML can be used to carry out time series classification. We combine the representation generated by TimeAutoML with Gradient Boost Decision Tree (GBDT) to carry out time series classification. Followed Franceschi et al. (2019) , we compared our method with four best supervised state-of-the-art model, HIVE-COTE (Lines et al., 2018) , ST (Bostrom & Bagnall, 2017) , EE (Lines & Bagnall, 2015) , BOSS (Schäfer, 2015) , which are shown in Table A6 . It is worthy mentioning that both of TimeAutoML and Franceschi et al. (2019) are unsupervised time series representation learning models. Accuracy score is used as the metric to evaluate the classification performance. Besides, the results of DTW (Lei et al., 2017) , which is an unsupervised model, and the results of GBDT on original input have also been posted in Table A6 . For easier comparison, we compute the average ranks of TimeAutoML and the benchmarks, which are shown in Figure A4 . It is seen that our method is globally the second-best one (with average rank 2.57), only beaten by HIVE-COTE (2.42), which is a powerful ensemble method using many classifiers in a hierarchical voting structure. And we can observe that, GBDT (6.63) on original input has a poor performance, while combined with representation generated by TimeAutoML can improve the classification performance significantly, which indicating the important role of TimeAutoML. Figure A4 : The average rank of our method and state-of-the-art models. Our method is an unsupervised representation learning method, combined with other classification algorithm can reach an excellent classification performance. We combine GBDT with our model in the experiment. A lower value of average rank represents a better classification performance.

G APPENDIX G: PARAMETER SENSITIVITY

In our experiment, λ 1 and λ 2 are two weighting factors governing the trade-off among three parts in our objective in (8). We analyzed the sensitivity of λ 1 and λ 2 in ECG200 dataset (average over 10 trials) on anomaly detection task, which is shown in Figure A5 . It is seen that, our approach is not very sensitive to the choice of λ 1 and λ 2 . Nevertheless, a too large λ 1 or a too small λ 2 may not be friendly to the optimization of our model. Based on this observation, we set the λ 1 = 0.0001 and λ 2 = 1 in our experiment. We also analyzed the sensitivity of Beta distribution priors α 0 and β 0 in our AutoML framework, which is tested in ECG200 dataset (average over 10 trials) on anomaly detection task and the results are shown in Figure A6 . It is seen that, the choice of Beta distribution priors α 0 and β 0 will not have a significant impact on performance, indicating that the our model is not very sensitive to the choice of Beta distribution priors. 

H APPENDIX H: MOTIVATION OF INVOLVING GAUSSIAN MIXTURE MODEL

The idea of TimeAutoML is to map the original time series into the latent space representation and the generated representation can be used to carry out many downstream machine learning tasks, such as anomaly detection, clustering, classification and so on. We employ the GMM model to characterize the latent space representation distribution of the input data for two reasons. First, GMM is a flexible and powerful model that has been proved to be capable of approximating any continuous distribution arbitrarily well under mild assumptions. Second, once we obtain a GMM model using the training data, we can calculate the distances between an input time series and the centroids of GMM in the latent space, which are proportional to the sample energy function. Therefore, the GMM model, in combination with the sample energy function, help to characterize the level of abnormality of an input time series. The time series that is far away from the centroids of the GMM in the latent space will be deemed as an anomaly.



Figure 1: The representation learning pipeline of TimeAutoML. There are totally eight modules forming this pipeline, namely data augmentation, encoder f en , attention, decoder f de , similarity selection f sim , estimation network f est , EM estimator f EM , auxiliary classification network f clas . And f BCE represents the binary cross entropy computation, D(x i , x rec i ), E(y i ) and L self (x i ) represent the reconstruction loss, energy and self-supervised contrastive loss of input sample x i , respectively.

TimeAutoML with Contrastive Learning Input: Maximum iterations L and Bayesian Optimization iterations B. for t = 1, 2, • • • , L do Configuring a complete AutoML pipeline accoding to Thompson Sampling. for b = 1, 2, • • • , B do Hyperparameters optimization: Update hyperparameters according to Bayesian Optimization and obtain the objective function value. end Update parameters of Thompson Sampling in each module according to the obtained objective function values. end Output: Configured AutoML pipeline and optimized hyperparameters.

CONTRASTIVE SELF-SUPERVISED LOSS According to Zhou et al. (2019); Kieu et al. (2019); Yoon et al. (

β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 LOF 0.6271 0.

We investigate how the proposed TimeAutoML responds to contaminated training data when time series are irregularly sampled with the rate β = 0.5. AUC scores of the proposed TimeAutoML when training on contaminated data are presented in Appendix D, Table A4, A5. We observe that the anomaly detection performance of TimeAutoML slightly degrades when training data are contaminated. Next, we investigate how TimeAutoML responds to different irregular sampling rate, i.e., when β varies from 0 to 0.7. The AUC scores of TimeAutoML and state-of-the-art anomaly detection methods on ECGFiveDays dataset are presented in Fig 2 and the results on other datasets are presented in Appendix D, Fig A1, A2. We notice that TimeAutoML performs well robustly across multiple irregular sampling rates.

Figure 2: AUC scores of TimeAutoML on ECGFiveDays dataset when irregular sampling rate β varies from 0 to 0.7.

Figure 3: Anomaly interpretation via analysis in latent space.

β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0.5 β = 0 β = 0

Figure A2: AUC scores of TimeAutoML and state-of-the-art anomaly detection methods on multivariate datasets when irregular sampling rate β varies from 0 to 0.7.

Figure A3: Irregular sampling on Sine curves.

Figure A5:The sensitivity analysis about weighting factors λ 1 and λ 2 , for each combination of λ 1 ∈ {0.00001, 0.0001, 0.001, 0.01, 0.1, 1} and λ 2 ∈ {0.001, 0.01, 0.1, 1, 10}.

Figure A6: The sensitivity analysis about Beta distribution priors α 0 and β 0 , for each combination of α 0 ∈ {5, 10, 15, 20, 25, 30} and β 0 ∈ {5, 10, 15, 20, 25, 30}.

Comparisons with related methods

NMI scores of TimeAutoML and state-of-the-art clustering methods. Bold and underlined scores respectively represent the best and second-best performing methods.

do Hyperparameters optimization: Update hyperparameters according to Bayesian optimization framework given in Appendix A and the obtained objective function value is denoted as f (K(t), Θ b (t)), where K(t) denote the module options in t th iteration and Θ b (t) denote the hyperparameters in b th Bayesian optimization iteration in t th iteration. end Update Beta distribution of the options in the configured pipeline:

Modules, options, and hyperparameters of TimeAutoML.

AUC scores of TimeAutoML and state-of-the-art anomaly detection methods on UCR time series dataset when time series are regularly sampled (β = 0). Bold and underlined scores respectively represent the best and second-best performing methods.

AUC scores of TimeAutoML and state-of-the-art anomaly detection methods on UCR time series dataset when time series are irregularly sampled (β = 0.5). Bold and underlined scores respectively represent the best and second-best performing methods.

AUC scores of TimeAutoML when univariate time series training datasets are contaminated with 5% and 10% anomaly samples.

AUC scores of TimeAutoML when univariate time series training datasets are contaminated with 5% and 10% anomaly samples.

Accuracy scores of TimeAutoML and the state-of-the-art classification methods on UCR time series datasets when time series are regularly sampled (β = 0). Bold scores represent the best performing method.

annex

Junyuan Xie, Ross Girshick, and Ali Farhadi. Unsupervised deep embedding for clustering analysis.In International conference on machine learning, pp. [478] [479] [480] [481] [482] [483] [484] [485] [486] [487] 2016 .Hang Xu, Lewei Yao, Wei Zhang, Xiaodan Liang, and Zhenguo Li. Auto-FPN: Automatic network architecture adaptation for object detection beyond classification. 

