import rpy2
import rpy2.robjects as ro
from rpy2.robjects.vectors import FloatVector
from rpy2.robjects.packages import importr
import torch
import numpy as np
from tqdm import tqdm
import torch.nn.functional as F
from torch_geometric_temporal.nn.recurrent import GConvGRU
import matplotlib.pyplot as plt
import pandas as pd
import time
from scipy.interpolate import interp1d
from matplotlib import animation
Class of Method
ST-GCN
Class
import
class RecurrentGCN(torch.nn.Module):
def __init__(self, node_features, filters):
super(RecurrentGCN, self).__init__()
self.recurrent = GConvGRU(node_features, filters, 2)
self.linear = torch.nn.Linear(filters, 1)
def forward(self, x, edge_index, edge_weight):
= self.recurrent(x, edge_index, edge_weight)
h = F.relu(h)
h = self.linear(h)
h return h
시간 측정 방법
= time.time()
t1for epoc in range(1000):
## 1
= net(x)
yhat ## 2
= loss_fn(yhat,y)
loss ## 3
loss.backward()## 4
optimizr.step()
optimizr.zero_grad()= time.time()
t2 -t1 t2
R
%load_ext rpy2.ipython
%%R
library(GNAR) library(igraph)
R[write to console]: Loading required package: igraph
R[write to console]:
Attaching package: ‘igraph’
R[write to console]: The following objects are masked from ‘package:stats’:
decompose, spectrum
R[write to console]: The following object is masked from ‘package:base’:
union
R[write to console]: Loading required package: wordcloud
R[write to console]: Loading required package: RColorBrewer
Data
%%R
<- as.matrix(fiveNet)
edges "fiveNode") data(
%R -o fiveVTS
%R -o edges
- node: 5
- time 200
functions
def vis(spatiotemporaldata):
= spatiotemporaldata.shape[1]
N = plt.subplots(N,1)
fig, ax for n in range(N):
ax[n].plot(spatiotemporaldata[:,n])'node='+str(n))
ax[n].set_title(#fig.set_width()
*2)
fig.set_figheight(N
fig.tight_layout()return fig
def vis2(spatiotemporaldata1,spatiotemporaldata2):
= spatiotemporaldata1.shape[1]
N = plt.subplots(N,1)
fig, ax for n in range(N):
='data1')
ax[n].plot(spatiotemporaldata1[:,n],label='data2')
ax[n].plot(spatiotemporaldata2[:,n],label'node='+str(n))
ax[n].set_title(
ax[n].legend()#fig.set_width()
*2)
fig.set_figheight(N
fig.tight_layout()return fig
= torch.tensor(edges) edges_tensor
= edges_tensor.nonzero() nonzero_indices
= np.array(nonzero_indices).T fiveNet_edge
= 200
T = 5 # number of Nodes
N = fiveNet_edge
E = np.array([1,2,3,4,5])
V = np.arange(0,T)
t = 1 node_features
= torch.tensor(E)
edge_index = torch.tensor(np.array([1,1,1,1,1,1,1,1,1,1]),dtype=torch.float32) edge_attr
= fiveVTS[:int(len(fiveVTS)*0.8)]
fiveVTS_train = fiveVTS[int(len(fiveVTS)*0.8):] fiveVTS_test
; vis(fiveVTS_train)
; vis(fiveVTS_test)
Random Missing Values
class Missing:
def __init__(self,df):
self.df = df
self.N = N
self.number = []
def miss(self,percent=0.5):
self.missing = self.df.copy()
self.percent = percent
for i in range(self.N):
self.seed = np.random.choice(1000,1,replace=False)
self.seed)
np.random.seed(self.number.append(np.random.choice(int(len(self.df))-1,int(len(self.df)*self.percent),replace=False))
self.missing[self.number[i],i] = float('nan')
def first_mean(self):
self.train_mean = self.missing.copy()
for i in range(self.N):
self.train_mean[self.number[i],i] = np.nanmean(self.missing[:,i])
def second_linear(self):
self.train_linear = pd.DataFrame(self.missing)
self.train_linear.interpolate(method='linear', inplace=True)
self.train_linear = self.train_linear.fillna(0)
self.train_linear = np.array(self.train_linear).reshape(int(len(self.df)),N)
type(fiveVTS_train)
numpy.ndarray
fiveVTS_train.shape
(160, 5)
= Missing(fiveVTS_train) _zero
= 0.1) _zero.miss(percent
; vis(_zero.missing)
_zero.first_mean()
; vis(_zero.train_mean)
_zero.second_linear()
160,5)); vis(np.array(_zero.train_linear).reshape(
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= torch.tensor(fiveVTS_test.reshape(int(T*0.2),N,1)[:-1,:,:]).float() xt_test
class Method:
def __init__(self,df,time,seednumber,trainx,trainy):
self.test_data = fiveVTS_test
self.seednumber = seednumber
self.N = N
self.timepoint = time -1
self.edge_index = edge_index
self.edge_attr = edge_attr
self.node_features = node_features
self.X = trainx
self.df = _zero.train_mean
self.y = trainy
self.xt_test = xt_test
self.w = np.zeros(((self.timepoint)*self.N,(self.timepoint)*self.N))
self.mse = []
self.mae = []
self.train_result_list = []
self.test_result_list = []
def _weight(self):
for i in range((self.timepoint)*self.N):
for j in range((self.timepoint)*self.N):
if i==j :
self.w[i,j] = 0
elif np.abs(i-j) <= 1 :
self.w[i,j] = 1
def _STGCN(self):
= RecurrentGCN(node_features=1, filters=4)
model = torch.optim.Adam(model.parameters(), lr=0.01)
optimizer
model.train()for epoch in tqdm(range(100)):
for time, (xt,yt) in enumerate(zip(self.X,self.y)):
= model(xt, edge_index, edge_attr)
y_hat = torch.mean((y_hat-yt)**2)
cost
cost.backward()
optimizer.step()
optimizer.zero_grad()self.train_result = torch.stack([model(xt, edge_index, edge_attr) for xt in self.X]).detach().numpy()
self.test_result = torch.stack([model(xt, edge_index, edge_attr) for xt in self.xt_test]).detach().numpy()
self.train_result_list.append(self.train_result)
self.test_result_list.append(self.test_result)
for i in range(self.N):
self.mse.append(np.mean((self.test_data[1:,i] - self.test_result.reshape(int(len(self.xt_test)),self.N)[:,i])**2))
for i in range(self.N):
self.mae.append(np.mean(np.abs(self.test_data[1:,i] - self.test_result.reshape(int(len(self.xt_test)),self.N)[:,i])))
def FT(self):
self._weight()
self._STGCN()
self.d = np.array(self.w.sum(axis=1))
self.D = np.diag(self.d)
self.L = np.array(np.diag(1/np.sqrt(self.d)) @ (self.D-self.w) @ np.diag(1/np.sqrt(self.d)))
self.lamb, self.Psi = np.linalg.eigh(self.L)
self.Lamb = np.diag(self.lamb)
self.fhatbar = self.Psi.T @ self.train_result.reshape((self.timepoint)*self.N,1)
= importr('EbayesThresh').ebayesthresh
ebayesthresh self.fhatbar_threshed = ebayesthresh(FloatVector(self.fhatbar))
self.fhatbarhat = self.Psi @ self.fhatbar_threshed
self.FT_result = self.fhatbarhat.reshape(self.timepoint,self.N,1)
for i in range(N):
self.df[self.seednumber[i],i] = torch.tensor(self.FT_result)[self.seednumber[i],i,0]
def show_lrpr(data1,data2,data3,data4,data5,history):
= data1,data2,data3,data4,data5
y1,y2,y3,y4,y5
= plt.figure(figsize=(10, 8))
fig = fig.add_subplot(5, 1, 1)
ax1 = fig.add_subplot(5, 1, 2)
ax2 = fig.add_subplot(5, 1, 3)
ax3 = fig.add_subplot(5, 1, 4)
ax4 = fig.add_subplot(5, 1, 5)
ax5
ax1.plot(y1)
ax2.plot(y2)
ax3.plot(y3)
ax4.plot(y4)
ax5.plot(y5)= ax1.plot(history[0][:,0,0])
line1, = ax2.plot(history[0][:,1,0])
line2, = ax3.plot(history[0][:,2,0])
line3, = ax4.plot(history[0][:,3,0])
line4, = ax5.plot(history[0][:,4,0])
line5,
def animate(epoc):
0,0])
line1.set_ydata(history[epoc][:,1,0])
line2.set_ydata(history[epoc][:,2,0])
line3.set_ydata(history[epoc][:,3,0])
line4.set_ydata(history[epoc][:,4,0])
line5.set_ydata(history[epoc][:,return line1,line2,line3,line4,line5
= animation.FuncAnimation(fig, animate, frames=30)
ani
plt.close()return ani
missing : 10%
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= Missing(fiveVTS_train) ___zero
= 0.1) ___zero.miss(percent
___zero.first_mean()
___zero.second_linear()
Mean
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero.train_mean
b = ___zero.number
c = train_X_mean
d = train_y_mean
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
3282.4832243919373
= pd.DataFrame(_mse) mean_mse100_10
= pd.DataFrame(_mae) mean_mae100_10
= _train_result.copy() _train_result_mean10
= _test_result.copy() _test_result_mean10
; plt.plot(mean_mse100_10.T)
; plt.plot(mean_mae100_10.T)
59]); vis2(_zero.train_mean,_train_result[
1:],_test_result[0]); vis2(fiveVTS_test[
Linear
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero.second_linear
b = ___zero.number
c = train_X_linear
d = train_y_linear
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
3295.478456020355
= pd.DataFrame(_mse) linear_mse100_10
= pd.DataFrame(_mae) linear_mae100_10
= _train_result.copy() _train_result_linear10
= _test_result.copy() _test_result_linear10
; plt.plot(linear_mse100_10.T)
; plt.plot(linear_mae100_10.T)
59]); vis2(_zero.train_mean,_train_result_linear10[
1:],_test_result_linear10[0]); vis2(fiveVTS_test[
missing : 20%
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= Missing(fiveVTS_train) ___zero20
= 0.2) ___zero20.miss(percent
___zero20.first_mean()
___zero20.second_linear()
Mean
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero20.train_mean
b = ___zero20.number
c = train_X_mean
d = train_y_mean
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:52<00:00, 1.89it/s]
100%|██████████| 100/100 [00:52<00:00, 1.89it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
3277.0478909015656
= pd.DataFrame(_mse) mean_mse100_20
= pd.DataFrame(_mae) mean_mae100_20
= _train_result.copy() _train_result_mean20
= _test_result.copy() _test_result_mean20
; plt.plot(mean_mse100_20.T)
; plt.plot(mean_mae100_20.T)
59]); vis2(___zero20.train_mean,_train_result_mean20[
1:],_test_result_mean20[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_mean20) show_lrpr(fiveVTS_test[
Linear
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero20.second_linear
b = ___zero20.number
c = train_X_linear
d = train_y_linear
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
3298.6988050937653
= pd.DataFrame(_mse) linear_mse100_20
= pd.DataFrame(_mae) linear_mae100_20
= _train_result.copy() _train_result_linear20
= _test_result.copy() _test_result_linear20
; plt.plot(linear_mse100_20.T)
; plt.plot(linear_mae100_20.T)
59]); vis2(___zero20.train_mean,_train_result_linear20[
1:],_test_result_linear20[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_linear20) show_lrpr(fiveVTS_test[
missing : 30%
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= Missing(fiveVTS_train) ___zero30
= 0.3) ___zero30.miss(percent
___zero30.first_mean()
___zero30.second_linear()
Mean
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero30.train_mean
b = ___zero30.number
c = train_X_mean
d = train_y_mean
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
3280.9767186641693
= pd.DataFrame(_mse) mean_mse_30
= pd.DataFrame(_mae) mean_mae_30
= _train_result.copy() _train_result_mean30
= _test_result.copy() _test_result_mean30
; plt.plot(mean_mse_30.T)
; plt.plot(mean_mae_30.T)
59]); vis2(___zero30.train_mean,_train_result_mean30[
1:],_test_result_mean30[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_mean30) show_lrpr(fiveVTS_test[
Linear
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero30.second_linear
b = ___zero30.number
c = train_X_linear
d = train_y_linear
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
3305.375289440155
= pd.DataFrame(_mse) linear_mse_30
= pd.DataFrame(_mae) linear_mae_30
= _train_result.copy() _train_result_linear30
= _test_result.copy() _test_result_linear30
; plt.plot(linear_mse_30.T)
; plt.plot(linear_mae_30.T)
59]); vis2(___zero30.train_mean,_train_result_linear30[
1:],_test_result_linear30[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_linear30) show_lrpr(fiveVTS_test[
missing : 40%
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= Missing(fiveVTS_train) ___zero40
= 0.4) ___zero40.miss(percent
___zero40.first_mean()
___zero40.second_linear()
Mean
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero40.train_mean
b = ___zero40.number
c = train_X_mean
d = train_y_mean
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.88it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
3287.529237985611
= pd.DataFrame(_mse) mean_mse_40
= pd.DataFrame(_mae) mean_mae_40
= _train_result.copy() _train_result_mean40
= _test_result.copy() _test_result_mean40
; plt.plot(mean_mse_40.T)
; plt.plot(mean_mae_40.T)
59]); vis2(___zero40.train_mean,_train_result_mean40[
1:],_test_result_mean40[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_mean40) show_lrpr(fiveVTS_test[
Linear
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero40.second_linear
b = ___zero40.number
c = train_X_linear
d = train_y_linear
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.82it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.85it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.87it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:53<00:00, 1.86it/s]
100%|██████████| 100/100 [00:54<00:00, 1.83it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
100%|██████████| 100/100 [00:54<00:00, 1.84it/s]
3303.96302652359
= pd.DataFrame(_mse) linear_mse_40
= pd.DataFrame(_mae) linear_mae_40
= _train_result.copy() _train_result_linear40
= _test_result.copy() _test_result_linear40
; plt.plot(linear_mse_40.T)
; plt.plot(linear_mae_40.T)
59]); vis2(___zero40.train_mean,_train_result_linear40[
1:],_test_result_linear40[0]); vis2(fiveVTS_test[
1:,0],fiveVTS_test[1:,1],fiveVTS_test[1:,2],fiveVTS_test[1:,3],fiveVTS_test[1:,4],_test_result_linear40) show_lrpr(fiveVTS_test[
missing : 50%
= torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_mean = torch.tensor(_zero.train_mean).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_mean
= torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[:int(T*0.8-1),:,:]
train_X_linear = torch.tensor(_zero.train_linear).reshape(int(T*0.8),N,1).float()[1:,:,:] train_y_linear
= Missing(fiveVTS_train) ___zero50
= 0.5) ___zero50.miss(percent
___zero50.first_mean()
___zero50.second_linear()
Mean
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero50.train_mean
b = ___zero50.number
c = train_X_mean
d = train_y_mean
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
= pd.DataFrame(_mse) mean_mse_50
= pd.DataFrame(_mae) mean_mae_50
= _train_result.copy() _train_result_mean50
= _test_result.copy() _test_result_mean50
; plt.plot(mean_mse_50.T)
; plt.plot(mean_mae_50.T)
59]); vis2(_zero.train_mean,_train_result_mean50[
1:],_test_result_mean50[0]); vis2(fiveVTS_test[
Linear
= time.time()
t1= 160
ttt = []
_mse = []
_mae = []
_train_result = []
_test_result = ___zero50.second_linear
b = ___zero50.number
c = train_X_linear
d = train_y_linear
f for i in range(60):
= Method(b,ttt,c,d,f)
a
a.FT()
_mse.append(a.mse)
_mae.append(a.mae)
_train_result.append(a.train_result)
_test_result.append(a.test_result)= a.FT_result
b = time.time()
t2 -t1 t2
= pd.DataFrame(_mse) linear_mse_50
= pd.DataFrame(_mae) linear_mae_50
= _train_result.copy() _train_result_linear50
= _test_result.copy() _test_result_linear50
; plt.plot(linear_mse_50.T)
; plt.plot(linear_mae_50.T)
59]); vis2(_zero.train_mean,_train_result_linear50[
1:],_test_result_linear50[0]); vis2(fiveVTS_test[