无法预测小时时间序列到分钟时间序列?

时间:2019-04-30 23:53:34

标签: python machine-learning keras linear-regression lstm

model = Sequential()

model.add(LSTM(512, input_shape=(None, 1), return_sequences=True))

model.add(Dropout(0.3))



model.add(LSTM(512, input_shape=(None, 1)))

model.add(Dropout(0.3))



model.add(Dense(1))



model.compile(loss='mean_squared_error', optimizer='rmsprop', metrics=['accuracy'])

model.summary()

model.fit(x_train, y_train, epochs=10, batch_size=16)

p = model.predict(x_test)

这是我的代码,

这是小时时间序列lstm模型,结果如下

a

我想让这个模型来预测分钟单位

我只是想尝试线性回归

data = y # p
scaler = MinMaxScaler(feature_range=(0, 1))
data = scaler.fit_transform(data)
x = np.arange(0, len(y))
x=x.reshape(len(x),1)
x = scaler.fit_transform(x)

train_size = int(len(data) * 0.80)
test_size = len(data) - train_size

y_train = data[0:train_size]
y_test = data[train_size:len(data)]
x_train = x[0:train_size]
x_test = x[train_size:len(x)]
# from sklearn.model_selection import train_test_split
# x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.8, random_state=42)

XGBModel = XGBRegressor()
XGBModel.fit(x_train,y_train, verbose=False)

p = XGBModel.predict(x_test)
plt.plot(y_test)
plt.plot(p)
plt.legend(['y_test', 'p'], loc='upper right')
plt.title(mean_squared_error(y_test, p))

plt.show()
print(mean_squared_error(y_test, p))

然后像下面这样

b

我错了吗?或者这不可能得到预测的分钟单位吗?

0 个答案:

没有答案