上传eta数据接口日志更新,聚烯烃只上传第五天的数据

This commit is contained in:
jingboyitiji 2025-02-13 17:05:30 +08:00
parent 1ca61af0a8
commit 0893fbde4d
3 changed files with 15 additions and 12 deletions

View File

@ -225,7 +225,7 @@ print("数据库连接成功",host,dbname,dbusername)
# 数据截取日期 # 数据截取日期
start_year = 2020 # 数据开始年份 start_year = 2020 # 数据开始年份
end_time = '' # 数据截取日期 end_time = '2025-01-27' # 数据截取日期
freq = 'B' # 时间频率,"D": 天 "W": 周"M": 月"Q": 季度"A": 年 "H": 小时 "T": 分钟 "S": 秒 "B": 工作日 freq = 'B' # 时间频率,"D": 天 "W": 周"M": 月"Q": 季度"A": 年 "H": 小时 "T": 分钟 "S": 秒 "B": 工作日
delweekenday = True if freq == 'B' else False # 是否删除周末数据 delweekenday = True if freq == 'B' else False # 是否删除周末数据
is_corr = False # 特征是否参与滞后领先提升相关系数 is_corr = False # 特征是否参与滞后领先提升相关系数

View File

@ -1667,14 +1667,14 @@ class EtaReader():
} }
# 发送post请求 上传数据 # 发送post请求 上传数据
logger.info('请求参数:',data) logger.info(f'请求参数:{data}')
response = requests.post(self.edbdatapushurl, headers=self.headers,data=json.dumps(data)) response = requests.post(self.edbdatapushurl, headers=self.headers,data=json.dumps(data))
# 检查响应状态码 # 检查响应状态码
if response.status_code == 200: if response.status_code == 200:
data = response.json() # 假设接口返回的是JSON数据 data = response.json() # 假设接口返回的是JSON数据
logger.info('上传成功,响应为:', data) logger.info(f'上传成功,响应为:{data}')
else: else:
# 请求失败,打印错误信息 # 请求失败,打印错误信息

View File

@ -379,17 +379,20 @@ def ex_Model_Juxiting(df,horizon,input_size,train_steps,val_check_steps,early_st
logger.info('读取模型:'+ filename) logger.info('读取模型:'+ filename)
nf = load(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') # df_test['ds'] = pd.to_datetime(df_test['ds'], errors='coerce')
#进行未来时间预测 #进行未来时间预测
df_predict=nf.predict(df_test).reset_index() df_predict=nf.predict(df_test).reset_index()
# 去掉index列 # 去掉index列
df_predict.drop(columns=['index'], inplace=True) df_predict.drop(columns=['index'], inplace=True)
df_predict.astype({col: 'float32' for col in df_predict.columns if col not in ['ds'] }) # 处理非有限值NA 或 inf将其替换为 0
df_predict = df_predict.fillna(0)
df_predict = df_predict.replace([np.inf, -np.inf], 0)
df_predict.astype({col: 'int' for col in df_predict.columns if col not in ['ds'] })
# 添加预测时间 # 添加预测时间
df_predict['created_dt'] = end_time df_predict['created_dt'] = end_time
@ -407,13 +410,13 @@ def ex_Model_Juxiting(df,horizon,input_size,train_steps,val_check_steps,early_st
for m in modelsindex.keys(): for m in modelsindex.keys():
list = [] list = []
for date,value in zip(dates,df_predict[m].round(2)): for date,value in zip(dates,df_predict[m]):
list.append({'Date':date,'Value':value}) list.append({'Date':date,'Value':value})
data['DataList'] = list data['DataList'] = [list[-1]]
data['IndexCode'] = modelsindex[m] data['IndexCode'] = modelsindex[m]
data['IndexName'] = f'价格预测{m}模型' data['IndexName'] = f'聚烯烃价格预测{m}模型'
data['Remark'] = m data['Remark'] = m
etadata.push_data(data) etadata.push_data(data=data)
# return nf_test_preds # return nf_test_preds