# Self-Supervised Spatio-Temporal Graph Learning for Point-of-Interest Recommendation
## 3 Methodology
### Spatio-Temporal-Aware Pre-Text Task  
For contrastive self-supervised learning, the pre-text tasks \(\mathcal{L}_{ssl}\) are defined based on positive and negative pairs. Existing methods usually treat representations of the same node with different augmentation methods [12] or with different GNN layers [13] as positive pairs, as well as different nodes using different augmentation methods [12] or different GNN layers [13] as negative pairs; neither of these approaches takes into account the spatio-temporal information. In this section, we propose spatial-aware and temporal-aware pre-text tasks, which are further used to define spatial-aware and temporal-aware contrastive learning objectives.  
In detail, we believe the spatio-temporal prior knowledge gives some clues to selecting positive and negative samples. For example, POIs with similar spatio-temporal properties are more suitable for positive samples than negative samples. Due to data sparsity, these similar POIs may not have interacted with the same user and could easily be mistaken as negative pairs, thus reducing the recommendation performance. Therefore, we designed spatial-aware and temporal-aware pre-text tasks, which are defined as follows:  
* Spatial-aware pre-text task (SPT): We took \(Q_{S}\) nodes with the highest spatial similarity in \(\mathcal{M}_{S}\) to the target node as positive examples and \(\rho(\%)\) nodes with the lowest spatial similarity as negative examples.
* Temporal-aware pre-text task (TPT): We took \(Q_{T}\) nodes with the highest temporal similarity in \(\mathcal{M}_{T}\) to the target node as positive examples and \(\rho(\%)\) nodes with the lowest temporal similarity as negative examples.  
Based on the above definitions, we proposed the spatial-aware and temporal-aware contrastive learning objectives:  
* Spatial-aware contrastive learning (SCL): Maximizes the MI between spatial-aware positive POI pairs and minimizes the MI between spatial-aware negative POI pairs: \[\mathcal{L}_{S}^{P}=\sum_{i\in\mathcal{P}}-\text{log}\frac{\sum_{j\in Q_{S}} \text{exp}\Big{(}s\Big{(}\mathbf{z}_{i}^{1},\mathbf{z}_{j}^{2}\Big{)}/\tau \Big{)}}{\sum_{k\in(|\mathcal{P}|\cdot p_{S})}\text{exp}\big{(}s\big{(}\mathbf{ z}_{i}^{1},\mathbf{z}_{k}^{2}\big{)}/\tau\big{)}},\] (12) where \(s(\cdot)\) is a similarity measure function, which is set as a dot product; \(\tau\) is the temperature in softmax; and \((\cdot)^{1}\) and \((\cdot)^{2}\) represent different embeddings obtained from data augmentation.  
* Temporal-aware contrastive learning (TCL): Maximizes the MI between temporal-aware positive POI pairs and minimizes the MI between temporal-aware negative POI pairs. \[\mathcal{L}_{T}^{P}=\sum_{i\in\mathcal{P}}-\text{log}\frac{\sum_{j\in Q_{T}} \text{exp}\big{(}s\big{(}\mathbf{z}_{i}^{1},\mathbf{z}_{j}^{2}\big{)}/\tau\big{)} }{\sum_{k\in(|\mathcal{P}|_{T})}\text{exp}\big{(}s\big{(}\mathbf{z}_{i}^{1}, \mathbf{z}_{k}^{2}\big{)}/\tau\big{)}}.\] (13)  
In practice, we set \(Q_{S}\) and \(Q_{T}\) to 1; that is, SSTGL only used the target node as a positive example. We leave larger scales or different \(Q_{S}\) and \(Q_{T}\) values to future work. In addition, since SSTGL did not define a user-based spatio-temporal similarity matrix, it used a spatio-temporal independent contrastive learning objective for users as in [12]:  
\[\mathcal{L}^{U}=\sum_{u\in\mathcal{U}}-\text{log}\frac{\text{exp}\big{(}s \big{(}\mathbf{z}_{u}^{1},\mathbf{z}_{u}^{2}\big{)}/\tau\big{)}}{\sum_{v\in \mathcal{U}}\text{exp}\big{(}s\big{(}\mathbf{z}_{u}^{1},\mathbf{z}_{v}^{2} \big{)}/\tau\big{)}}. \tag{14}\]  
Using POI-based and user-based self-supervised objective functions, we defined the final self-supervised optimization objective as follows:  
\[\mathcal{L}_{ssl}=\mathcal{L}^{U}+\alpha\mathcal{L}^{P}, \tag{15}\]  
where \(\alpha\) is a hyper-parameter used to balance two losses, and \(\mathcal{L}^{P}\in\{\mathcal{L}_{S}^{P},\mathcal{L}_{T}^{P}\}\).