17427 11 months ago
parent 704914a0bc
commit 7a4d041dc2

@ -58,6 +58,7 @@ def to_data(file_dir, excel):
df = (df - min_value) / (max_value - min_value)
dataset_x, dataset_y = create_dataset(df, DAYS_FOR_TRAIN)
print()
print('len(dataset_x:)', len(dataset_x))
# 划分训练集和测试集
@ -91,7 +92,7 @@ def to_data(file_dir, excel):
train_loss.append(loss.item())
b = time.time()
print(excel,industry,'训练用时',b-a)
print(excel, industry, '训练用时', b - a)
# 保存模型
# torch.save(model.state_dict(),save_filename)
@ -121,7 +122,7 @@ def to_data(file_dir, excel):
result_eight = pd.DataFrame({'pred_test': pred_test[-31:], 'real': df[-31:]})
target = (result_eight['pred_test'][-3:].sum() - result_eight['real'][-3:].sum()) / result_eight[
'real'].sum()
print(target)
# print(target)
with open(fr'.\cws_to_data\{excel[:2]}.txt', 'a', encoding='utf-8') as f:
tmp_data = {'city': excel[:2], 'industry': industry, "month_deviation_rate": round(target, 5)}
f.write(str(tmp_data) + "\n")

Loading…
Cancel
Save