我使用3 variables
使用以前的需求来预测未来需求,但是每当我运行代码时,我的Y axis
就会显示错误
如果我仅在Y axis
上仅使用一个变量,则没有错误。
示例:
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_var))
y = demanda.iloc[:,0].values
y = np.reshape(y,1))
输出
ValueError: cannot reshape array of size 17379 into shape (17379,20,1)
GitHub: repository