聚烯烃预测图上下界用5个最佳模型进行绘制

This commit is contained in:
workpc 2024-11-06 15:28:30 +08:00
parent ba237cb657
commit dbaf99fe38

View File

@ -508,12 +508,13 @@ def model_losss_juxiting(sqlitedb):
modelnames.remove('y') modelnames.remove('y')
df_combined3 = df_combined.copy() # 备份df_combined,后面画图需要 df_combined3 = df_combined.copy() # 备份df_combined,后面画图需要
# 每行预测值找到10%分位数和90%分位数
# 使用最佳五个模型进行绘图
best_models = pd.read_csv(os.path.join(dataset,'best_modelnames.txt'),header=None).values.flatten().tolist()
def find_min_max_within_quantile(row): def find_min_max_within_quantile(row):
row.drop(['ds','y'], inplace=True) row = row[best_models]
# 获取分位数10%和90%的值 q10 = row.min()
q10 = row.quantile(0.1) q90 = row.max()
q90 = row.quantile(0.9)
# 获取 row行10%分位值对应的模型名称 # 获取 row行10%分位值对应的模型名称
min_model = row[row == q10].idxmin() min_model = row[row == q10].idxmin()
max_model = row[row == q90].idxmin() max_model = row[row == q90].idxmin()
@ -530,10 +531,24 @@ def model_losss_juxiting(sqlitedb):
# 通道使用预测模型的80%置信度
# def find_min_max_within_quantile(row):
# row.drop(['ds','y'], inplace=True)
# # 获取分位数10%和90%的值
# q10 = row.quantile(0.1)
# q90 = row.quantile(0.9)
# # 获取 row行10%分位值对应的模型名称
# min_model = row[row == q10].idxmin()
# max_model = row[row == q90].idxmin()
# # # 判断flot值是否为空值
# # if pd.isna(q10) or pd.isna(q90):
# return pd.Series([q10, q90,min_model,max_model], index=['min_within_quantile','max_within_quantile','min_model','max_model'])
# # 遍历行
# df_combined3[['min_within_quantile', 'max_within_quantile','min_model','max_model']] = df_combined3.apply(find_min_max_within_quantile, axis=1)
# df_combined = df_combined.round(4)
# print(df_combined3)