聚烯烃日度预测,上传市场信息平台

This commit is contained in:
workpc 2025-04-02 16:20:50 +08:00
parent 694be51fb8
commit e7cd575b88
2 changed files with 74 additions and 10 deletions

View File

@ -241,16 +241,16 @@ table_name = 'v_tbl_crude_oil_warning'
# 开关
is_train = False # 是否训练
is_train = True # 是否训练
is_debug = False # 是否调试
is_eta = False # 是否使用eta接口
is_eta = True # 是否使用eta接口
is_market = False # 是否通过市场信息平台获取特征 ,在is_eta 为true 的情况下生效
is_timefurture = True # 是否使用时间特征
is_fivemodels = False # 是否使用之前保存的最佳的5个模型
is_edbcode = False # 特征使用edbcoding列表中的
is_edbnamelist = False # 自定义特征对应上面的edbnamelist
is_update_eta = True # 预测结果上传到eta
is_update_report = False # 是否上传报告
is_update_report = True # 是否上传报告
is_update_warning_data = False # 是否上传预警数据
is_del_corr = 0.6 # 是否删除相关性高的特征,取值为 0-1 0 为不删除0.6 表示删除相关性小于0.6的特征
is_del_tow_month = True # 是否删除两个月不更新的特征

View File

@ -82,6 +82,68 @@ global_config.update({
})
def push_market_value():
config.logger.info('发送预测结果到市场信息平台')
# 读取预测数据和模型评估数据
predict_file_path = os.path.join(config.dataset, 'predict.csv')
model_eval_file_path = os.path.join(config.dataset, 'model_evaluation.csv')
try:
predictdata_df = pd.read_csv(predict_file_path)
top_models_df = pd.read_csv(model_eval_file_path)
except FileNotFoundError as e:
config.logger.error(f"文件未找到: {e}")
return
predictdata = predictdata_df.copy()
# 取模型前十
top_models = top_models_df['模型(Model)'].head(10).tolist()
# 去掉FDBformer
if 'FEDformer' in top_models:
top_models.remove('FEDformer')
# 计算前十模型的均值
predictdata_df['top_models_mean'] = predictdata_df[top_models].mean(axis=1)
# 打印日期和前十模型均值
print(predictdata_df[['ds', 'top_models_mean']])
# 准备要推送的数据
first_mean = predictdata_df['top_models_mean'].iloc[0]
last_mean = predictdata_df['top_models_mean'].iloc[-1]
# 保留两位小数
first_mean = round(first_mean, 2)
last_mean = round(last_mean, 2)
predictdata = [
{
"dataItemNo": global_config['bdwd_items']['ciri'],
"dataDate": global_config['end_time'].replace('-',''),
"dataStatus": "add",
"dataValue": first_mean
},
{
"dataItemNo": global_config['bdwd_items']['benzhou'],
"dataDate": global_config['end_time'].replace('-',''),
"dataStatus": "add",
"dataValue": last_mean
}
]
print(predictdata)
# 推送数据到市场信息平台
try:
push_market_data(predictdata)
except Exception as e:
config.logger.error(f"推送数据失败: {e}")
def predict_main():
"""
主预测函数用于从 ETA 获取数据处理数据训练模型并进行预测
@ -388,13 +450,15 @@ def predict_main():
if __name__ == '__main__':
# global end_time
# 遍历2024-11-25 到 2024-12-3 之间的工作日日期
for i_time in pd.date_range('2025-3-19', '2025-3-29', freq='B'):
try:
global_config['end_time'] = i_time.strftime('%Y-%m-%d')
predict_main()
except Exception as e:
logger.info(f'预测失败:{e}')
continue
# for i_time in pd.date_range('2025-3-19', '2025-3-29', freq='B'):
# try:
# global_config['end_time'] = i_time.strftime('%Y-%m-%d')
# predict_main()
# except Exception as e:
# logger.info(f'预测失败:{e}')
# continue
# predict_main()
push_market_value()