import itstgcntry
import torch
import itstgcntry.planner
Adding the RecurrentGCN models
RecurrentGCN
RecurrentGCN
Import
Try
import pandas as pd
'./simulation_results/2023-05-29_11-18-32.csv').groupby(['RecurrentGCN','method','mrate'])['mse'].mean().reset_index() pd.read_csv(
RecurrentGCN | method | mrate | mse | |
---|---|---|---|---|
0 | DCRNN | IT-STGCN | 0.8 | 1.517346 |
1 | DCRNN | STGCN | 0.8 | 1.521906 |
2 | EvolveGCNH | IT-STGCN | 0.8 | 1.338225 |
3 | EvolveGCNH | STGCN | 0.8 | 1.337022 |
4 | EvolveGCNO | IT-STGCN | 0.8 | 1.370455 |
5 | EvolveGCNO | STGCN | 0.8 | 1.326990 |
6 | GCLSTM | IT-STGCN | 0.8 | 1.529536 |
7 | GCLSTM | STGCN | 0.8 | 1.600452 |
8 | GConvGRU | IT-STGCN | 0.8 | 1.567661 |
9 | GConvGRU | STGCN | 0.8 | 1.654162 |
10 | GConvLSTM | IT-STGCN | 0.8 | 1.494284 |
11 | GConvLSTM | STGCN | 0.8 | 1.633645 |
12 | LRGCN | IT-STGCN | 0.8 | 1.512042 |
13 | LRGCN | STGCN | 0.8 | 1.604186 |
14 | MPNNLSTM | IT-STGCN | 0.8 | 1.386678 |
15 | MPNNLSTM | STGCN | 0.8 | 1.351526 |
16 | TGCN | IT-STGCN | 0.8 | 1.279269 |
17 | TGCN | STGCN | 0.8 | 1.278411 |
'./simulation_results/2023-05-29_12-31-06.csv').groupby(['RecurrentGCN','method','mrate'])['mse'].mean().reset_index() pd.read_csv(
RecurrentGCN | method | mrate | mse | |
---|---|---|---|---|
0 | DCRNN | IT-STGCN | 0.6 | 1.457874 |
1 | DCRNN | STGCN | 0.6 | 1.523312 |
2 | EvolveGCNH | IT-STGCN | 0.6 | 1.265695 |
3 | EvolveGCNH | STGCN | 0.6 | 1.290008 |
4 | EvolveGCNO | IT-STGCN | 0.6 | 1.288295 |
5 | EvolveGCNO | STGCN | 0.6 | 1.308886 |
6 | GCLSTM | IT-STGCN | 0.6 | 1.304539 |
7 | GCLSTM | STGCN | 0.6 | 1.537681 |
8 | GConvGRU | IT-STGCN | 0.6 | 1.402607 |
9 | GConvGRU | STGCN | 0.6 | 1.582745 |
10 | GConvLSTM | IT-STGCN | 0.6 | 1.299263 |
11 | GConvLSTM | STGCN | 0.6 | 1.534498 |
12 | LRGCN | IT-STGCN | 0.6 | 1.295239 |
13 | LRGCN | STGCN | 0.6 | 1.527917 |
14 | MPNNLSTM | IT-STGCN | 0.6 | 1.287649 |
15 | MPNNLSTM | STGCN | 0.6 | 1.307589 |
16 | TGCN | IT-STGCN | 0.6 | 1.276318 |
17 | TGCN | STGCN | 0.6 | 1.262256 |
GConvGRU
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
/home/csy/Dropbox/blog/posts/GCN/itstgcntry/utils.py:72: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at /opt/conda/conda-bld/pytorch_1682343998658/work/torch/csrc/utils/tensor_new.cpp:245.)
lags = torch.tensor(train_dataset.features).shape[-1]
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.GConvGRU_RecurrentGCN(train_dataset_padded,filters=1) model
=5) lrnr.learn(model,epoch
5/5
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.GConvGRU_RecurrentGCN(train_dataset_padded,filters=1) model1
=5) lrnr1.learn(model1,epoch
5/5
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
DCRNN
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.DCRNN_RecurrentGCN(train_dataset_padded,filters=1) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.DCRNN_RecurrentGCN(train_dataset_padded,filters=1) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
EvolveGCNH
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.EvolveGCNH_RecurrentGCN(train_dataset_padded) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.EvolveGCNH_RecurrentGCN(train_dataset_padded) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
EvolveGCNO
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.EvolveGCNO_RecurrentGCN(train_dataset_padded) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.EvolveGCNO_RecurrentGCN(train_dataset_padded) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
GCLSTM
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.GCLSTM_RecurrentGCN(train_dataset_padded, filters=1) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.GCLSTM_RecurrentGCN(train_dataset_padded, filters=1) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
GConvLSTM
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.GConvLSTM_RecurrentGCN(train_dataset_padded, filters=1) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.GConvLSTM_RecurrentGCN(train_dataset_padded, filters=1) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
LRGCN
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.LRGCN_RecurrentGCN(train_dataset_padded, filters=1) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.LRGCN_RecurrentGCN(train_dataset_padded, filters=1) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
MPNNLSTM
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.MPNNLSTM_RecurrentGCN(train_dataset_padded, filters=1) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.MPNNLSTM_RecurrentGCN(train_dataset_padded, filters=1) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
TGCN
= itstgcntry.load_data('./data/fivenodes.pkl')
data_dict = itstgcntry.DatasetLoader(data_dict) loader
= loader.get_dataset(lags=2)
dataset = itstgcntry.temporal_signal_split(dataset, train_ratio=0.8) train_dataset, test_dataset
= [list(range(10,100)),[],list(range(50,80)),[],[]]
mindex = itstgcntry.miss(train_dataset,mindex,mtype='block')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
= itstgcntry.rand_mindex(train_dataset,mrate=0.5)
mindex = itstgcntry.miss(train_dataset,mindex,mtype='rand')
train_dataset_miss = itstgcntry.padding(train_dataset_miss) # padding(train_dataset_miss,method='linear'와 같음) train_dataset_padded
-
학습
= itstgcntry.StgcnLearner(train_dataset_padded) lrnr
= itstgcntry.TGCN_RecurrentGCN(train_dataset_padded, filters=32) model
=50) lrnr.learn(model,epoch
50/50
= itstgcntry.ITStgcnLearner(train_dataset_padded) lrnr1
= itstgcntry.TGCN_RecurrentGCN(train_dataset_padded, filters=32) model1
=50) lrnr1.learn(model1,epoch
50/50
-
적합값
# lrnr(train_dataset_padded)
# lrnr(test_dataset)['yhat'].shape
- 실행하면 X,y,yhat 출력
-
모형 평가 및 시각화
= itstgcntry.Evaluator(lrnr,train_dataset_padded,test_dataset) evtor
= evtor.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig
= itstgcntry.Evaluator(lrnr1,train_dataset_padded,test_dataset) evtor1
= evtor1.plot('--.',h=5,max_node=3,label='complete data',alpha=0.5) # max_nodes 는 1보다 커야함
fig 12)
fig.set_figwidth(12)
fig.set_figheight(
fig.tight_layout() fig