目錄

1140820 meeting

前言

本次實驗同 1140819 meeting #2 ,僅將訓練的資料集進行修改,嘗試建立不平穩的時空資料(#simulation02)。

生成程式碼

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# libraries
library(fields)
library(SpatialTools)

# necessary functions
source("mcmc.R")
source("auxfunctions.R")

# Set up the grid
set.seed(100)
ns <- 2331
nt <- 260
s <- cbind(runif(n = ns, min = 0, max = 10), runif(n = ns, min = 0, max = 10))
x <- array(1, c(ns, nt, 3))
for (t in 1:nt) {
  x[, t, 2] <- sin(s[, 1]^(1/2))
  x[, t, 3] <- ifelse(s[, 2] > 5, cos(2 * s[, 2]^(1/2)), 1/3 * sin(s[, 2]^3))
}
plot(s)
plot(x[, 1, 2:3])

# generated data
set.seed(123)

lambda    <- c(0, 0,  0,  0,  3,  3,  3,  3,   0,   0,   0,   0,   3,   3,   3,   3,   0,   0,   0,   0,   3,   3,   3,   3)
tau.alpha <- c(0, 0,  0,  0,  6,  6,  6,  6,   0,   0,   0,   0,   6,   6,   6,   6,   0,   0,   0,   0,   6,   6,   6,   6)
tau.beta  <- c(0, 0,  0,  0, 16, 16, 16, 16,   0,   0,   0,   0,  16,  16,  16,  16,   0,   0,   0,   0,  16,  16,  16,  16)
nknots    <- c(1, 5, 10, 20,  1,  5, 10, 20,   1,   5,  10,  20,   1,   5,  10,  20,   1,   5,  10,  20,   1,   5,  10,  20)
phi.z     <- c(0, 0,  0,  0,  0,  0,  0,  0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9)
phi.w     <- c(0, 0,  0,  0,  0,  0,  0,  0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9)
phi.tau   <- c(0, 0,  0,  0,  0,  0,  0,  0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5)

combined = array(NA, c(ns, nt, 24))

for (i in 1:24) {
  # --- 左右半邊不同 correlation range ---
  phi.z.local   <- ifelse(s[,1] < 5, phi.z[i],   phi.z[i] * 1.5)   # 右半邊 range 拉長
  phi.w.local   <- ifelse(s[,1] < 5, phi.w[i],   phi.w[i] * 1.5)
  phi.tau.local <- ifelse(s[,1] < 5, phi.tau[i], phi.tau[i] * 1.5)
  
  data_ <- rpotspatTS(nt = nt,
                      x = x, 
                      s = s, 
                      beta = c(10, 0, 0), 
                      gamma = 0.9, 
                      nu = 0.5, 
                      rho = 1, 
                      phi.z = phi.z[i],      # time series parameters
                      phi.w = phi.w[i],      # time series parameters
                      phi.tau = phi.tau[i],  # time series parameters
                      lambda = lambda[i], 
                      tau.alpha = tau.alpha[i], 
                      tau.beta = tau.beta[i], 
                      nknots = nknots[i], 
                      dist = "gaussian"
                      )$y
  
  # combined
  combined[, , i] = data_
  
  # hist
  hist(data_, main = paste0('hist. of ', i))
  
  # remove
  rm(data_)
}

# combine
#library(abind)
#combined <- abind(data_1, data_2, data_3, along = 3)

# save
library(dplyr)
library(reticulate)
np = import("numpy")
combined = combined %>% r_to_py()
combined = combined$transpose(2L, 1L, 0L)
save_dir = 'datasets'
if (!dir.exists(save_dir)) {
  dir.create(save_dir, recursive = TRUE)
}
np$save(paste0(save_dir, '/real.npy'), combined)
np$save(paste0(save_dir, '/all_locations.npy'), s)

SSSD + autoFRK

autoFRK 推論耗時 2.308502 分鐘(CPU 平行運算,核心數:23)。

MethodALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE8.09838718.09747428.103903010.461637610.455781910.49701988.00385708.00314198.0081784
RMSPE2.84576652.84560612.84673553.23444553.23354023.23991052.82910892.82898252.8298725
MSPE%0.66947590.66967410.66827840.94887260.94863650.95029940.65830000.65851560.6569976
RMSPE%0.81821510.81833620.81748300.97410090.97397970.97483300.81135690.81148970.8105539
MAPE2.13458192.13448422.13517182.45504242.45449722.45833652.12176342.12168372.1222452
MAPE%0.18617860.18620360.18602740.22458530.22458470.22458890.18464230.18466840.1844849

TSMixer + autoFRK

TSMixer 推論耗時 3:02:20.712516 (CPU 平行運算,核心數:24)。

autoFRK 推論耗時 2.16183 小時(CPU 平行運算,核心數:23)。

MethodALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE1.455784591.455416791.4580068916.945377516.939456316.98115550.836200870.836055210.83708095
RMSPE1.206558991.206406561.207479564.11647644.11575714.12081980.914440190.914360550.91492128
MSPE%0.123756770.123781360.123608161.41562671.41612171.41263590.072081970.072087750.07204705
RMSPE%0.351790800.351825750.351579521.18980111.19000911.18854360.268480860.268491620.26841582
MAPE0.795141390.795033580.795792763.09235473.09177743.09584300.703252850.703163830.70379076
MAPE%0.070084190.070085090.070078780.27254440.27258210.27231640.061985790.061985210.06198928

RegressionEnsemble + autoFRK

RegressionEnsemble 推論耗時 0:02:39.071316 (CPU 平行運算,核心數:12)。

autoFRK 推論耗時 2.917213 小時(CPU 平行運算,核心數:23)。

MethodALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE2.966088472.967085732.9600627256.213278556.242848656.0346070.836200870.836055210.83708095
RMSPE1.722233571.722523071.720483287.49755157.49952327.4856270.914440190.914360550.91492128
MSPE%0.244207150.244411500.242972434.54733664.55250524.5161070.072081970.072087750.07204705
RMSPE%0.494173200.494379910.492922332.13244852.13366002.1251130.268480860.268491620.26841582
MAPE0.878888120.878800520.879417445.26976995.26971785.2700850.703252850.703163830.70379076
MAPE%0.076901990.076906130.076876920.44980690.44992920.4490680.061985790.061985210.06198928

RegressionEnsemble (LSTM) + autoFRK

RegressionEnsemble 推論耗時 0:44:41.278393 (CPU 平行運算,核心數:12)。

autoFRK 推論耗時 2.235521 小時(CPU 平行運算,核心數:23)。

MethodALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.21805543.221014563.2001755962.764419962.844998362.27754170.836200870.836055210.83708095
RMSPE1.79389391.794718521.788903467.92239997.92748377.89161210.914440190.914360550.91492128
MSPE%0.27154420.271971080.268964665.25809925.26905435.19190500.072081970.072087750.07204705
RMSPE%0.52109900.521508470.518618032.29305462.29544212.27857520.268480860.268491620.26841582
MAPE0.89265350.892641420.892726645.62767025.62958115.61612370.703252850.703163830.70379076
MAPE%0.07833230.078345310.078253690.48699510.48734780.48486420.061985790.061985210.06198928

結論

Method / ModelSSSD + autoFRKTSMixer + autoFRKRegressionEnsemble + autoFRKRegressionEnsemble (LSTM) + autoFRK
MSPE
ALL Locs (Future)
10.461637616.945377556.213278562.7644199
MSPE
Known Locs (Future)
10.455781916.939456356.242848662.8449983
MSPE
Unknown Locs (Future)
10.497019816.981155556.03460762.2775417





RMSPE
ALL Locs (Future)
3.23444554.11647647.49755157.9223999
RMSPE
Known Locs (Future)
3.23354024.11575717.49952327.9274837
RMSPE
Unknown Locs (Future)
3.23991054.12081987.4856277.8916121





MSPE%
ALL Locs (Future)
0.94887261.41562674.54733665.2580992
MSPE%
Known Locs (Future)
0.94863651.41612174.55250525.2690543
MSPE%
Unknown Locs (Future)
0.95029941.41263594.5161075.1919050





RMSPE%
ALL Locs (Future)
0.97410091.18980112.13244852.2930546
RMSPE%
Known Locs (Future)
0.97397971.19000912.13366002.2954421
RMSPE%
Unknown Locs (Future)
0.97483301.18854362.1251132.2785752





MAPE
ALL Locs (Future)
2.45504243.09235475.26976995.6276702
MAPE
Known Locs (Future)
2.45449723.09177745.26971785.6295811
MAPE
Unknown Locs (Future)
2.45833653.09584305.2700855.6161237





MAPE%
ALL Locs (Future)
0.22458530.27254440.44980690.4869951
MAPE%
Known Locs (Future)
0.22458470.27258210.44992920.4873478
MAPE%
Unknown Locs (Future)
0.22458890.27231640.4490680.4848642

結語

https://raw.githubusercontent.com/Josh-test-lab/website-assets-repository/refs/heads/main/posts/1140819%20meeting/To%20be%20continued.jpg
To be continued!

運行環境

  • 本機作業系統:Windows 11 24H2
    • 程式語言:Python 3.12.9
  • 計算平臺:財團法人國家實驗研究院國家高速網路與計算中心臺灣 AI 雲
    • 作業系統:Ubuntu
    • Miniconda
    • GPU:NVIDIA Tesla V100 32GB GPU
    • CUDA 12.8 driver
    • 程式語言:Python 3.10.16 for Linux

延伸學習

參考資料