更改准确率计算逻辑

This commit is contained in:
liurui 2024-12-16 11:21:37 +08:00
parent 6e7f425382
commit 1ad1553e01
2 changed files with 10 additions and 5 deletions

View File

@ -234,12 +234,12 @@ def predict_main(end_time):
file=max(glob.glob(os.path.join(dataset,'*.pdf')), key=os.path.getctime),
ssl=ssl,
)
# m.send_mail()
m.send_mail()
if __name__ == '__main__':
# 遍历2024-11-25 到 2024-12-3 之间的工作日日期
for i_time in pd.date_range('2024-12-16', '2024-12-17', freq='B'):
for i_time in pd.date_range('2024-11-22', '2024-12-16', freq='B'):
end_time = i_time.strftime('%Y-%m-%d')
# print(e_time)
predict_main(end_time)

View File

@ -187,9 +187,9 @@ def ex_Model(df,horizon,input_size,train_steps,val_check_steps,early_stop_patien
logger.info('读取模型:'+ filename)
nf = load(filename)
# # # 测试集预测
# nf_test_preds = nf.cross_validation(df=df_test, val_size=val_size, test_size=test_size, n_windows=None)
nf_test_preds = nf.cross_validation(df=df_test, val_size=val_size, test_size=test_size, n_windows=None)
# # 测试集预测结果保存
# nf_test_preds.to_csv(os.path.join(dataset,"cross_validation.csv"),index=False)
nf_test_preds.to_csv(os.path.join(dataset,"cross_validation.csv"),index=False)
df_test['ds'] = pd.to_datetime(df_test['ds'], errors='coerce')
@ -426,7 +426,12 @@ def model_losss(sqlitedb,end_time):
# 上周准确率计算
predict_y = sqlitedb.select_data(table_name = "accuracy")
ids = predict_y[predict_y['min_price'].isnull()]['id'].tolist()
predict_y[['min_price','max_price']] = predict_y[['min_within_quantile','max_within_quantile']]
# 模型评估前五最大最小
# predict_y[['min_price','max_price']] = predict_y[['min_within_quantile','max_within_quantile']]
# 模型评估前五均值 df_combined3['mean'] = df_combined3[modelnames].mean(axis=1)
predict_y['min_price'] = predict_y[modelnames].mean(axis=1) -1
predict_y['max_price'] = predict_y[modelnames].mean(axis=1) +1
for id in ids:
row = predict_y[predict_y['id'] == id]
try: