title: Defending Water Treatment Networks: Exploiting Spatio-temporal Effects for Cyber Attack Detection
authors: Dongjie Wang Pengyang Wang Jingbo Zhou Leilei Sun Bowen Du Yanjie Fu
text: 
  
  
  
  
  
  
  
  
  
  
  
  
  Defending Water Treatment Networks:  Exploiting Spatio-temporal Effects for Cyber Attack Detection
      1st Dongjie Wang
  
  Department of Computer Science 
  
  University of Central Florida
  
  Orlando,United States 
  
  wangdongjie@knights.ucf.edu
  2nd Pengyang Wang
  
  Department of Computer Science 
  
  University of Central Florida
  
  Orlando, United States 
  
  pengyang.wang@knights.ucf.edu
  3rd Jingbo Zhou
  
  Baidu Research 
  
  Baidu Inc.
  
  Beijing, China 
  
  zhoujingbo@baidu.com
  4th Leilei Sun
  
  Department of Computer Science 
  
  Beihang University
  
  Beijing, China 
  
  leileisun@buaa.edu.cn
  5th Bowen Du
  
  Department of Computer Science 
  
  Beihang University
  
  Beijing, China 
  
  dubowen@gmail.com
  6th Yanjie Fu^†
  
  Department of Computer Science 
  
  University of Central Florida
  
  Orlando, United States 
  
  yanjie.fu@ucf.edu
  
      December 30, 2023
  ======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
  
  
  
  
  
  While Water Treatment Networks (WTNs) are critical infrastructures for local communities and public health, WTNs are vulnerable to cyber attacks. Effective detection of attacks can defend WTNs against discharging contaminated water, denying access,  destroying equipment, and causing public fear.  
  While there are extensive studies in WTNs attack detection, they only exploit the data characteristics partially to detect cyber attacks.
  After preliminary exploring the sensing data of WTNs, we find that integrating spatio-temporal knowledge, representation learning, and detection algorithms can improve attack detection accuracy.
  To this end, we propose a structured anomaly detection framework to defend WTNs by modeling the spatio-temporal characteristics of cyber attacks in WTNs.
  In particular, we propose a spatio-temporal representation framework specially tailored to cyber attacks after separating the sensing data of WTNs into a sequence of time segments.
  This framework has two key components. 
  The first component is a temporal embedding module to preserve temporal patterns within a time segment by projecting the time segment of a sensor into a temporal embedding vector. 
  We then construct Spatio-Temporal Graphs (STGs), where a node is a sensor and an
  attribute is the temporal embedding vector of the sensor, to describe the state of the WTNs.
  The second component is a spatial embedding module, which learns the final fused embedding of the WTNs from STGs. 
  In addition, we devise an improved one class-SVM model that utilizes a new designed pairwise kernel to detect cyber attacks. 
  The devised pairwise kernel augments the distance between normal and attack patterns in the fused embedding space. 
  Finally, we conducted extensive experimental evaluations with real-world data to demonstrate the effectivness of our framework: it achieves an accuracy of 91.65%, with average improvement ratios of 82.78%  and 22.96% with respect to F1 and AUC,  compared with  baseline methods.
  
  
  
  In this paper, we propose a structured anomaly detection framework to defend water treatment networks (WTNs) by modeling the spatio-temporal characteristics of cyber attacks in WTNs. While WTNs are critical infrastructures for public health, WTNs are vulnerable to cyber attacks. Effective detection of cyber attacks can defend WTNs against discharging contaminated water, denying access,  destroying equipment, and causing public distrust or fear.  There are abundant complex spatio-temporal information hiding behind the WTNs. However, there are limited studies that simultaneously model the spatio-temporal information of the WTNs for attack detection.  To this end, we propose a structured detection framework to integrate the spatio-temporal patterns of sensing data with an integrated one-class detection model.  Specifically, we first segment the sensing data of WTNs into a sequence of time segments.  Later, we develop a spatio-temporal representation framework. This framework has two key components. The first component is a temporal embedding module, which preserves the temporal effects of sensing data at time segments. Then, we construct a spatio-temporal graph (STG) by mapping the temporal embedding to the graph structure of WTNs based on sensor positions. The second component is a spatial embedding module, which learns fused embedding that preserves the spatio-temporal effects of cyber attacks jointly from the STG. After that, we build an integrated OC-SVM model that utilizes a new pairwise kernel to detect cyber attacks. The pairwise kernel augments the difference between normal and attack patterns by the similarity among fused embedding that is produced by the spatio-temporal representation module. Finally, we present extensive experimental results to illustrate the effectiveness of our method. Especially, our framework achieves 91.65% at Accuracy and improves 82.78% , 22.96% on average at F1 and AUC respectively compared with other baseline models.
  
  
  
  In this paper, we model the multi-scale temporal multi-channel graph anomaly structure in cyber attack detection to defend water treatment networks (WTNs). 
  While WTNs are a critical infrastructure for public health, WTNs are vulnerable to cyber attacks. 
  Effective detection of cyber attacks can defend WTNs against discharging contaminated water, denying access,  destroying equipment, and
  causing public distrust or fear. 
  We identify multi-scale temporal, multi-channel graph anomaly structure that is buried under the sensing data of WTNs.  
  However, there are limited studies that simultaneously model both multi-scale temporal information and multi-channel graph anomaly structure. 
  To this end, we propose a structured detection framework to integrate the multi-scale temporal multi-channel anomaly patterns with unsupervised one-class detection. 
  Specifically, we first segment the spatio-temporal sensing data of WTNs into a sequence of time segments. 
  Later, we develop a spatio-temporal representation framework to model the multi-scale temporal information and multi-channel graph structure. 
  This framework has two key components. 
  The first component is a temporal embedding module, which preserves intra-segment characteristics  to  map time segments into temporal embedding vectors. 
  Then, we regard each dimension of the temporal embedding as a signal channel and construct multi-channel sensor graphs based on the graph structure of WTNs for each segment.
  This graph not only reflects the connectivity of sensors, but also contains the temporal information of each sensor, which describes the spatio-temporal correlation of WTNs.
  The second component is a relational embedding module, which learns fused embedding from the multi-channel sensor graphs. 
  After that, we develop an integrated one-class detection and pairwise kernel. The pairwise kernel can model the inter-segment relationship to augment the difference of representations  between normal patterns and attack patterns. 
  Finally, we present extensive experimental results to illustrate the effectiveness of our method.
  
  
  
  
  
  § INTRODUCTION
  
  segment: delay durative
  Seq2Seq: intra-segment
  GCN: spatial 
  OC-svm inter segment
  
  
  1. Incorporating temporal effects
      a. seq2seq reconstruct original, first derive, second derive to preserve the data changing rate,
      data changing direction.
  2. Incorporating spatial effects
      a. MCSG preserve and fuse spatio-temporal features.
  3. Integrated OC-SVM
      a. OC-SVM pair wise kernel.
  
  
  
  Water Treatment Networks (WTNs) are critical infrastructures that utilize industrial control systems, sensors and communication technologies to control the water purification processes to improve the water quality and distribution for drinking, irrigation, or industrial uses. Although it is a critical infrastructure,
  WTNs are vulnerable to cyber attacks. 
  For example, the water sector reported the fourth largest number of incidents in 2016 [https://www.osti.gov/servlets/purl/1372266]. 
  How does a cyber attack to WTNs look like?
  Figure <ref> shows that a water treatment procedure includes six stages (i.e., P1-P6), each of which is monitored by sensors; a cyber attack compromises the RO Feed Pump sensor of P4 to change the levels of chemicals being used to treat tap water. 
  As a result, there is a compelling need for an effective solution to attack detection in WTNs. 
  
  
  
  
  In the literature, there are a number of studies about cyber attack detection in WTNs <cit.>.
  However, most of these studies only exploit traditional spaiotemporal data preprocessing and pattern extraction methods to distinguish attack patterns.
  Our preliminary explorations find that tremendous opportunities exist in solving the problem by teaching a machine to augment the differences between normal and attack patterns.
  To this end, in this paper, we aim to effectively solve the attack detection problem by augmenting the difference between normal and attack patterns in WTNs. 
  
  However, it is challenging to mine the spatio-temporal graph stream data of WTNs and identify the strategy to maximize the pattern divergence between normal  and attack behaviors. 
  By carefully examining the sensing data of WTNs, we identify three types of characteristics of cyber attacks: 
  (1) delayed effect, meaning that many attacks will not take effects immediately, but usually exhibit symptoms after a while;
  (2) continued effect, meaning that the effects of attacks will sustain for a while, not disappear rapidly;
  (3) cascading effect, meaning that the effects of attacks  propagate to other sensors across the whole WTNs. 
  Specifically, the delayed  and continued effects are both temporal, and the cascading effect is spatial. 
  More importantly, these three effects are mutually coupled, impacted, and boosted in WTNs.
  
  
  A new framework is required to address the margin maximization between normal and attack pattern learning, under the three coupled effects. 
  
  Along this line, we propose a structured detection framework.
  This framework has two main phases:
  (1) spatio-temporal representation learning, which includes two modules: incorporating temporal effects and  spatial effects;
  (2) improved unsupervised one-class detection, which utilizes a new designed pairwise kernel to make detection more accurate. 
  Next, we briefly introduce our structured spatio-temporal detection framework named STDO.
  
  Phase 1: Spatio-temporal representation learning.
  This phase aims to learn a good spatio-temporal representation over the sensing data of WTNs with two modules.
  The first module of this part is to integrate temporal effects.
  Cyber attacks in WTNs exhibit temporally-dependent attack behaviors, sequentially-varying attack purposes over time, and delayed negative impacts. 
  Traditional methods ( e.g., AR, MA, ARMA, ARIMA, arrival density of point process, change point detection) mostly model the patterns of data points at each timestamp.
  However, we identify that partitioning the sensing data into a sequence of time segments can help to better describe delayed and continued effect of attacks. 
  Therefore, we propose to segment the sensing data into a sequence of time segments. 
  We then exploit a sequence-to-sequence (seq2seq) embedding method to characterize the temporal dependencies within each time segment. 
  To improve the seq2seq method, we develop a new neural reconstruction structure to reconstruct not just a time segment, but also first and second derivatives of momentum of  the time segment. 
  In this way, the improved seq2seq method can have the awareness of  values, acceleration, and jerk (second order derivatives) of sensor measurements. 
  Through this module, we obtain the temporal embedding of each time segment of each  sensor.
  
  The second module is to integrate spatial effects.
  The effects of cyber attacks in WTNs will spatially diffuse and propagate to other sensors over time.
  Therefore, exploring the  propagation structure  can significantly model attack patterns and improve detection accuracy.
  However, how can we capture the spatial structures of propagation?
  The topology of WTNs is a graph of interconnected sensors.
  We map the temporal embedding of one time segment of a sensor to the graph of WTNs as node attributes.
  We construct the Spatio-Temporal Graphs (STGs), where a node is a sensor and an attribute is the temporal embedding of the sensor, to describe the state of the WTNs.
  In this way, the STGs not only contain spatial connectivity among different sensors, but also include temporal patterns by mapping temporal embedding. 
  We develop graph embedding model to jointly learn the state representations of the WTNs from the relational STGs.  
  
  Phase 2: Improving Unsupervised One-Class Detection Model. 
  In reality, WTNs are mostly normal yet with a small number of cyber attack events, so the attack data samples are quite rare. This trait makes the data distributions of normal and attack extremely imbalanced. How can we overcome the imbalanced data distribution to accurately detect cyber attack? One-class detection fits well this problem. In particular, one-class SVM (OC-SVM) is a popular detection model, in which a hyper-plane is identified to divide normal and abnormal data samples after being mapped to a high-dimmensional space by kernel functions. While vanilla OC-SVM achieves promising results, the kernel functions can be improved by exploiting the similarities between data samples.
  Specifically, we propose a new pair-wise kernel function to augment the distance between normal and attack patterns by preserving similarity across different data samples. Consequently, normal data samples are grouped into a cluster, while abnormal data samples are pushed away from normal data.
  In our framework, we feed the learned state representations of the WTN into the improved OC-SVM to use the pairwise kernel to detect attacks.
  
  In summary, we develop a structured detection framework for cyber attack detection in WTNs. 
  Our contributions are as follows:
  (1) we investigate an important problem of defending critical graph-structured infrastructures via cyber attack detection, which is important for building resilient and safe communities. 
  (2) we develop a structured detection framework to maximize the margin between normal and attack patterns, by integrating spatio-temporal knowledge, deep representation learning, and pairwise one-class detection. 
  (3) we implement and test our proposed framework with real-world water treatment network data and demonstrate the enhanced performance of our method.
  Specifically, our detection method achieves an accuracy of 91.65%, with average improvement ratios of 82.78%  and 22.96% with respect to F1 and AUC,  compared with baseline methods.
  
  
  In this paper, we develop a structured detection framework for early and precise detection of cyber attacks to defend Water Treatment Networks (WTNs).
  This research is based on a public research testbed - “SWaT”, which is a sensing data of WTNs that involves cyber and physical attacks <cit.>.
  WTNs utilize industrial control systems, sensors and communication technologies to control the water purification processes to improve the water quality and distribution for drinking, irrigation, or industrial uses.
  WTNs are critical infrastructures that must be protected from any sort of destruction. 
  However, WTNs are vulnerable to cyber attacks, and the water sector reported the fourth largest number of incidents in 2016 [https://www.osti.gov/servlets/purl/1372266].  
  
  
  
  Typically, WTNs control procedure includes six stages (i.e., P1-P6) which is composed by various sensors and managed by an industrial control system.  
  Figure <ref> shows a typical illustration of cyber attack in WTNs, in which a cyber attack compromises the RO Feed Pump sensor of P4, and changes the levels of chemicals being used to treat tap water, which further poison the water resulting in public disasters.
  Therefore, effective detection of cyber attack is highly desired for defending WTNs.
  
  
  
  
  
  
  
  
  After analyzing the massive sensory data of WTNs, we identify three types of characteristics of cyber attacks: 
  (1) delayed effect, referring to the fact that the effects of attacks would not immediately appear, but usually show symptoms after a while, as shown in Figure <ref>;
  (2) durative effect, referring to the observation that the effects of attacks would maintain for a time period, it would not disappear rapidly;
  and (3) cascading effect, referring to the phenomenon that the effects of attack would propagate to other unattacked sensors across the whole WTNs due to the connected network structure.
  Specifically, the delayed  and durative effect are both temporal effects of attacks, and cascading effect belongs to spatial effect of attacks. 
  
  
  
  
  In order to improve the performance of cyber attack detection, we capture the spaio-temporal effects of the WTNs completely and exploit an integrated one-class SVM (OC-SVM) algorithm to accomplish the attack detection task.
  Next, we briefly introduce our structured detection framework.
  
  Incorporating temporal effects.
  Cyber attacks in WTNs exhibit temporally-dependent attack behaviors, sequentially-varying attack purposes over time, and delayed negative impacts. 
  Intuitively, partitioning the sensing data into a sequence of time segments can capture delayed and durative effect of cyber attack better than only considering the data point at one timestamp.
  However, traditional methods ( e.g., AR, MA, ARMA, ARIMA, arrival density of point process, change point detection) is unable to take sequental segments as input.
  
  
  Therefore, to better capture the unique temporal effects of attacks in WTNs, we propose to segment the sensing data into a sequence of time segments, then we exploit a sequence-to-sequence (seq2seq) embedding method to characterize the temporal dependencies within each time segment. 
  Specifically, we reconstruct not only  the sensory data segments, but also first and second derivatives of the segments, which aims to capture both the instant and trend of change rate of the sensory data.
  Through this module, we obtain the temporal embedding of each time segment of all sensors.
  
  
  Incorporating spatial effects.
  The effects of cyber attacks in WTNs will spatially diffuse and propagate to other sensors over time.
  Therefore, exploring the structure of cyber attack propagation and fusing the effects of cyber attacks can significantly improve detection accuracy.
  But how we can capture the propagation spatial structure and fuse the cyber attack effects?
  We propose a spatio-temporal graph (STG) to combine the spatio-temporal characteristics of cyber attacks in WTNs together.
  Formally, the hidden topology structure of the WTNs is a graph that is constructed by the interconnected sensors.
  We map the temporal embedding of each sensor at one time segment to the graph of WTNs as node attributes.
  The attributed graph is one STG that not only contains the spatial information among different sensors but also includes the temporal effects of cyber attacks.
  In order to fuse the spatio-temporal effects of cyber attcks, we develop a graph representation module to map the STG into latent space.
  We obtain the ultimate latent embedding that sustains the spatio-temporal information of WTNs.
  
  
  
  
  
  However, it is challenging to explore the spatio-temporal information to profile anomalies, because there are many features of cyber attack in WTNs (e.g.,  delayed, propagation and mutation), as shown in Figure <ref>.
  But, how we can find an optimal set of dimensions to describe the spatial interaction patterns of sensors and fuse the temporal characteristics of sensing data?
  We propose a multi-channel sensor graph (MCSG) to combine the spatio-temporal information of WTNs together. 
  Formally, we map the temporal embedding vector of each time segment of all sensors to the WTNs to construct MCSG according to the sensor position in WTNs.
  Each dimension of embedding forms each channel of MCSG.
  The MCSG not only contains the latent temporal characteristics but also includes the spatial interactions among different sensors.
  After that, we pass forward the MCSG into the ultimate graph representation module to obtain the latent embedding of the MCSG.
  This embedding represents the spatio-temporal correlation in WTNs jointly. 
  
  
  Integrated One-Class Detection Model. 
  In the real scenario, the WTNs are usually normal with limited cyber attacks, so the attack data samples are scarce.
  Such fact makes the data distributions of normal and attack are extremely unbalanced.
  How to overcome the unbalanced data distribution to detect cyber attack accurately?
  One class classification models are suitable for this problem.
  Especially, one-class SVM (OC-SVM) is a popular model has attracted many attentions, in which a hyper-plane is found to divide normal and abnormal data samples after being mapped to higher dimmensions by kernal functions.
  While vanilla OC-SVM achieves promising results, the kernel functions can be improved by exploiting the similarities between data samples.
  Specifically, 
  
  
  we propose a new pair-wise kernel function to augment the distance between normal and attack patterns by preserving similarity of different data samples. 
  Consequently, normal data samples are grouped into a cluster, while abnormal data samples are pushed away.
  
  In our framework, we feed the embedding which contains spatio-temporal correlation of WTNs into an integrated OC-SVM module that using the pairwise kernel to detect cyber attacks in WTNs.
  
  
  
  
  
  
  
  Along these lines, in this paper, we develop a structured detection framework for cyber attack detection in WTNs. 
  Especially, our contributions are as follows:
  (1) We exploit a seq2seq method to model the temporal dependency of time segment, which captures the changing trend of sensing data in a time period.
  (2) We identify the spatio-temporal graph (STG) that describe the spatio-temporal correlation of cyber attack in WTNs and learn the fused embedding by a graph representation learning module.
  (3) We develop an integrated OC-SVM to detect cyber attack in WTNs with a new pair-wise kernel which is provided by us.
  (4) We implement and test our proposed detection framework with real world cyber attack data in a water treatment plant and demonstrate the enhanced performance of our method.
  
  
  
  
  
  
  
  
  
  
  
  Cyber physical systems (CPS) are ubiquitous in recent decades due to the period of vigorous development of hardware and internet.
  While CPS provide great potentials for the frontier of intelligent Internet of Things (IOT), the risk of suffering malicious behaviors and hazardous attacks is increasing significantly, which may lead to catastrophic consequences.
  Such facts make detecting attacks a vital topic for protecting critical infrastructures.
  Therefore, in this paper, we propose to study the problem of cyber attack detection for critical infrastructures on a public research testbed - “SWaT”, which is a water treatment network (WTN) that involves cyber and physical attacks <cit.>.
  
  
  
  It is appealing to modeling both the temporal and spatial effect of attacks to improve the accuracy of cyber attack detection.
  Next, we briefly introduce how to incorporate temporal and spatial effect of cyber attacks.
  
  
  Intuitively, comparing to only consider one single data point at one time stamp, partitioning the sensing data into sequence of segments can better capture the delay effects and durative effects, which further help model temporal effects of attacks. 
  Moreover, partitioned segments raise multi-scale temporal information (1) micro-scale, which is the temporal dependency within segments, and (2) macro-scale, which is the temporal dependency across segments. 
  
  
  
  
  
  
  
  
  
   
  
  
  
  § PROBLEM STATEMENT AND FRAMEWORK OVERVIEW
  
  We first introduce the statement of the problem, and then present an overview of the framework.
  
  
  
  
  
  
   §.§ Problem Statement
  
  We aim to study the problem of cyber attack detection using the sensing data of WTNs. 
  We observe that cyberattacks in WTNs exhibit not just spatial diffusion patterns, but also two temporal effects (i.e., delayed and continued).
  As a result, we partition the sensing data streams into non-overlapped time segments. 
  We investigate detection on the time segment level.
  
  	
  The WTN Attack Detection Problem. 
  Formally, assuming a WTN consists of N sensors, given the sensing data streams of a WTN, we evenly divide the streams into m non-overlapped segments by every K sensory records.
  Consequently, we obtain a segment sequence  𝐒=[𝐒_1, 𝐒_2, ⋯, 𝐒_i, ⋯, 𝐒_m], where the matrix 𝐒_i ∈ℝ^N × K is the i-th segment.
  Each segment is associated with a cyber attack status label:  if a cyber attack happens within 𝐒_i, the label of this segment is marked as y_i = 1; Otherwise, y_i = 0.
  The objective is to develop a framework that takes the segment sequence 𝐒 as inputs,  and output the corresponding cyber attack labels for each segment to maximize detection accuracy.
  
  
  
  
  
   §.§ Framework Overview
  
  Figure <ref> shows that our framework includes two phases:
  (1) Spatio-temporal representation learning (P1); 
  (2) Improving unsupervised one-class detection (P2).
  Specifically, there are two modules in Phase 1:
  (a) Embedding time segment sequential patterns, in which a seq2seq model is leveraged to capture the temporal dependencies within a segment.
  Later, the learned representations are attached to each node (sensor) in the WTNs as node attributes to construct STGs. Be sure to notice that temporal patterns are integrated by attaching temporal embeddings as attributes; and spatial connectivity is integrated via a graph structure of sensors, which is introduced next. 
  (b) Modeling spatio-temporal patterns over STGs, in which the fused embedding is learned through an encode-decode paradigm integrated with Graph Convolutional Network (GCN). 
  The fused embedding summarizes the information of STGs to profile the spatio-temporal characteristics in WTNs.
  Finally, the Phase 2 exploit the fused embedding as inputs to detect attacks.
  The Phase 2 has one module, namely anomaly detection with pairwise segment similarity awareness. 
  Specifically,  the fused embedding is fed into an improved one-class anomaly detector integrated with awareness of pairwise segment similarity.
  Specifically, the similarities between two different segment embedding vectors are introduced to the pairwise kernel of the detector to augment the distance between normal and attack patterns.
  
  
  
  
  
  § PROPOSED METHOD
  
  We first introduce time segment embedding, then illustrate the construction of spatio-temporal graphs using temporal embedding and sensor networks, present spatio-temporal graph-based representation learning, and, finally, discuss the integration with one-class detection. 
  
  
  
   §.§ Segmentation of Sensing Data Streams
  
  The cyber attacks in WTNs cause abnormal sensing measurements.
  The symptoms of cyber attacks usually donot exhibit immediately (delayed effect) and maintains for a while (continued effect).
  To capture the two effects, we partition the sensing data of a WTN into a sequence of non-overlapped time segments. 
  Each segment represent the sensing measurements of a fixed length of time. 
  
  
  
  
  
  
  Figure <ref> shows how we segment the streams. 
  Specifically,  consider the existence of n sensors in a WTN, and the time range of data collection is  [t_1 ∼ t_n].
  There are n data streams. 
  We partition all the n streams into m segments, denoted by 𝐒_seq = [𝐒_1,𝐒_2,...,𝐒_m].
  Each segment 𝐒_i includes q time points, denoted by 𝐒_i = [𝐯_i^1,𝐯_i^2,…,𝐯_i^q], where 𝐯_i^q represents the sensing data value at q_th timestamp in i-th time segment and the time range is [t_1 ∼ t_q].
  Meanwhile, we label the WTNs cyber attack status based on the rule that if a cyber attack happens at a time point in one temporal segment, the status of WTNs is labeled 1 (attack) in the segment, otherwise, it is labeled 0 (normal).
  So we obtain the WTNs status label set based on 𝐒_seq, denoted by 𝐋_seq = [𝐥_1,𝐥_2,…, 𝐥_m].
  Through these steps, we obtain non-overlapped temporal segments and the corresponding WTNs status label set.
  
  
  
  
  
   §.§ Embedding Time Segments Sequential Patterns
  
  
  We first model the sequential patterns of time segments.
  The sequential patterns of WTN involves two essential measurements: (1) changing rate and (2) the trend of changing rate, which correspond to the first and second derivatives respectively.
  Therefore, in addition to the raw data points in one segment, we introduce both the first and second derivatives to quantify the sequential patterns, resulting in an augmented segment. Formally, blow we define the augmented segment.
  
  Augmented Segment. Given a sensory data segment denoted by  𝐒_i=[𝐯_i^1, 𝐯_i^2, ⋯, 𝐯_i^k, ⋯, 𝐯_i^K], where 𝐯_i^k ∈ℝ^N× 1 denotes the sensory measurements of all the sensors of the i-th segment at the k-th record.
  Then, the corresponding first-order derivative segment 𝐒_i^' is 𝐒_i^'=[∂𝐒_i/∂𝐯_i^2, ∂𝐒_i/∂𝐯_i^3, ⋯, ∂𝐒_i/∂𝐯_i^K], and the corresponding second-order derivative segment 𝐒_i^” is 𝐒_i^”=[∂𝐒_i^'/∂𝐯_i^3, ∂𝐒_i^'/∂𝐯_i^4, ⋯, ∂𝐒^'/∂𝐯_i^K].
  The augmented segment 𝐒̃_i is then defined as the concatenation of the raw segment, the first-order  derivative segments, and the second-order  derivative segments: 𝐒̃_i = [𝐒_i, 𝐒_i^', 𝐒_i^”].
  For convenience, 𝐒̃_i also can be denoted as 𝐒̃_i=[𝐫_i^1, 𝐫_i^2,…,𝐫_i^3K-3], where 
  elements in [𝐫_i^1, 𝐫_i^2, ⋯, 𝐫_i^K] corresponds to each element in 𝐒_i, 
  elements in [𝐫_i^K+1, 𝐫_i^K+2, ⋯, 𝐫_i^2K-1] corresponds to each element in 𝐒^'_i, 
  and the elements in [𝐫_i^2K, 𝐫_i^2K+1, ⋯, 𝐫_i^3K-3] corresponds to each element in 𝐒^”_i respectively.
  
  
  We here provide an example of constructing an augmented segment. 
  Suppose there are two sensors in WTNs, there are three measurement records in each time segment.
  In such WTN, N is 2 and K is 3.
  Considering the i-th segment 𝐒_i = [[1,3,4],[2,8,5]], the size of 𝐒_i is 2×3. 
  We then calculate the 𝐒^'_i by row: 𝐒^'_i = [[2,1],[6,-3]].
  Afterward, 𝐒^”_i=[[-1],[-9]].
  Finally, we concatenate these three segments by row: 𝐒̃_i =
  [[1,3,4,2,1,-1]
  [2,8,5,6,-3,-9]].
  
  Figure <ref> shows the process of temporal embedding.
  The temporal embedding process develops a seq2seq model based on the encoder-decoder paradigm that takes a non-augmented segment as inputs, and reconstructs the corresponding augmented segment.
  The objective is to minimize the loss between the original augmented segment and the reconstructed one.
  Next, we provide an example about how our model operate the i-th segment 𝐒_i.
  
  The encoding step feeds the segment 𝐒_i into a seq2seq encoder, and outputs the latent representation of the segment 𝐔_i.
  Formally,  as shown in Equation <ref>, given the segment data 𝐒_i=[𝐯_i^1, 𝐯_i^2, …, 𝐯_i^K],
  the first hidden state 𝐡^1 is calculated by the first time step value. 
  
  Then recursively, the hidden state  of the previous time step 𝐡^t-1 and the current time step value 𝐯_i^t are fed into a LSTM model to produce the current time step hidden state 𝐡^t.
  Finally, we concatenate all of the hidden states by row (sensor) to obtain the latent feature matrix 𝐔_i.
  
  
      {[               𝐡^1 =σ (𝐖_e 𝐯_i^1 + 𝐛_e),                                        ; 𝐡^t=LSTM([𝐯_i^t, 𝐡^t-1]), ∀ t ∈{2,…,K},;        𝐔_i = CONCAT(𝐡^1, 𝐡^2, … , 𝐡^K),                                         ].
  
  where 𝐖_e and 𝐛_e are the weight and bias of the encoding step, respectively.
  
  In the decoding step, the decoder takes 𝐔_i as inputs and generates a reconstructed augmented segment: [𝐫̂_i^1,𝐫̂_i^2, …, 𝐫̂_i^3K-3]. 
  Formally, as shown in Equation <ref>, the first hidden state ĥ^1 of the decoder is copied from the last hidden state of encoder 𝐡^K. 
  Then, the previous time step hidden state ĥ^t-1, the previous time step element 𝐫̂_i^t-1, and the latent feature vector 𝐔_i are input into the LSTM model to produce the current time step hidden state ĥ^t.
  Finally, the reconstructed value of current time step 𝐫̂_i^t  is produced by current hidden state ĥ^t that is activated by sigmoid function σ. 
  
  
      {[                                                                                  𝐡̂^1 = 𝐡^K,;                                                                𝐫̂_i^1 = σ(𝐖_d 𝐡̂^̂1̂ + 𝐛_d),; 𝐡̂^t = LSTM([
                   𝐫̂^t-1_i, 𝐡̂^t-1,
                   𝐔_i
                   ]), ∀ t ∈{2,…,K},;                                                 𝐫̂_i^t = σ(𝐖_d 𝐡̂^̂t̂ + 𝐛_d),  ∀ t ∈{2,…,K},;                                                                                              ].
  
  where 𝐖_d and 𝐛_d are the weight and bias for the decoding step respectively.
  
  After the decoding step, we obtain the reconstructed augmented segment sequence [𝐫̂_i^1, 𝐫̂_i^2, …, 𝐫̂_i^3K-3]. 
  The objective is to minimize the reconstruction loss between the original and reconstructed augmented segment sequence.
  The overall loss is denoted as 
  
      min∑_i=1^m∑^3K-3_k=1 || 𝐫_i^k - 𝐫̂_i^k ||^2.
  
  
  Along this line, we obtain the latent temporal embedding at the i-th time segment, denoted by 𝐔_i.
  
  
  
   §.§ Temporal Embedding as Node Attributes: Constructing Spatio-temporal Graphs
  
  
  
  
  The temporal embedding, obtained by Section <ref>, describes and models the temporal effects of cyber attacks.
  Then, to further incorporate the spatial effects of WTNs, we map the temporal embedding to WTNs as node attributes.
  Taking the temporal embedding of the i-th segment 𝐔_i as an example.
  Since each row of  𝐔_i is a temporal embedding of a segment of one senor (node), we mapped each row of 𝐔_i to the corresponding node (sensor) as attributes, resulting in an attributed WTNs G_i, which we call a Spatio-temporal Graph (STG) that preserves both the spatial and temporal effects.
  
  
  
  
  
  
  
  
  
  
  
  
  
  
   §.§ Learning Representations of STGs
  
  Figure <ref> shows that we develop a spatiotemporal graph representation learning framework to preserve not just temporal patterns, but also spatial patterns in a latent embedding space.
  We take the STG of the i-th time segment, G_i, as an example to explain the representation process.
  Formally, we denote G_i by G_i = (𝐔_i,𝐀_i), where 𝐀_i is an adjacency matrix that describes the connectivity among different sensors;
  𝐔_i is a feature matrix that is formed by the temporal embedding of all the sensors of the i-th time segment.
  The representation learning process is formulated as: given the i-th STG G_i, the objective is to minimize the reconstruction loss between the input G_i and the reconstructed graph Ĝ_i, by an encoding-decoding framework, in order to learn a latent embedding 𝐳_i.
  
  The neural architecture of the encoder includes two Graph Convolutional Network (GCN) layers. 
  The first GCN layer take 𝐀_i and 𝐔_i  as inputs, and then outputs the lower-dimensional feature matrix Û_i.
  
  Specifically, the encoding process of the first GCN layer is given by: 
  
      Û_i    = 
          RELU(GCN(𝐔_i,𝐀_i)) 
         =RELU(𝐃̂_i^-1/2𝐀_i𝐃̂_i^-1/2𝐔_i𝐖_0)
  
  where 𝐃̂_̂î is the diagonal degree matrix of G_i, and  𝐖_0 is the weight matrix of the first GCN layer.
  
  Since the latent embedding 𝐳_i of the graph is sampled from one prior normal distribution, here the purpose of the second GCN layer is to assess the parameters of the prior distribution.
  This layer takes 𝐀_i and Û_i as the input, then produces the mean value μ and the variance value δ^2 of the prior normal distribution as the output. 
  
  Thus the encoding process of the second GCN layer can be formulated as 
  
      μ,log(δ^2) = GCN(
          𝐔̂_i,𝐀_i)
           = 𝐃̂_i^-1/2𝐀_i𝐃̂_i^-1/2𝐔̂_i𝐖_1,
  
  where 𝐖_1 is the weight matrix of the second GCN layer.
  Then we utilize the reparameterization trick to mimic the sample operation to construct the latent representation 𝐳_i.
  The process is formulated as 
  
      𝐳_i=μ+δ×ϵ,
  
  where ϵ∼𝒩(0,1).
  
  The decoding step takes the latent representation 𝐳_i as the input and outputs the the reconstructed adjacent matrix Â_i.
  The decoding process is denoted as 
  
      Â_i = σ(𝐳_i𝐳_i^T).
  
  In addition, the core calculation of the decoding step can be denoted as 𝐳_i𝐳_i^T = 𝐳_i𝐳_i^Tcosθ.
  Owing to the 𝐳_i is the node level representation, the inner product calculation is helpful to capture the correlation among different sensors.
  
  We minimize the joint loss function ℒ_g during the training phase, which is formulated as Equation <ref>.
  ℒ_g includes
  two parts. 
  The first part is Kullback-Leibler divergence between the distribution of 𝐳_i and the prior standard normal distribution denoted by 𝒩(0,1).
  The second part is the squared error between 𝐀_i and Â_i.
  Our training purpose is to make the  Â_i as similar as 𝐀_i, and to let the distribution of 𝐳_i as close as 𝒩(0,1).
  The total loss is denoted as 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
      ℒ_g = ∑_i=1^m
              KL[q(𝐳_i|𝐗_i,𝐀_i) || p(𝐳_i)]
              _KL Divergence between q(.) and p(.)
              +
              ∑_j=1^w𝐀_i-𝐀̂_i ^2 
              ^Loss between 𝐀_i and Â_i
  
  
  When the model converges, we apply the global average aggregation to 𝐳_i. 
  Then the 𝐳_i becomes the graph-level representation of the WTNs, which contains the spatio-temporal information of the whole system at i-th time segment.
  
  
  
  
   §.§ One-Class Detection with Data Similarity Awareness
  
  In reality, most of sensor data are normal, and attacks related data are scarce and expensive.
  This indeed results into the problem of unbalanced training data.
  How can we solve the problem?
  Can we develop a solution that only uses normal data for attack detection?
  This is the key algorithm challenge for this phase. 
  One-class classification is a promising solution that aims to find a hyperplane to distinguish normal and attack patterns only using normal data.
  Specifically, OC-SVM is a classical one-class classification model. OC-SVM includes two steps:
  (1) mapping low dimensional data into a high dimensional feature space by a kernel function. 
  (2) learning the parameters of hyper-plane to divide normal and abnormal data via  optimization.
  
  Intuitively, in the hyperspace provided by OC-SVM, the normal (or abnormal) data are expected to be closer, while there should be a large distance between normal and abnormal data.
  In other words, similar data points should be closer to each other than dissimilar ones.
  However, traditional kernel functions (e.g., linear, nonlinear, polynomial, radial basis function (RBF), sigmoid) cannot preserve such characteristic well. 
  
  How can we make  data samples well-separated in order to achieve such characteristic?  
  To address the question, we propose a new pairwise kernel function that is capable of reducing the distances between similar data points, while maximizing the distances between dissimilar ones.
  Formally, given the representation matrix 𝐙 = [𝐳_1, ⋯, 𝐳_i, ⋯, 𝐳_m], the pairwise kernel function is given by :
  
      Kernel = tanh(1/𝒟( 𝐙)𝐙𝐙^T+sim(𝐙, 𝐙^T)+𝐜)
  
  where 𝐙^T is the transpose of 𝐙, 𝒟(𝐙) is the covariance matrix of 𝐙, and sim(𝐙, 𝐙^T) ∈ℝ^N × N is the pairwise similarity matrix between segments. 
  
  Compared with the vanilla sigmoid kernel function, we add sim(𝐙, 𝐙^T), where the  range of sim(𝐙, 𝐙^T) is [-1,1].
  If two segments are more similar, the corresponding value in sim(𝐙, 𝐙^T) is closer to 1. 
  Otherwise, the value is closer to -1.
  Therefore, when two segments are similar (e.g., both are normal or abnormal samples), the proposed parwise kernel function will push these two segments closer; otherwise, these two segments will be set away from each other.
  
  
  
  
  
  
  The pairwise kernel is able to enlarge the distance among different category samples in feature space, which makes the OC-SVM converge more easily and detect cyber attacks more accurate.
  Figure <ref> shows the detection process of  cyber attacks.
  The spatio-temporal embedding 𝐳_i is fed into the  integrated OC-SVM to detect cyber attacks by utilizing the pairwise kernel function, and to output the corresponding status labels of WTNs, to indicate whether a cyber attack happen or not at the i-th time segment.
  
  
  
   §.§ Comparison with Related Work
  
  Recently, lots of attempts have been made to detect cyber attacks in WTNs.
  For instance, Lin et al. utilized a probabilistic graphical model to preserve the spatial dependency among sensors in WTNs and a one-class classifier to detect cyber attacks <cit.>.
  Li et al. regarded the LSTM and RNN as the basic model of the GAN framework to develop an anomaly detection algorithm to detect cyber attacks in WTNs <cit.>.
  Raciti et al. constructed one real-time anomaly detection system based on cluster model <cit.>.
  However, these models exhibit several limitations when detecting cyber attacks: (i) the changing trend of sensing data in a time segment is not preserved; 
  (ii) the spatial patterns among sensors are captured partially;
  (iii) the similarity between different data samples is not utilized completely. 
  
  In order to overcome these limitations, we propose a new spatio-temporal graph (STG) to preserve and fuse spatio-temporal effects of WTNs simultaneously.
  Moreover, a new pairwise kernel that utilizing the data similarity to augment the distance among different patterns is also proposed to improve the accuracy of cyber attack detection.
  
  
  
  
  
  
  
  
  § EXPERIMENTAL RESULTS
  
  We conduct experiments to answer the following research questions:
  
      
    * Does our proposed outlier detection framework (STOD) outperforms the existing methods?
      
    * Is the spatio-temporal representation learning component  of STOD necessary for improving detection performance?
      
    * Is the proposed pairwise kernel better than other traditional kernels for cyber attack detection?
      
    * How much time will our method and other methods cost?
  
  
  
  
   §.§ Data Description
  
  We used the secure water treatment system (SWAT) data set that is from Singapore University of Technology and Design for our study.
  The SWAT has project built one water treatment system  and a sensor network to monitor and track the situations of the system.
  Then, they construct one attack model to mimic the cyber attack of this kind of system in the real scenario.
  The cyber attacks to and the sensory data of the system are collected to form the SWAT dataset. 
  Table <ref> show some important statistics of the SWAT dataset. 
  Specifically, the SWAT dataset include a normal set (no cyber attacks)  and an attack set (with cyber attacks). The time period of the normal data is from 22 December 2015 to 28 December 2015. 
  The time period of the attack data  is from 28 December 2015 to 01 January 2016, and 01 February 2016. 
  There is no time period overlap between the normal data and the attack data on 28 January 2015.
  It is difficult to identify more water treatment network datasets. In this study, we focus on validating our method using this dataset. 
  
  
  
  
  
  
   §.§ Evaluation Metrics
  
  We evaluate the performances of our method in terms of four metrics. 
  Given a testset, a detection model will predict a set of binary labels (1: attack; 0: normal). 
  Compared predicted labels with golden standard benchmark labels, we let tp, tn, fp, fn be the sizes of the true positive, true negative, false positive, false negative sets, respectively. 
  
  
  
    * Accuracy: is given by:
  
      Accuracy = tp+tn/tp+tn+fp+fn
  
  
  
    * Precision: is given by:
  
      Precision = tp/tp+fp
  
  
  
    * F-measure: is the harmonic mean of  precision and recall, which is given by:
  
      F-measure = 2× Precision × Recall/Precision+Recall
  
  
  
    * AUC: is the area under the ROC curve. It shows the capability of a model to distinguish between two classes.
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
   §.§ Baseline Algorithms
  
  We compare the performances of our method (STOD) against the following ten baseline algorithms.
  
  
      
    * DeepSVDD <cit.>:  expands the classic SVDD algorithm into a deep learning version. It utilizes a neural network to find the hyper-sphere of minimum volume that wraps the normal data. If a data sample falls inside of the hyper-sphere, DeepSVDD classifies the sample as  normal, and attack otherwise.
      In the experiments, we set the dimensions of the spatio-temporal embedding 𝐳_i to 28 × 28.
      
      
    * GANomaly <cit.>: is based on the GAN framework.
      It develop a new version of generator by using the encoder-decoder-encoder structure. 
      The algorithm regards the difference between the embedding of the first encoder and the embedding of the second encoder as the anomaly score to distinguish normal and abnormal.
      In the experiments, we set the dimension of the spatio-temporal embedding vector 𝐳_i into 28 × 28.
      
      
    * LODA <cit.>: is an ensemble outlier detection model. It collects a series of weak anomaly detectors to produce a strong detector. In addition, the model fits real-time data flow and is resistant to missing values in the data set. In the experiments, we fed the learned representations into the LODA to detect.
      
      
    * Isolation-Forest <cit.>.
      The IsolationForest isolates observations by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of the selected feature. In the experiments, we input spatio-temporal embedding vector 𝐳_i into Isolation-Forest, and set the number of estimators = 100, max sample numbers = 256.
      
      
    * LOF <cit.>. 
      The principle of LOF is to measure the local density of data samples. 
      If one data sample has low local density, the sample is an outlier. Otherwise, the sample is a normal sample. 
      In the experiments, we input the spatio-temporal embedding vector 𝐳_i into LOF and set the number of neighborhood = 20, the distance metric for finding neighborhoods is euclidean distance.
      
      
    * KNN <cit.>.
      KNN selects k nearest neighborhoods of one data sample based on a distance metric.
      KNN calculates the anomaly score of the data sample according to the anomaly situation of the k neighborhoods. 
      In the experiments, we input spatio-temporal embedding vector 𝐳_i into KNN, and set the number of neighborhoods = 5, the adopted distance metric is euclidean distance.
      
      
    * ABOD <cit.>.
      The ABOD method uses angle as a more robust measure to detect outliers. If many neighborhoods of one sample locate in the same direction to the sample, it is an outlier, otherwise, it is a normal sample.
      In the experiments, we input spatio-temporal embedding 𝐳_i into ABOD, set k = 10. The angle metric is cosine value.  
      
      
    * STODP1. We proposed to partition the sensing data into non-overlapped segments. The global mean pooling technique was then applied to fuse the segments of different sensors into an averaged feature vector. We fed the fused feature vector  into OC-SVM for outlier detection. 
      The kernel of OC-SVM is defined in Equation <ref>.
      
      
    * STODP2. We applied the global mean pooling 
      to the temporal embedding vectors generated by Section 3.A to obtain a global feature vector of WTN, which was fed into OC-SVM for outlier detection.
      In addition, the kernel of OC-SVM is our proposed kernel function defined in Equation <ref>.
      
      
    * STODP3. In order to study the effect of Seq2Seq, we remove the Seq2Seq module of our framework pipeline.
      The temporal segments of different sensors are organized as graph set.
      The graph set is input into graph embedding module to obtain the final embedding.
      Finally, the embedding is input into OC-SVM to do outlier detection.
      The kernel of the OC-SVM is  defined in Equation <ref>.
  
  
  
  
  
  In the experiments, the spatio-temporal representation learning phase of our framework is used to preserve the spatio-temporal patterns and data characteristics into feature learning. 
  The one-class outlier detection phase of our framework is used to detect the cyber attack status of the water treatment system based on the spatio-temporal representation.
  We only use normal data to train our model. 
  After the training phase, our model has the capability to detect the status of the testing data set that contains both normal and attack data.
  All the evaluations are performed on a x64 machine with Intel i9-9920X 3.50GHz CPU and 128GB RAM. The operating system is Ubuntu 18.04. 
  
  
  
  
  
  
   §.§ Overall Performances
  
  
  We compare our method with the baseline models in terms of accuracy, precision, f-measure and AUC. 
  Figure <ref> shows the average performances of our mtehod (STOD) is the best in terms of accuracy, f-measure and AUC; our method ranks second in terms of precision, compared with other baseline models. 
  A potential interpretation of such observation is that the STOD captures the temporal effects (delayed , continued) and spatial effect (cascading) of cyber attacks by spatio-temporal representation learning part of STOD in a balanced way. 
  With STOD captures more intrinsic features of cyber attacks, the model not only finds more attack samples but also makes fewer mistakes on normal samples.
  Thus, the distinguishing ability of STOD is improved greatly.
  But on a single evaluation metric, STOD maybe poorer than other baselines.
  Overall, STOD outperforms with respect to Accuracy, F-measure and ACU compared with baseline models, which signifies our detection framework owns the best attack detection ability.
  
  
  
  A potential interpretation of such observation is that our method learns the characteristics of both normal and attack patterns in a balanced way. 
  Thus, our method can capture more intrinsic rules of cyber attacks, which makes STOD not only find more attack samples but also make fewer mistakes on normal samples.
  This balanced learning way causes the STOD does not rank 1_st in terms of Precision and Recall respectively, but the comprehensive metric F-Measure is the most excellent.
  Other baseline models can not achieve this performance due to the limitations that they can not capture more features in data.
  Thus STOD model ranks 1_st with respect to Accuracy, F-measure and AUC, which signifies our framework owns the best cyber attack detection ability than other baselines.
  
  
  
  
  
  
  Another observation is that the performances of LOF, ABOD, and KNN are much worse than other models. 
  The possible reason is that these models exploit distance or angle-based assessment strategies.
  These geometrical measurements are vulnerable after projecting data into high dimensional space due to the “curse of dimensionality”.
  Thus, these models can not achieve excellent performances.
  
  
  
   §.§ Study of Representation Learning
  
  
  The representation learning phase of our framework include:
  (1) partitioning sensor data streams into segments;
  (2) modeling the temporal dependencies with seq2seq;
  (3) modeling the spatial dependencies with graph embedding.
  What role does each of the three steps play in our framework?
  
  
  We will iteratively remove each of the three steps to obtain three different variants, namely STODP1, STODP2, STODP3. 
  We then test compare the three variants with our original framework to examine the importance of the removed step for improving detection performances
  
  Figure <ref> shows the experimental results of STOD, STODP1, STODP2, and STODP3, which clearly show that STOD outperforms STODP1, STODP2, and STODP3 in terms of accuracy, precision, f-measure, and AUC with a large margin.
  A reasonable explanation of this phenomenon is that attack patterns are spatially and temporally structured, and, thus, when more buried spatio-temporal patterns are modeled, the method becomes more discriminant. 
  The results validate the three steps (segmentation, temporal, spatial) of the representation learning phase is critical for attack pattern characterization. 
  
  
  
   §.§ Study of Pairwise Kernel Function 
  
  
  The kernel function is vital for the SVM based algorithm family. An effective kernel function can map challenging data samples into a high-dimensional space, and make these data samples more separable in the task of detection. 
  We design experiments to validate the improved performances of our pairwise kernel function by comparing our pairwise kernel function with  other baseline kernel functions.
  Specifically, the baseline kernels are as follows:
  
      
    * linear. This kernel is a linear function. There are limited number of parameters in the linear kernel, so the calculation process is quick. The dimension of the new feature space is similar to the original space.
      
    * poly. This kernel is a polynomial function.
      The parameters of the kernel are more than the linear kernel.
      It maps data samples into high dimensional space.
      
    * rbf. This kernel is a Gaussian function that is a non-linear function. It exhibits excellent performance in many common situations.
  
    * sigmoid. This kernel is a sigmoid function.
  When SVM utilizing this function to model data samples, the effect is similar to using a multi-layer perceptron. 
      
  
  
  
  
  
  
  Figure <ref> shows a comparison between our kernel and other baseline kernels with respect to all evaluation metrics. 
  We observed that our kernel shows significant improvement, compared with other baseline kernels, in terms of Accuracy, Precision, F-measure, and AUC, 
  This indicates that our kernel can effectively augment the attack patterns in original data, and maximize the difference between normal and attack patterns, by mapping original data samples into high dimensional feature space. 
  This experiment validates the superiority of our pairwise kernel function.
  
  
  
  
   §.§ Study of Time Costs
  
  We aim to study the time costs of  training and testing in different models. 
  Specifically, we divided the dataset into six non-overlap folds. 
  We then used cross-validation to evaluate the time costs of different models.
  
  
  
  Figure <ref> shows the comparison of training time costs among  different models. 
  We find that the training time costs of each model is relatively stable. 
  An obvious observation is GANomaly has the largest training time cost than other models. This is because the encoder-decoder-encoder network architecture design is time-consuming.
  In addition, the training time of STOD is slightly longer than OC-SVM. 
  This can be explained by the fact that the similarity calculation of pairwise kernel function increases time costs, since we need to calculate the similarities between two representation vectors of each training data sample.
  
  
  
  Figure <ref> shows the comparisons of testing time costs among different models. 
  The testing time costs of each model are relatively stable as well. And  many of them can complete the testing task within one second,  except GANomaly. 
  We find the testing time of our method is shorter than the training time by comparing Figure <ref> and Figure <ref>.
  This can be explained by a strategy of our method:  once the model training is completed, our method stores the kernel mapping parameters in order to save time of computation. 
  In addition, GANomaly still shows the largest testing time cost.
  The reason is that the testing phase of GANomaly needs to calculate two representation vectors of each testing data samples, and, thus, GANomaly doesn't use less time, compared with that of the training phase.
  
  
  
  
   §.§ Case Study: Visualization for Spatio-temporal Embedding
  
  The spatio-temporal representation learning phase is an important step in our structured detection framework. 
  An effective representation learning method should be able to preserve the patterns of normal or attack behaviors and maximize the distances between normal and attack in the detection task.
  We visualize the spatio-temporal embedding on a 2-dimensional space, in order to validate the discriminant capabilities of our learned representations. 
  Specifically, we first select 3000 normal and 3000 attack spatio-temporal embedding respectively.
  We then utilize the T-SNE manifold method to visualize the embedding.
  Figure <ref> shows the visualization results of normal and attack data samples.
  We find that our representation learning result is discriminant in a transformed 2-dimensional space.
  As can be seen, the learned normal and attack representation vectors are clustered together to form dense areas. The observation shows that non-linear models are more appropriate for distinguishing normal and attack behaviors than linear methods.
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  § RELATED WORK
  
  
  Representation Learning. Representation learning is to learn a low-dimensional vector to represent the given data of an object. 
  Representation learning approaches are three-fold: (1) probabilistic graphical models; (2) manifold learning approaches; (3) auto-encoder and its variants;
  The main idea of the probabilistic graphical model is to learn an uncertain knowledge representation by a Bayesian network <cit.>.
  The key challenge of such methods is to find the topology relationship among nodes in the probabilistic graphical model.
  The manifold learning methods utilize the non-parametric approach to find manifold and  embedding vectors in low dimensional space based on neighborhood information <cit.>. 
  However, manifold learning is usually time-costly. 
  The discriminative ability of such methods is very high in many applications. 
  Recently, deep learning models are introduced to conduct representation learning.
  The auto-encoder model is a classical neural network framework, which embeds the non-linear relationship in feature space via minimizing the reconstruction loss between original and reconstructed data <cit.>. 
  When representation learning meets spatial data, autoencoders can inetgrate with spatio-temporal statistical correlations to   learn more effective embedding vectors.   <cit.>. 
  For instance, Singh et al, use the auto-encoder framework to learn the spatio-temporal representation of traffic videos to help detect the road accidents <cit.>. 
  Wang et al. utilize spatio-temporal representation learning to learn the intrinsic feature of GPS trajectory data to help analyze  driving behavior <cit.>.
  
  Deep Outlier Detection.  Outlier detection is a classical problem with important applications, such as,  fraud detection and cyber attack detection.
  Recently, deep learning has been introduced into outlier detection.
  According to the availability of outlier labels, deep anomaly detection can be classified into three categories:
  (1) supervised deep outlier detection;
  (2) semi-supervised deep outlier detection;
  (3) unsupervised deep outlier detection.
  First, supervised deep outlier detection models usually train a deep classification model to distinguish whether  a data sample is normal or not <cit.>.
  These models are not widely available in reality,  because it is difficult to obtain data labels of outliers. 
  Meanwhile, data imbalance is a serious issue that degrades the performances of supervised models. 
  Second, semi-supervised outlier detection methods usually train a deep auto-encoder model to learn the latent embedding of normal data <cit.>, then the learned embedding vectors are used to accomplish outlier detection task.
  In deep semi-supervised outlier detection, one-class classification is an important research direction.
  For instance, Liu et. al, proposed to detect the anomaly data on uncertain data by SVDD algorithm <cit.>. Many experiments have shown the adaptability of one class SVM. 
  Third, unsupervised outlier detection models do not need any label information, they detect outliers depends on the intrinsic rules (e.g., scores, distance, similarity) of data <cit.>.
  Such methods are appropriate for scenarios that are hard to collect label information.
  
  Cyber Attack Detection in Water Treatment Network. Water purification plants are critical infrastructures in our local communities. 
  Such infrastructures are usually vulnerable to cyber attacks. 
  Early detection of cyber attacks in water treatment networks is significant for defending our infrastructure safety and public health.  
  There are many existing studies about outlier detection in water treatment networks <cit.>. 
  For instance, Adepu et al. studied the impact of cyber attacks on water distribution systems <cit.>. 
  Goh et al. designed an unsupervised learning approach that regards Recurrent Neural Networks as a temporal predictor to detect attacks <cit.>.
  Inoue et al. compared the performances of Deep Neural Network and OC-SVM on outlier detection in water treatment networks <cit.>. 
  Raciti et al. developed a real-time outlier detection system by  clustering algorithms and deployed the system into a water treatment network <cit.>.
  However, there is limited studies that integrate deep graph representation learning, spatiotemporal patterns, and one-class detection to more effectively address cyber attack problems.  
  
  
  
  
  
  § CONCLUSION REMARKS
  
  We studied the problem of cyber attack detection in water treatment networks. 
  To this end, we proposed a structured detection framework to integrate spatial-temporal patterns, deep representation learning, and one-class detection. 
  Specifically, we first partitioned the sensing data of WTNs into a sequence of fixed-size time segments. 
  We then built a deep spaiotemporal representation learning approach to preserve the spatio-temporal patterns of attacks and normal behaviors.
  The representation learning approach includes two modules:
  (1) a temporal embedding module, which preserves the temporal dependencies within a time segment.
  Then, we constructed the spatiotemporal graphs by mapping the temporal embedding to the WTN as node attributes.
  (2) a spatial embedding module, which learns the fused spatio-temporal embedding from the spaiotemporal graphs.
  In addition, we developed an integrated one-class detection method with an improved pairwise kernel.
  The new kernel is capable of augmenting the difference between normal and attack patterns via the pairwise similarity among deep embedding vectors of system behaviors. 
  Finally, we conducted extensive experiments to illustrate the effectiveness of our method: STOD achieves an accuracy of 91.65%, with average improvement ratios of 82.78%  and 22.96% with respect to F1 and AUC, compared with the baseline methods.
  
  
  
  
  
  
  
  
   
  
  IEEEtran    
  
  
  