# CDSTAEP: Cross-Domain Spatial-Temporal Association Learning for Abnormal Events Prediction
## 4 Methodology
### Graph Representation Learning in Mixed-Curvature Spaces
#### 4.2.1 Metric and Map Representations in Curvature Spaces
(4) Self-Supervised Learning  
The purpose of self-supervised learning is to learn rich correlations in samples by continuously optimizing the encoder function and obtain the event representation vector in the event associate graph by optimizing the objective function. The effective comparison between positive and negative samples can enable the encoder to learn a richer feature representation, which is the basis of self-supervised learning. In self-supervised learning, views are generated by standard augmentations, such as cropping, rotation, etc., and defining views in Riemannian space is challenging. Two enhancement methods are generally considered on the graph: (1) feature space enhancement of the initial node, such as masking enhancement of sampling features or adding Gaussian noise; (2) generation of congruent graphs, such as generating congruence through diffusion matrix or the shortest distance picture. Research [45] shows that masking enhancement or adding noise in both spaces degrades the overall performance. Therefore, we transform the adjacency matrix into a diffusion matrix and treat these two matrices as two congruent graphs of the same graph structure, and then conduct sub-sampling. Since the adjacency matrix and the diffusion matrix, respectively, provide a local view and a global view of the graph structure, they can maximize the consistency of representing vectors from two different spaces, so that the self-supervised learning model can learn rich local information and global information through the encoder at the same time. Contrastive learning is a particular case of self-supervised learning. The goal is to learn an encoder, the objective function \(f(\cdot)\)[46], and compare the data with positive and negative samples in the feature space to learn the characteristics of the samples. For given data x, the similarity \(score(\cdot)\) between positive and negative samples should satisfy the following:  
\[score\big{(}f(x),f\big{(}x^{+}\big{)}\big{)}\gg score\big{(}f(x),f\big{(}x^{-} \big{)}\big{)} \tag{27}\]  
where \(x\in\{\mathbb{H},\mathbb{E},\mathbb{S}\}\) is a node in the Riemann space, \(x^{+}\) is a positive sample similar to \(x\), \(x^{-}\) is a negative sample dissimilar to \(x\), and \(score(\cdot)\) is usually the Euclidean distance or cosine similarity. Comparing positive and negative samples in Riemannian space includes two methods: comparing positive and negative samples in the same curvature space and comparing positive and negative samples between different curvature spaces. We lift the samples in Riemannian space to a common tangent space and score the consistency of positive and negative samples from different curvature spaces to obtain richer feature representations [16]. The formula for calculating the similarity between positive and negative samples is as follows:  
\[\hat{S}_{ij}=\frac{exp\Big{(}s_{single-space}\big{(}x_{i},x_{j}\big{)}\Big{)}} {\sum_{k\in\mathcal{N}_{i}}exp\Big{(}s_{single-space}(x_{i},x_{k})\Big{)}} \tag{19}\]0  
where \(x\in\{\mathbb{H},\mathbb{E},\mathbb{S}\}\) is the node data, the logarithmic map \(log_{0}^{k}\) is used to construct the common tangent space, and \(k\) is the space curvature. To optimize the encoder, it is necessary to construct a softmax classifier to classify positive and negative samples, and we introduce the **Info NCELoss** function [47] to optimize the encoder \(f(\cdot)\). The loss function formula in a single curvature space is as follows:  
\[\hat{S}_{ij}=\frac{exp\Big{(}s_{single-space}\big{(}x_{i},x_{j}\big{)}\Big{)}} {\sum_{k\in\mathcal{N}_{i}}exp\Big{(}s_{single-space}(x_{i},x_{k})\Big{)}} \tag{19}\]1  
We evaluate the consistency between samples by the cosine similarity \(score(\cdot)\), where \(f(x)\) and \(f(x^{+})\) are the encoding functions of positive and negative samples, respectively, and \(N\) is the number of samples in a batch, that is, the number of all sampled nodes in the mixed-curvature space. For a given positive sample pair, the remaining \(N-1\) samples are all negative samples.