聚烯烃每周最佳模型逻辑调整
This commit is contained in:
parent
8074647329
commit
5a8e3ae007
@ -39,35 +39,35 @@ edbnamelist = [
|
||||
]
|
||||
|
||||
|
||||
# eta自有数据指标编码
|
||||
# eta自有数据指标编码 次月
|
||||
modelsindex = {
|
||||
'NHITS': 'SELF0000001',
|
||||
'Informer': 'SELF0000057',
|
||||
'LSTM': 'SELF0000058',
|
||||
'iTransformer': 'SELF0000059',
|
||||
'TSMixer': 'SELF0000060',
|
||||
'TSMixerx': 'SELF0000061',
|
||||
'PatchTST': 'SELF0000062',
|
||||
'RNN': 'SELF0000063',
|
||||
'GRU': 'SELF0000064',
|
||||
'TCN': 'SELF0000065',
|
||||
'BiTCN': 'SELF0000066',
|
||||
'DilatedRNN': 'SELF0000067',
|
||||
'MLP': 'SELF0000068',
|
||||
'DLinear': 'SELF0000069',
|
||||
'NLinear': 'SELF0000070',
|
||||
'TFT': 'SELF0000071',
|
||||
'FEDformer': 'SELF0000072',
|
||||
'StemGNN': 'SELF0000073',
|
||||
'MLPMultivariate': 'SELF0000074',
|
||||
'TiDE': 'SELF0000075',
|
||||
'DeepNPTS': 'SELF0000076'
|
||||
'NHITS': 'SELF0000143',
|
||||
'Informer': 'SELF0000144',
|
||||
'LSTM': 'SELF0000145',
|
||||
'iTransformer': 'SELF0000146',
|
||||
'TSMixer': 'SELF0000147',
|
||||
'TSMixerx': 'SELF0000148',
|
||||
'PatchTST': 'SELF0000149',
|
||||
'RNN': 'SELF0000150',
|
||||
'GRU': 'SELF0000151',
|
||||
'TCN': 'SELF0000152',
|
||||
'BiTCN': 'SELF0000153',
|
||||
'DilatedRNN': 'SELF0000154',
|
||||
'MLP': 'SELF0000155',
|
||||
'DLinear': 'SELF0000156',
|
||||
'NLinear': 'SELF0000157',
|
||||
'TFT': 'SELF0000158',
|
||||
'FEDformer': 'SELF0000159',
|
||||
'StemGNN': 'SELF0000160',
|
||||
'MLPMultivariate': 'SELF0000161',
|
||||
'TiDE': 'SELF0000162',
|
||||
'DeepNPTS': 'SELF0000163',
|
||||
}
|
||||
|
||||
# eta 上传预测结果的请求体,后面发起请求的时候更改 model datalist 数据
|
||||
data = {
|
||||
"IndexCode": "",
|
||||
"IndexName": "价格预测模型",
|
||||
"IndexName": "价格预测xx模型-次月",
|
||||
"Unit": "无",
|
||||
"Frequency": "日度",
|
||||
"SourceName": f"价格预测",
|
||||
@ -305,7 +305,7 @@ is_timefurture = True # 是否使用时间特征
|
||||
is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
||||
is_edbcode = False # 特征使用edbcoding列表中的
|
||||
is_edbnamelist = False # 自定义特征,对应上面的edbnamelist
|
||||
is_update_eta = False # 预测结果上传到eta
|
||||
is_update_eta = True # 预测结果上传到eta
|
||||
is_update_report = True # 是否上传报告
|
||||
is_update_warning_data = False # 是否上传预警数据
|
||||
is_update_predict_value = True # 是否上传预测值到市场信息平台
|
||||
|
@ -39,29 +39,29 @@ edbnamelist = [
|
||||
]
|
||||
|
||||
|
||||
# eta自有数据指标编码
|
||||
# eta自有数据指标编码 次周
|
||||
modelsindex = {
|
||||
'NHITS': 'SELF0000001',
|
||||
'Informer': 'SELF0000057',
|
||||
'LSTM': 'SELF0000058',
|
||||
'iTransformer': 'SELF0000059',
|
||||
'TSMixer': 'SELF0000060',
|
||||
'TSMixerx': 'SELF0000061',
|
||||
'PatchTST': 'SELF0000062',
|
||||
'RNN': 'SELF0000063',
|
||||
'GRU': 'SELF0000064',
|
||||
'TCN': 'SELF0000065',
|
||||
'BiTCN': 'SELF0000066',
|
||||
'DilatedRNN': 'SELF0000067',
|
||||
'MLP': 'SELF0000068',
|
||||
'DLinear': 'SELF0000069',
|
||||
'NLinear': 'SELF0000070',
|
||||
'TFT': 'SELF0000071',
|
||||
'FEDformer': 'SELF0000072',
|
||||
'StemGNN': 'SELF0000073',
|
||||
'MLPMultivariate': 'SELF0000074',
|
||||
'TiDE': 'SELF0000075',
|
||||
'DeepNPTS': 'SELF0000076'
|
||||
'NHITS': 'SELF0000099',
|
||||
'Informer': 'SELF0000100',
|
||||
'LSTM': 'SELF0000101',
|
||||
'iTransformer': 'SELF0000102',
|
||||
'TSMixer': 'SELF0000103',
|
||||
'TSMixerx': 'SELF0000104',
|
||||
'PatchTST': 'SELF0000105',
|
||||
'RNN': 'SELF0000106',
|
||||
'GRU': 'SELF0000107',
|
||||
'TCN': 'SELF0000108',
|
||||
'BiTCN': 'SELF0000109',
|
||||
'DilatedRNN': 'SELF0000110',
|
||||
'MLP': 'SELF0000111',
|
||||
'DLinear': 'SELF0000112',
|
||||
'NLinear': 'SELF0000113',
|
||||
'TFT': 'SELF0000114',
|
||||
'FEDformer': 'SELF0000115',
|
||||
'StemGNN': 'SELF0000116',
|
||||
'MLPMultivariate': 'SELF0000117',
|
||||
'TiDE': 'SELF0000118',
|
||||
'DeepNPTS': 'SELF0000119',
|
||||
}
|
||||
|
||||
# eta 上传预测结果的请求体,后面发起请求的时候更改 model datalist 数据
|
||||
|
@ -219,7 +219,6 @@ push_data_value_list_data = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 八大维度数据项编码
|
||||
bdwd_items = {
|
||||
'ciri': 'jxtppbdwdcr',
|
||||
@ -243,7 +242,7 @@ table_name = 'v_tbl_crude_oil_warning'
|
||||
# 开关
|
||||
is_train = True # 是否训练
|
||||
is_debug = False # 是否调试
|
||||
is_eta = True # 是否使用eta接口
|
||||
is_eta = False # 是否使用eta接口
|
||||
is_market = False # 是否通过市场信息平台获取特征 ,在is_eta 为true 的情况下生效
|
||||
is_timefurture = True # 是否使用时间特征
|
||||
is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
||||
|
@ -302,12 +302,13 @@ def predict_main():
|
||||
# 计算最近60天预测残差最低的模型名称
|
||||
model_results = sqlitedb.select_data(
|
||||
'trueandpredict', order_by="ds DESC", limit="60")
|
||||
|
||||
# 删除created_dt,y列空行
|
||||
model_results = model_results.dropna(
|
||||
subset=['created_dt', 'y'])
|
||||
# 删除空值率为90%以上的列
|
||||
if len(model_results) > 10:
|
||||
model_results = model_results.dropna(
|
||||
thresh=len(model_results)*0.1, axis=1)
|
||||
# 删除空行
|
||||
model_results = model_results.dropna()
|
||||
model_results = model_results.dropna(
|
||||
thresh=len(model_results)*0.1, axis=1)
|
||||
modelnames = model_results.columns.to_list()[2:-1]
|
||||
for col in model_results[modelnames].select_dtypes(include=['object']).columns:
|
||||
model_results[col] = model_results[col].astype(np.float32)
|
||||
|
@ -250,7 +250,8 @@ def ex_Model(df, horizon, input_size, train_steps, val_check_steps, early_stop_p
|
||||
list.append({'Date': date, 'Value': value})
|
||||
data['DataList'] = list
|
||||
data['IndexCode'] = modelsindex[m]
|
||||
data['IndexName'] = f'价格预测{m}模型'
|
||||
# data['IndexName'] = f'价格预测{m}模型'
|
||||
data['IndexName'] = data['IndexName'].replece('xx', m)
|
||||
data['Remark'] = m
|
||||
etadata.push_data(data)
|
||||
|
||||
@ -463,7 +464,7 @@ def ex_Model_Juxiting(df, horizon, input_size, train_steps, val_check_steps, ear
|
||||
if config.is_update_eta:
|
||||
df_predict['ds'] = pd.to_datetime(df_predict['ds'])
|
||||
dates = df_predict['ds'].dt.strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
for m in modelsindex.keys():
|
||||
try:
|
||||
list = []
|
||||
@ -1247,7 +1248,6 @@ def model_losss(sqlitedb, end_time):
|
||||
_get_accuracy_rate(df, create_dates, ds_dates)
|
||||
except Exception as e:
|
||||
config.logger.info(f'准确率计算错误{e}')
|
||||
|
||||
|
||||
def _add_abs_error_rate():
|
||||
# 计算每个预测值与真实值之间的偏差率
|
||||
@ -1822,7 +1822,8 @@ def model_losss_juxitingbak(sqlitedb, end_time):
|
||||
plt.text(i, j, str(j), ha='center', va='bottom')
|
||||
|
||||
# 当前日期画竖虚线
|
||||
plt.axvline(x=df['ds'].iloc[-config.horizon], color='r', linestyle='--')
|
||||
plt.axvline(x=df['ds'].iloc[-config.horizon],
|
||||
color='r', linestyle='--')
|
||||
plt.legend()
|
||||
plt.xlabel('日期')
|
||||
# 自动设置横轴日期显示
|
||||
@ -2270,7 +2271,7 @@ def brent_export_pdf(num_indicators=475, num_models=21, num_dayindicator=202, in
|
||||
config.dataset, 'model_evaluation.csv'), encoding='utf-8')
|
||||
# 按评估指标排序,取前五
|
||||
fivemodels_list = eval_df['模型(Model)'].values # 列表形式,后面当作列名索引使用
|
||||
eval_models_list = fivemodels_list.tolist()
|
||||
eval_models_list = fivemodels_list.tolist()
|
||||
# 去掉FEDformer
|
||||
if 'FEDformer' in eval_models_list:
|
||||
eval_models_list.remove('FEDformer')
|
||||
@ -2356,7 +2357,8 @@ def brent_export_pdf(num_indicators=475, num_models=21, num_dayindicator=202, in
|
||||
content.append(Graphs.draw_little_title('模型选择:'))
|
||||
content.append(Graphs.draw_text(
|
||||
f'本次预测使用了一个专门收集时间序列的NeuralForecast库中的{num_models}个模型:'))
|
||||
content.append(Graphs.draw_text(f'使用{config.input_size}个数据预测未来{inputsize}个数据。'))
|
||||
content.append(Graphs.draw_text(
|
||||
f'使用{config.input_size}个数据预测未来{inputsize}个数据。'))
|
||||
content.append(Graphs.draw_little_title('指标情况:'))
|
||||
with open(os.path.join(config.dataset, '特征频度统计.txt'), encoding='utf-8') as f:
|
||||
for line in f.readlines():
|
||||
|
Loading…
Reference in New Issue
Block a user