plt.plot(real_stock_price, color = 'red', label = 'Real TATA Stock Price') plt.plot(predicted_stock_price, color = 'blue', label = 'Predicted TAT Stock Price') plt.title('TATA Stock Price Prediction') plt.xlabel('samples') plt.ylabel('TATA Stock Price') plt.legend() plt.show()...
transform(predicted_prices) y_test = scaler.inverse_transform(y_test) # 绘制预测结果 plt.plot(y_test, label='True_Prices') plt.plot(predicted_prices, label='Predicted_Prices') plt.legend() plt.xlabel('Time_Steps') plt.ylabel('Stock_Price') plt.title('LSTM Stock Price Prediction') plt...
# 预测与实际差异的可视化 plt.plot(real_stock_price, color ='red', label ='Real TATA Stock Price') plt.plot(predicted_stock_price, color ='blue', label ='Predicted TAT Stock Price') plt.title('TATA Stock Price Prediction') plt.xlabel('samples') plt.ylabel('TATA Stock Price') plt.le...
plt.plot(original, color = 'red', label = 'Real Stock Price') plt.plot(pred, color = 'blue', label = 'Predicted Stock Price') plt.title('Stock Price Prediction') plt.xlabel('Time') plt.ylabel('Google Stock Price') plt.legend() plt.show() 看样子还不错,到目前为止,我们训练了模型...
(X_test)# 可视化预测结果plt.figure(figsize=(12,6))plt.plot(data['Date'],y,label='Actual',color='blue')plt.scatter(data['Date'].iloc[X_test.flatten()],predictions,label='Predicted',color='red')plt.title('Stock Price Prediction')plt.xlabel('Date')plt.ylabel('Price')plt.legend()...
()1314#预测15stock_data['Predicted'] =model.predict(X)1617#绘制结果18plt.figure(figsize=(12,6))19plt.plot(stock_data['close'], label='Actual')20plt.plot(stock_data['Predicted'], label='Predicted', color='red')21plt.title('Stock Price Prediction with OLS')22plt.legend()23plt.show...
# 预测股价y_pred=model.predict(X_test.values.reshape(-1,1))# 绘制股价预测图plt.figure(figsize=(10,6))plt.scatter(X_test,y_test,color='blue')plt.plot(X_test,y_pred,color='red',linewidth=2)plt.xlabel('Date')plt.ylabel('Price')plt.title('Stock Price Prediction')plt.show() ...
plt.plot(real_stock_price, color = 'red', label = 'Real TATA Stock Price') plt.plot(predicted_stock_price, color = 'blue', label = 'Predicted TAT Stock Price') plt.title('TATA Stock Price Prediction') plt.xlabel('samples')
], net_df['Open'].tail(600), color='green', label = 'Train Stock Price')plt.plot(test_data.index, y, color = 'red', label = 'Real Stock Price')plt.plot(test_data.index, predictions, color = 'blue', label = 'Predicted Stock Price')plt.title('Netflix Stock Price Prediction')...
plt.title('Stock Price Prediction') plt.xlabel('Time') plt.ylabel('Google Stock Price') plt.legend() plt.show() 看样子还不错,到目前为止,我们训练了模型并用测试值检查了该模型。现在让我们预测一些未来值。 从主df 数据集中获取我们在开始时加载的最后 30 个值[为什么是 30?因为这是我们想要的过去...