我将向您展示如何使用 LSTM 和 GRU 预测股票价格。
导入库
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import plotly.express as pxfrom keras.preprocessing.sequence import TimeseriesGenerator
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_errorfrom tensorflow.keras.models import Sequential
from tensorflow.keras.layers impor