diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 丽水 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 丽水 .xlsx new file mode 100644 index 0000000..10b4de1 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 丽水 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 台州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 台州 .xlsx new file mode 100644 index 0000000..d049e57 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 台州 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 嘉兴 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 嘉兴 .xlsx new file mode 100644 index 0000000..3106d9d Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 嘉兴 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 宁波 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 宁波 .xlsx new file mode 100644 index 0000000..935b6f4 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 宁波 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 杭州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 杭州 .xlsx new file mode 100644 index 0000000..cdacaf3 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 杭州 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 温州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 温州 .xlsx new file mode 100644 index 0000000..8675ecc Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 温州 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 湖州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 湖州 .xlsx new file mode 100644 index 0000000..e7e6ad8 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 湖州 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 绍兴 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 绍兴 .xlsx new file mode 100644 index 0000000..2deaa7e Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 绍兴 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 舟山 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 舟山 .xlsx new file mode 100644 index 0000000..ac1eb0e Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 舟山 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 衢州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 衢州 .xlsx new file mode 100644 index 0000000..5d2c300 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 衢州 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/ 金华 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/ 金华 .xlsx new file mode 100644 index 0000000..6724b4e Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/ 金华 .xlsx differ diff --git a/浙江电压等级电量/浙江各地市分电压日电量数据/~$ 杭州 .xlsx b/浙江电压等级电量/浙江各地市分电压日电量数据/~$ 杭州 .xlsx new file mode 100644 index 0000000..54bf8a2 Binary files /dev/null and b/浙江电压等级电量/浙江各地市分电压日电量数据/~$ 杭州 .xlsx differ diff --git a/浙江电压等级电量/电压等级_输出为5.py b/浙江电压等级电量/电压等级_输出为5.py index 9ae6363..5536370 100644 --- a/浙江电压等级电量/电压等级_输出为5.py +++ b/浙江电压等级电量/电压等级_输出为5.py @@ -52,61 +52,61 @@ def data_preprocessing(data): return data # 拼接数据集 -# file_dir = r'C:\Users\user\Desktop\浙江各地市分电压日电量数据' -# excel = os.listdir(file_dir)[0] -# data = pd.read_excel(os.path.join(file_dir, excel), sheet_name=0, index_col='stat_date') -# data.drop(columns='地市',inplace=True) -# data = data_preprocessing(data) -# -# df = data[data.columns[0]] -# df.dropna(inplace = True) -# dataset_x, dataset_y = create_dataset(df, DAYS_FOR_TRAIN) -# -# for level in data.columns[1:]: -# df = data[level] -# df.dropna(inplace=True) -# x, y = create_dataset(df, DAYS_FOR_TRAIN) -# dataset_x = np.concatenate((dataset_x, x)) -# dataset_y = np.concatenate((dataset_y, y)) -# -# -# for excel in os.listdir(file_dir)[1:]: -# -# data = pd.read_excel(os.path.join(file_dir,excel), sheet_name=0,index_col='stat_date') -# data.drop(columns='地市', inplace=True) -# data = data_preprocessing(data) -# -# for level in data.columns: -# df = data[level] -# df.dropna(inplace=True) -# x,y = create_dataset(df,DAYS_FOR_TRAIN) -# dataset_x = np.concatenate((dataset_x,x)) -# dataset_y = np.concatenate((dataset_y,y)) -# -# -# +file_dir = r'C:\Users\user\Desktop\浙江各地市分电压日电量数据' +excel = os.listdir(file_dir)[0] +data = pd.read_excel(os.path.join(file_dir, excel), sheet_name=0, index_col='stat_date') +data.drop(columns='地市',inplace=True) +data = data_preprocessing(data) + +df = data[data.columns[0]] +df.dropna(inplace = True) +dataset_x, dataset_y = create_dataset(df, DAYS_FOR_TRAIN) + +for level in data.columns[1:]: + df = data[level] + df.dropna(inplace=True) + x, y = create_dataset(df, DAYS_FOR_TRAIN) + dataset_x = np.concatenate((dataset_x, x)) + dataset_y = np.concatenate((dataset_y, y)) + + +for excel in os.listdir(file_dir)[1:]: + + data = pd.read_excel(os.path.join(file_dir,excel), sheet_name=0,index_col='stat_date') + data.drop(columns='地市', inplace=True) + data = data_preprocessing(data) + + for level in data.columns: + df = data[level] + df.dropna(inplace=True) + x,y = create_dataset(df,DAYS_FOR_TRAIN) + dataset_x = np.concatenate((dataset_x,x)) + dataset_y = np.concatenate((dataset_y,y)) + + + # # 训练 device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # -# # 标准化到0~1 -# max_value = np.max(dataset_x) -# min_value = np.min(dataset_x) -# dataset_x = (dataset_x - min_value) / (max_value - min_value) -# dataset_y = (dataset_y - min_value) / (max_value - min_value) -# -# print(max_value,min_value) -# # 划分训练集和测试集 -# train_size = int(len(dataset_x)*0.7) -# train_x = dataset_x[:train_size] -# train_y = dataset_y[:train_size] -# -# # 将数据改变形状,RNN 读入的数据维度是 (seq_size, batch_size, feature_size) -# train_x = train_x.reshape(-1, 1, DAYS_FOR_TRAIN) -# train_y = train_y.reshape(-1, 1, 5) -# -# # 转为pytorch的tensor对象 -# train_x = torch.from_numpy(train_x).to(device).type(torch.float32) -# train_y = torch.from_numpy(train_y).to(device).type(torch.float32) +# 标准化到0~1 +max_value = np.max(dataset_x) +min_value = np.min(dataset_x) +dataset_x = (dataset_x - min_value) / (max_value - min_value) +dataset_y = (dataset_y - min_value) / (max_value - min_value) + +print(max_value,min_value) +# 划分训练集和测试集 +train_size = int(len(dataset_x)*0.7) +train_x = dataset_x[:train_size] +train_y = dataset_y[:train_size] + +# 将数据改变形状,RNN 读入的数据维度是 (seq_size, batch_size, feature_size) +train_x = train_x.reshape(-1, 1, DAYS_FOR_TRAIN) +train_y = train_y.reshape(-1, 1, 5) + +# 转为pytorch的tensor对象 +train_x = torch.from_numpy(train_x).to(device).type(torch.float32) +train_y = torch.from_numpy(train_y).to(device).type(torch.float32) model = LSTM_Regression(DAYS_FOR_TRAIN, 32, output_size=5, num_layers=2).to(device) # 导入模型并设置模型的参数输入输出层、隐藏层等