Using the fastai2 `Datasets` to make an time series dataset.
norm = NormalizeTS()
o = (TSTensorSeq(torch.arange(10.)),TSTensorSeqy( torch.arange(10,15),x_len=10))
o_en = norm(o)
test_eq(o_en[0].mean(), 0)
test_eq(o_en[1].mean()==0, False)
dec_o = norm.decode(o_en)
test_eq(dec_o[0],o[0])
f,axs = plt.subplots(1,3, sharey=True)
ax = o[0].show(axs[0])
o[1].show(ax)
ax.plot([0,15],[0,0],'--')
ax = o_en[0].show(axs[1])
o_en[1].show(ax)
ax.plot([0,15],[0,0],'--')
ax = dec_o[0].show(axs[2])
dec_o[1].show(ax)
ax.plot([0,15],[0,0],'--')
norm = NormalizeTS(mean=9)
o = (TSTensorSeq(torch.arange(10.)),TSTensorSeqy( torch.arange(10,15),x_len=10))
o_en = norm(o)
test_eq(o_en[0][-1], 0)
test_eq(o_en[1][-1]==0, False)
dec_o = norm.decode(o_en)
test_eq(dec_o[0],o[0])
f,axs = plt.subplots(1,3, sharey=True)
ax = o[0].show(axs[0])
o[1].show(ax)
ax.plot([0,15],[0,0],'--')
ax = o_en[0].show(axs[1])
o_en[1].show(ax)
ax.plot([0,15],[0,0],'--')
ax = dec_o[0].show(axs[2])
dec_o[1].show(ax)
ax.plot([0,15],[0,0],'--')
a = [np.random.randn(3,10)]*50
b = [np.random.randn(3,5)]*50
r = concat_ts_list(a,b)
test_eq(r[0].shape,(3,15))
test_eq(r[0], np.concatenate([a[0],b[0]],1))
a = [np.random.randn(3,15)]*50
train, val = make_test(a,5,5)
test_eq(train[0],a[0][:,:-10])
test_eq(val[0],a[0][:,-10:])
train, val = make_test(a,5,5,True)
test_eq(train[0],a[0][:,:-5])
test_eq(val[0],a[0][:,-10:])
d = {}
d.pop('k',1)
dbunch = TSDataLoaders.from_folder(path, horizon = 14, step=5, bs=64, nrows=10, device = 'cpu', after_batch=noop)
for o in dbunch[0]:
test_close(o[0].mean(),0)
test_close(o[0].std(),1,eps=.1)
dbunch = TSDataLoaders.from_folder(path, horizon = 14, step=5, bs=64, nrows=100)
dbunch.train.show_batch(max_n=4)
dbunch.test.show_batch(max_n=4)