From 4c8b74ad749ccdb745c1af1a3665638d04c50610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E5=AE=87=E9=B9=8F?= <13911091+fusir7@user.noreply.gitee.com> Date: Mon, 1 Jan 2024 14:53:55 +0000 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=A2=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 傅宇鹏 <13911091+fusir7@user.noreply.gitee.com> --- lstm/Data_preprocessing.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lstm/Data_preprocessing.py diff --git a/lstm/Data_preprocessing.py b/lstm/Data_preprocessing.py new file mode 100644 index 0000000..8a064fb --- /dev/null +++ b/lstm/Data_preprocessing.py @@ -0,0 +1,16 @@ +import pandas as pd +from sklearn.preprocessing import MinMaxScaler + +df = pd.read_csv('../dataset/GOOG-year.csv') #读取文件 +df.head() + +minmax = MinMaxScaler().fit(df.iloc[:, 4:5].astype('float32')) # Close index #对原始数据中的第5列(Close index)进行归一化处理,并将结果保存在df_log中 +df_log = minmax.transform(df.iloc[:, 4:5].astype('float32')) # Close index +df_log = pd.DataFrame(df_log) +df_log.head() + +test_size = 30 # 数据集与测试集的划分 +simulation_size = 10 #训练10次 + +df_train = df_log.iloc[:-test_size] +df_test = df_log.iloc[-test_size:] \ No newline at end of file -- Gitee