到底预测的是未来什么时间长度?我们看到过最多的应该就是在测试集上做预测了,比如训练好模型之后就model.predict(x_test),然后以scatter plot的形式绘制出预测值和观测值(真实值),如下图: 但是在具体的预测上面,似乎看不到影子。话说话来,这个好像也算预测,因为是相对的一个数据集。如果有理解和解读错误的地方还...
tw:int,pw:int,target_columns,drop_targets=False):'''df: Pandas DataFrame of the univariate time-seriestw: Training Window - Integer defining how many steps to look backpw: Prediction Window - Integer defining how many steps forward to predictreturns: dictionary of sequences and targets for al...
df_testing_scaled= self._train_test_split()[1] X_test,y_test=self.createXY(df_testing_scaled)#预测值prediction =self.model.predict(X_test) prediction_copy_array= np.repeat(prediction,self.n_features,axis=-1) pred=self.scaler.inverse_transform(np.reshape(prediction_copy_array,(len(predictio...
return predict, test_y filename = 'passenger.csv' AirLine = Airline_Predict(filename) train_x, train_y, test_x, test_y, MMS = AirLine.load_data() predict_y, test_y = AirLine.train_model(train_x, train_y, test_x, test_y) #对标注化后的数据还原 predict_y = MMS.inverse_transform...
test_predict_plot[:, :] = np.nan test_predict_plot[len(scaled_data)-len(test_predict):len(scaled_data),:] = test_predict plt.figure(figsize=(16,8))plt.plot(df.values[:,0], label='Actual Temperature')plt.plot(test_predict_plot[:,0], label='Predicted Temperature')plt.legend()plt...
prediction=my_model.predict(testX)print("prediction\n",prediction)print("\nPrediction Shape-",prediction.shape) testY 和 prediction 的长度是一样的。现在可以将 testY 与预测进行比较。 但是我们一开始就对数据进行了缩放,所以首先我们必须做一些逆缩放过程。
predictY = model.predict(testX) print(predictY) # Plot the results plt.figure(figsize=(20,4)) plt.suptitle('Prediction') plt.title('History='+str(steps_of_history)+', Future='+str(steps_in_future)) plt.plot(x, 'r-', label='Actual') plt.plot(predictY, 'gx', label='Predicted...
predict_y = unminmaxscaler(predict_y, train_x_minmax[0], train_y_minmax[1]) new_data_x[i] = predict_y 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 训练了几次,每次结果都不太一样,取了一个相对不错的。由于使用的是原油价格,随机性比较大,如果是规律性...
predict(test_X)] # 计算MSE rmse = np.sqrt(((predicted - test_y) ** 2).mean(axis=0)) print("Mean Square Error is:%f" % rmse[0]) plot_predicted, = plt.plot(predicted, label='predicted') plot_test, = plt.plot(test_y, label='real_sin') plt.legend([plot_predicted, plot_...
arima_pred = arima_result.predict(start = len(train_data), end = len(df)-1, typ="levels").rename("ARIMA Predictions") arima_pred test_data['Monthly beer production'].plot(figsize = (16,5), legend=True) arima_pred.plot(legend = True); ...