基于GRU股票预测实战

import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import Dropout, Dense,GRU
import os
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error, mean_absolute_error
import math
import PySide2

dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

maotai = pd.read_csv('./Sh600519.csv')  # 读取股票数据
training_set = maotai.iloc[0:2426 - 300, 2:3].values  # 前(2426-300=2126)天的开票价格作为训练集,表格从0开始计数,2:3是读取【2:3)列,前闭后开,故提取c列开盘价
test_set = maotai.iloc[2426 - 300:, 2:3]  # 后300天开盘价作为测试集

# 归一化
sc = MinMaxScaler(feature_range=(0, 1))  # 定义归一化:归一化到(0,1)之间
training_set_scaled = sc.fit_transform(training_set)  # 求得训练集的最大值,最

你可能感兴趣的:(深度学习实战代码40例,gru,python,tensorflow,机器学习,深度学习)