20250722 meeting

The cover image shows the prediction result for Day 1 after training on 250 days of data. The predicted time is 11:30 AM on September 7, 2024.
Introduction
This experiment aims to predict the next data point by exploring the linear relationship between spatial basis functions and real data.
Experiment
In this experiment, the original three-dimensional spatiotemporal data (5000 locations, 250 days, 24 hours) is first standardized for each location’s time series, followed by subtracting the mean at each corresponding time point. Using MRTS, a spatial basis matrix of shape (5000, 5000) is computed for each location, and linear regression is performed. The $SSSD^{S4}$ model is then used to predict the next period’s $\mathbb{\beta}$ and $\mathbb{\varepsilon}$ in the linear regression.
The experiment focuses on the region of China, with 5000 locations selected using a fixed random seed, and training with 3,800 iterations.
A portion of the code is shown below:
- Time series standardization for each location
| |
Subtracting Spatial Mean
To simplify computation, the average across all spatial locations is subtracted in this step. In the future, we plan to implement a more refined approach, such as subtracting the previous spatial mean, and then adding it back after predicting $\mathbb{\beta}$ and $\mathbb{\varepsilon}$ for the next period.
| |
The following code should be modified.
| |
- Code for spatial basis and linear regression model
| |
The following shows the first 40 $\mathbb{\beta}$, $\mathbb{\varepsilon}$, and QQ plots.
- $\mathbb{\beta}$
- $\mathbb{\varepsilon}$
- QQ plots
This experiment only predicts the next 10 periods, using the $SSSD^{S4}$ model to forecast data for these 10 future periods. The original training set (5000, 250, 24) is extended by 10 days to form (5000, 260, 24) data points, filling in the future 10 days. The number of iterations is set to 3,800 for all runs.
Below are the parameters used in this experiment.
model.yaml
| |
training.yaml
| |
inference.yaml
| |
Imputation
During imputation, data is restored in the reverse order of previous processing steps. Specifically, linear data reconstruction is performed first, followed by adding back the spatial mean and reversing the temporal standardization.
| |
Results
The imputation results are shown below, presenting the filled data for the first 40 locations over 260 days and 24 hours.
The following shows the ground truth and imputation results for 260 days, with the last 10 days being missing values.
The following are the experimental results for all days (ALL) and the imputed days (Future).
| Method | Value |
|---|---|
| MSPE (All) | 275.036719 |
| MSPE (Future) | 73.921309 |
| MAPE (All) | 11.352546 |
| MAPE (Future) | 6.607120 |
| MSPE% (All) | 0.040497 |
| MSPE% (Future) | 0.022734 |
| MAPE% (All) | 0.040497 |
| MAPE% (Future) | 0.022734 |
The following are the experimental results for the first 10 locations.
| Metric | location 0 | location 1 | location 2 | location 3 | location 4 | location 5 | location 6 | location 7 | location 8 | location 9 |
|---|---|---|---|---|---|---|---|---|---|---|
| MSPE (All) | 5.255262 | 10.026982 | 14.820487 | 11.327233 | 21.766030 | 10.163997 | 12.028227 | 27.281164 | 15.930138 | 12.857481 |
| MSPE (Future) | 3.356809 | 6.474035 | 14.732642 | 10.664811 | 13.967894 | 8.502941 | 12.174201 | 14.512227 | 13.899978 | 8.035698 |
| MAPE (All) | 1.828430 | 2.530852 | 3.230515 | 2.770408 | 3.856013 | 2.537044 | 2.792764 | 4.207124 | 3.220459 | 2.865893 |
| MAPE (Future) | 1.385229 | 2.076008 | 3.560789 | 3.016031 | 3.385609 | 2.551944 | 3.087012 | 3.242486 | 3.098211 | 2.263944 |
| MSPE% (All) | 0.006074 | 0.008465 | 0.010717 | 0.009204 | 0.012819 | 0.008425 | 0.009239 | 0.013915 | 0.010648 | 0.009491 |
| MSPE% (Future) | 0.004619 | 0.006998 | 0.011953 | 0.010142 | 0.011376 | 0.008567 | 0.010323 | 0.010823 | 0.010338 | 0.007556 |
| MAPE% (All) | 0.006074 | 0.008465 | 0.010717 | 0.009204 | 0.012819 | 0.008425 | 0.009239 | 0.013915 | 0.010648 | 0.009491 |
| MAPE% (Future) | 0.004619 | 0.006998 | 0.011953 | 0.010142 | 0.011376 | 0.008567 | 0.010323 | 0.010823 | 0.010338 | 0.007556 |
Control Group
To verify the effectiveness of the above modifications, the following control group experiment was conducted. For fairness, the number of iterations was also set to 3,800, and the data, after temporal standardization, was input into the $SSSD^{S4}$ model to predict the next 10 days. The experimental results are shown below.
Here are the control group experiment results, focusing on all days (ALL) and the imputed days (Future).
| Method (Control) | Value |
|---|---|
| MSPE (All) | 33.366627 |
| MSPE (Future) | 21.066000 |
| MAPE (All) | 4.087378 |
| MAPE (Future) | 3.584273 |
| MSPE% (All) | 0.014458 |
| MSPE% (Future) | 0.012363 |
| MAPE% (All) | 0.014458 |
| MAPE% (Future) | 0.012363 |
Below are the experimental results for the top 10 locations in the control group.
| Metric | location 0 | location 1 | location 2 | location 3 | location 4 | location 5 | location 6 | location 7 | location 8 | location 9 |
|---|---|---|---|---|---|---|---|---|---|---|
| MSPE (All) | 10.087422 | 20.628242 | 32.429203 | 25.994247 | 26.916309 | 24.316294 | 23.361771 | 22.525789 | 26.675638 | 9.733860 |
| MSPE (Future) | 9.859146 | 22.754442 | 42.287827 | 29.440161 | 30.574316 | 36.257183 | 31.123371 | 25.592594 | 33.918751 | 18.377745 |
| MAPE (All) | 2.443704 | 3.676670 | 5.009152 | 4.464825 | 4.596467 | 4.187994 | 4.139386 | 4.070803 | 4.407689 | 2.394271 |
| MAPE (Future) | 2.536753 | 4.275434 | 6.336579 | 5.214918 | 5.353099 | 5.744732 | 5.237920 | 4.642370 | 5.360564 | 3.896869 |
| MSPE% (All) | 0.008098 | 0.012278 | 0.016622 | 0.014840 | 0.015277 | 0.013898 | 0.013675 | 0.013449 | 0.014565 | 0.007949 |
| MSPE% (Future) | 0.008460 | 0.014416 | 0.021272 | 0.017527 | 0.018002 | 0.019290 | 0.017522 | 0.015505 | 0.017897 | 0.013019 |
| MAPE% (All) | 0.008098 | 0.012278 | 0.016622 | 0.014840 | 0.015277 | 0.013898 | 0.013675 | 0.013449 | 0.014565 | 0.007949 |
| MAPE% (Future) | 0.008460 | 0.014416 | 0.021272 | 0.017527 | 0.018002 | 0.019290 | 0.017522 | 0.015505 | 0.017897 | 0.013019 |
Conclusion
Even after embedding into the spatial domain, the prediction error remains higher than that of pure time series forecasting. However, this might be due to the smaller prediction region, which results in higher overall accuracy compared to the previous setup that randomly sampled 5,000 locations from one-fourth of the globe. It may be worthwhile to re-examine the linear regression process and reconsider how to handle the spatial average per unit time so that the results retain temporal characteristics.
Epilogue
Environment
- Local Operating System: Windows 11 24H2
- Programming Language: Python 3.12.9
- Computing Platform: National Center for High-Performance Computing (NCHC) – Taiwan AI Cloud
- Operating System: Ubuntu
- Miniconda
- GPU: NVIDIA Tesla V100 32GB GPU
- CUDA 12.8 driver
- Programming Language: Python 3.10.16 for Linux
Further Learning
- I tested this project on the GitHub repository.
References
Juan Lopez Alcaraz, Nils Strodthoff. (2022). Diffusion-based time series imputation and forecasting with structured state space models. Transactions on Machine Learning Research. Retrieved from https://openreview.net/forum?id=hHiIbk7ApW
SSSD. (2022). GitHub. Retrieved from https://github.com/AI4HealthUOL/SSSD
SSSD_CP. (2024). GitHub. Retrieved from https://github.com/egpivo/SSSD_CP
近兩年小時值查詢. (n.d.). 環境部 - 空氣品質監測網. Retrieved from https://airtw.moenv.gov.tw/CHT/Query/InsValue.aspx



![[Thought] Historical Earthquake Locations Around Taiwan](https://Josh-test-lab.github.io/posts/Historical%20Earthquake%20Locations%20Around%20Taiwan/cover%20image.webp)




