我正在运行此仓库中“使用”部分中定义的代码: https://github.com/achillesrasquinha/bulbea/
在训练和测试之前,数据将通过以下代码进行规范化:
if normalize:
splits = np.array([_get_cummulative_return(split) for split in splits])
size = len(splits)
split = int(np.rint(train * size))
train = splits[:split,:]
test = splits[split:,:]
归一化函数是:
def _get_cummulative_return(data):
cumret = (data / data[0]) - 1
return cumret
建模过程:
Xtrain = np.reshape(Xtrain, (Xtrain.shape[0], Xtrain.shape[1], 1))
Xtest = np.reshape( Xtest, ( Xtest.shape[0], Xtest.shape[1], 1))
rnn = RNN([1, 100, 100, 1]) # number of neurons in each layer
rnn.fit(Xtrain, ytrain)
测试:
p = rnn.predict(Xtest)
要使用此预测变量,我应该:
如果是,如何对数据进行非规范化?