具有多个变量的时间序列的递归神经网络-TensorFlow [英] Recurrent neural networks for Time Series with Multiple Variables - TensorFlow
本文介绍了具有多个变量的时间序列的递归神经网络-TensorFlow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 3个变量
使用以前的需求来预测未来需求,但是每当我运行代码时,我的 Y轴
都会显示错误
I'm using previous demand to predict future demand, using 3 variables
, but whenever I run the code my Y axis
shows error
如果我仅在 Y轴
上仅使用一个变量,则没有错误.
If I use only one variable on the Y axis
separately it has no error.
示例:
demandaY = bike_data[['cnt']]
n_steps = 20
for time_step in range(1, n_steps+1):
demandaY['cnt'+str(time_step)] = demandaY[['cnt']].shift(-time_step).values
y = demandaY.iloc[:, 1:].values
y = np.reshape(y, (y.shape[0], n_steps, 1))
数据集
脚本
features = ['cnt','temp','hum']
demanda = bike_data[features]
n_steps = 20
for var_col in features:
for time_step in range(1, n_steps+1):
demanda[var_col+str(time_step)] = demanda[[var_col]].shift(-time_step).values
demanda.dropna(inplace=True)
demanda.head()
n_var = len(features)
columns = list(filter(lambda col: not(col.endswith("%d" % n_steps)), demanda.columns))
X = demanda[columns].iloc[:, :(n_steps*n_var)].values
X = np.reshape(X, (X.shape[0], n_steps, n_var))
y = demanda.iloc[:, 0].values
y = np.reshape(y, (y.shape[0], n_steps, 1))
输出
ValueError: cannot reshape array of size 17379 into shape (17379,20,1)
查看全文