聚烯烃绘图逻辑更改
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 58 KiB |
@ -1,4 +1,4 @@
|
||||
日度(220),周度(93),84天(1)
|
||||
日度(219),周度(94),119天(1)
|
||||
PP主力收盘价拟合残差/丙烷 CP M1,PE注塑开工率/周,中国:华东地区:市场平均价:BOPP厚光膜
|
||||
华南聚丙烯基差(折盘面收盘价),PP:看跌比例:中国(周),
|
||||
华北聚丙烯基差(折盘面收盘价),PP:看平比例:中国(周),
|
||||
@ -60,39 +60,39 @@ PP:高熔共聚:2240S:自提价:常州:国家能源宁煤(日),PP
|
||||
PP:高熔共聚:EP548R:市场价:广州:中科炼化(日),PP粉料库存,
|
||||
PP:高熔共聚:2240S:出厂价:华南地区:国家能源宁煤(日),中国BOPP原料库存量,
|
||||
PP:高熔共聚:EP548R:出厂价:华南地区:中海壳牌(日),BOPP订单天数-产成品库存天数(隆众),
|
||||
PP:薄壁注塑:BZ-70:出厂价:华北地区:寿光鲁清(日),PP下游综合开工率/2WMA,
|
||||
PP:薄壁注塑:PPH-MM60:出厂价:华北地区:石家庄炼化(日),PP下游综合开工率同差,
|
||||
PP:薄壁注塑:K1870-B:市场价:临沂:榆能化(日),PP周度产量/4WMA,
|
||||
PP:薄壁注塑:M60ET:出厂价:华东地区:镇海炼化(日),PP粉检修减损量(周),
|
||||
PP:薄壁注塑:1040TE:出厂价:华东地区:宁夏神华宁煤(日),PP周度产量同差,
|
||||
PP:薄壁注塑:1040TE:出厂价:华南地区:宁夏神华宁煤(日),PP周度产量,
|
||||
PP:薄壁注塑:PPH-MN60:出厂价:华南地区:中石化北海(日),PP周度开工率,
|
||||
PP:薄壁注塑:TM6000H:出厂价:华南地区:福建联合石化(日),PP下游开工/PE下游开工,
|
||||
PP:透明:PPR-B10:出厂价:华中地区:中原中石化(日),PP管材开工率同差,
|
||||
PP:透明:PPR-MT25:出厂价:华中地区:中原中石化(日),PP无纺布开工率同差,
|
||||
PP:透明:PPR-MT75N:出厂价:华中地区:中原中石化(日),PP下游综合开工率/3年超季节性,
|
||||
PP:无规共聚:HC-M700B:出厂价:华北地区:山东东明(日),中国再生PP周度开工负荷率,
|
||||
热水管:PA14D:市场价:青州:大庆炼化(日),中国再生PP周度开工负荷率同差,
|
||||
CPP:二元共聚膜:DY-W0723F:市场主流价:天津:独山子石化(日),PP粉料开工率(4WMA),
|
||||
PP:透明:R3080T:出厂价:华东地区:浙江鸿基(日),PP检修减损量,
|
||||
PP:透明:M08ETN:出厂价:华东地区:镇海炼化(日),PP下游综合开工率(少注塑&CPP),
|
||||
PP:透明:R3260T:出厂价:华东地区:浙江鸿基(日),BOPP开工率同差,
|
||||
热水管:YPR-503:出厂价:华东地区:扬子石化(日),BOPP开工率(4WMA),
|
||||
热水管:PA14D:出厂价:华东地区:大庆炼化(日),PP粉料开工率,
|
||||
CPP:二元共聚膜:F800EDF:出厂价:华东地区:上海石化(日),PP周度检修率,
|
||||
CPP:二元共聚膜:F08EC:出厂价:华东地区:镇海炼化(日),PP周度产量周环差,
|
||||
PP:透明:HT9025NX:出厂价:华南地区:茂名石化(日),PP周度产量同比,
|
||||
PP:透明:HT9025ZK:出厂价:华南地区:中科炼化(日),PP下游成品库存天数,
|
||||
PP:透明:HT9025NX:市场主流价:广州:中石化茂名(日),PP部分下游订单天数,
|
||||
热水管:T4401:出厂价:华南地区:茂名石化(日),中国BOPP订单天数同差,
|
||||
热水管:PPR-4220:出厂价:华南地区:广州石化(日),中国BOPP订单天数/4WMA,
|
||||
PP:BOPP:1103K:出厂价:华北地区:国家能源宁煤(日),BOPP完工订单工作量(周),
|
||||
PP:BOPP:PPH-FL03-S:出厂价:华北地区:青岛炼化(日),中国再生PP周度样本成交量,
|
||||
PP:BOPP:1103K:出厂价:华东地区:国家能源宁煤(日),BOPP开工率超季节性/3年,
|
||||
PP:BOPP:F03BT:出厂价:华东地区:镇海炼化(日),中国BOPP成品库存量同差,
|
||||
PP:BOPP:1103K:出厂价:华南地区:宁夏神华宁煤(日),中国CPP订单天数,
|
||||
PP:BOPP:L5D98:出厂价:华南地区:广东石化(日),BOPP 订单-成品天数,
|
||||
PP:BOPP:PPH-F03D:出厂价:华南地区:海南炼化装置一(日),,
|
||||
PP:薄壁注塑:BZ-70:出厂价:华北地区:寿光鲁清(日),BOPP开工率(隆众)同差,
|
||||
PP:薄壁注塑:PPH-MM60:出厂价:华北地区:石家庄炼化(日),PP下游综合开工率/2WMA,
|
||||
PP:薄壁注塑:K1870-B:市场价:临沂:榆能化(日),PP下游综合开工率同差,
|
||||
PP:薄壁注塑:M60ET:出厂价:华东地区:镇海炼化(日),PP周度产量/4WMA,
|
||||
PP:薄壁注塑:1040TE:出厂价:华东地区:宁夏神华宁煤(日),PP粉检修减损量(周),
|
||||
PP:薄壁注塑:1040TE:出厂价:华南地区:宁夏神华宁煤(日),PP周度产量同差,
|
||||
PP:薄壁注塑:PPH-MN60:出厂价:华南地区:中石化北海(日),PP周度产量,
|
||||
PP:薄壁注塑:TM6000H:出厂价:华南地区:福建联合石化(日),PP周度开工率,
|
||||
PP:透明:PPR-B10:出厂价:华中地区:中原中石化(日),PP下游开工/PE下游开工,
|
||||
PP:透明:PPR-MT25:出厂价:华中地区:中原中石化(日),PP管材开工率同差,
|
||||
PP:透明:PPR-MT75N:出厂价:华中地区:中原中石化(日),PP无纺布开工率同差,
|
||||
PP:无规共聚:HC-M700B:出厂价:华北地区:山东东明(日),PP下游综合开工率/3年超季节性,
|
||||
热水管:PA14D:市场价:青州:大庆炼化(日),中国再生PP周度开工负荷率,
|
||||
CPP:二元共聚膜:DY-W0723F:市场主流价:天津:独山子石化(日),中国再生PP周度开工负荷率同差,
|
||||
PP:透明:R3080T:出厂价:华东地区:浙江鸿基(日),PP粉料开工率(4WMA),
|
||||
PP:透明:M08ETN:出厂价:华东地区:镇海炼化(日),PP检修减损量,
|
||||
PP:透明:R3260T:出厂价:华东地区:浙江鸿基(日),PP下游综合开工率(少注塑&CPP),
|
||||
热水管:YPR-503:出厂价:华东地区:扬子石化(日),BOPP开工率同差,
|
||||
热水管:PA14D:出厂价:华东地区:大庆炼化(日),BOPP开工率(4WMA),
|
||||
CPP:二元共聚膜:F800EDF:出厂价:华东地区:上海石化(日),PP粉料开工率,
|
||||
CPP:二元共聚膜:F08EC:出厂价:华东地区:镇海炼化(日),PP周度检修率,
|
||||
PP:透明:HT9025NX:出厂价:华南地区:茂名石化(日),PP周度产量周环差,
|
||||
PP:透明:HT9025ZK:出厂价:华南地区:中科炼化(日),PP周度产量同比,
|
||||
PP:透明:HT9025NX:市场主流价:广州:中石化茂名(日),PP下游成品库存天数,
|
||||
热水管:T4401:出厂价:华南地区:茂名石化(日),PP部分下游订单天数,
|
||||
热水管:PPR-4220:出厂价:华南地区:广州石化(日),中国BOPP订单天数同差,
|
||||
PP:BOPP:1103K:出厂价:华北地区:国家能源宁煤(日),中国BOPP订单天数/4WMA,
|
||||
PP:BOPP:PPH-FL03-S:出厂价:华北地区:青岛炼化(日),BOPP完工订单工作量(周),
|
||||
PP:BOPP:1103K:出厂价:华东地区:国家能源宁煤(日),中国再生PP周度样本成交量,
|
||||
PP:BOPP:F03BT:出厂价:华东地区:镇海炼化(日),BOPP开工率超季节性/3年,
|
||||
PP:BOPP:1103K:出厂价:华南地区:宁夏神华宁煤(日),中国BOPP成品库存量同差,
|
||||
PP:BOPP:L5D98:出厂价:华南地区:广东石化(日),中国CPP订单天数,
|
||||
PP:BOPP:PPH-F03D:出厂价:华南地区:海南炼化装置一(日),BOPP 订单-成品天数,
|
||||
CPP:二元共聚膜:PPR-F08M-S:出厂价:华南地区:茂名石化(日),,
|
||||
CPP:二元共聚膜:PPR-F08-S:出厂价:华南地区:茂名石化(日),,
|
||||
BOPP:12μ光膜:出厂价:华北地区:凯达包装(日),,
|
||||
@ -156,7 +156,6 @@ PP现货-丙烯价差(山东),,
|
||||
聚丙烯出口利润,,
|
||||
PP检修损失量(万吨/年),,
|
||||
PP日度产量1000天百分位,,
|
||||
BOPP开工率(隆众)同差,,
|
||||
PP开工率/2WMA,,
|
||||
PP开工率同差,,
|
||||
PP日度开工率,,
|
||||
|
|
@ -1,4 +1,4 @@
|
||||
特征信息:总共有312个,日度(220),周度(93),84天(1), 详看 附1、特征列表
|
||||
特征信息:总共有312个,日度(219),周度(94),119天(1), 详看 附1、特征列表
|
||||
数据特征工程:
|
||||
1. 数据日期排序,新日期在最后
|
||||
2. 删除空列,特征数据列没有值,就删除
|
||||
|
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 56 KiB |
@ -108,25 +108,25 @@ def predict_main():
|
||||
row,col = df.shape
|
||||
|
||||
now = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
ex_Model(df,
|
||||
horizon=horizon,
|
||||
input_size=input_size,
|
||||
train_steps=train_steps,
|
||||
val_check_steps=val_check_steps,
|
||||
early_stop_patience_steps=early_stop_patience_steps,
|
||||
is_debug=is_debug,
|
||||
dataset=dataset,
|
||||
is_train=is_train,
|
||||
is_fivemodels=is_fivemodels,
|
||||
val_size=val_size,
|
||||
test_size=test_size,
|
||||
settings=settings,
|
||||
now=now,
|
||||
etadata = etadata,
|
||||
modelsindex = modelsindex,
|
||||
data = data,
|
||||
is_eta=is_eta,
|
||||
)
|
||||
# ex_Model(df,
|
||||
# horizon=horizon,
|
||||
# input_size=input_size,
|
||||
# train_steps=train_steps,
|
||||
# val_check_steps=val_check_steps,
|
||||
# early_stop_patience_steps=early_stop_patience_steps,
|
||||
# is_debug=is_debug,
|
||||
# dataset=dataset,
|
||||
# is_train=is_train,
|
||||
# is_fivemodels=is_fivemodels,
|
||||
# val_size=val_size,
|
||||
# test_size=test_size,
|
||||
# settings=settings,
|
||||
# now=now,
|
||||
# etadata = etadata,
|
||||
# modelsindex = modelsindex,
|
||||
# data = data,
|
||||
# is_eta=is_eta,
|
||||
# )
|
||||
|
||||
|
||||
logger.info('模型训练完成')
|
||||
|
@ -534,58 +534,79 @@ def model_losss_juxiting(sqlitedb):
|
||||
with open(os.path.join(dataset,"best_modelnames.txt"), 'w') as f:
|
||||
f.write(','.join(modelnames) + '\n')
|
||||
|
||||
|
||||
# 根据真实值y确定最大最小值,去掉最高最低的预测值
|
||||
import heapq # 使用堆来找到最大和最小的值
|
||||
|
||||
# 根据最接近真实值的预测模型计算波动率,得到在波动率范围内的预测值确定通道边界
|
||||
|
||||
best_models = pd.read_csv(os.path.join(dataset,'best_modelnames.txt'),header=None).values.flatten().tolist()
|
||||
def find_min_max_within_quantile(row):
|
||||
true_value = row['y']
|
||||
row.drop(['ds','y'], inplace=True)
|
||||
row = row.astype(float).round(2)
|
||||
|
||||
max_heap = []
|
||||
min_heap = []
|
||||
for col in row.index:
|
||||
# 对比真实值进行分类
|
||||
if row[col] < true_value:
|
||||
heapq.heappush(min_heap, row[col])
|
||||
elif row[col] > true_value:
|
||||
heapq.heappush(max_heap, -row[col]) # 使用负号来实现最大堆
|
||||
|
||||
if len(max_heap) == 1:
|
||||
max_y = max_heap[0]
|
||||
elif len(max_heap) == 0:
|
||||
max_y = -min_heap[-1]
|
||||
else:
|
||||
max_y = heapq.nsmallest(2, max_heap)[1]
|
||||
|
||||
if len(min_heap) < 2 :
|
||||
min_y = -max_heap[-1]
|
||||
else:
|
||||
min_y = heapq.nsmallest(2, min_heap)[-1]
|
||||
|
||||
|
||||
# 获取最大和最小的值
|
||||
q10 = min_y
|
||||
q90 = -max_y
|
||||
|
||||
# 获取最大和最小的模型名称
|
||||
row = row[best_models]
|
||||
q10 = row.min()
|
||||
q90 = row.max()
|
||||
# 获取 row行最大最小值模型名称
|
||||
min_model = row[row == q10].idxmin()
|
||||
max_model = row[row == q90].idxmax()
|
||||
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'])
|
||||
|
||||
# 设置上下界比例
|
||||
rote = 1
|
||||
|
||||
q10 = q10 * rote
|
||||
q90 = q90 * rote
|
||||
|
||||
logger.info(min_model,q10,max_model,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)
|
||||
|
||||
|
||||
# # 根据真实值y确定最大最小值,去掉最高最低的预测值
|
||||
# import heapq # 使用堆来找到最大和最小的值
|
||||
# def find_min_max_within_quantile(row):
|
||||
# true_value = row['y']
|
||||
# row.drop(['ds','y'], inplace=True)
|
||||
# row = row.astype(float).round(2)
|
||||
|
||||
# max_heap = []
|
||||
# min_heap = []
|
||||
# for col in row.index:
|
||||
# # 对比真实值进行分类
|
||||
# if row[col] < true_value:
|
||||
# heapq.heappush(min_heap, row[col])
|
||||
# elif row[col] > true_value:
|
||||
# heapq.heappush(max_heap, -row[col]) # 使用负号来实现最大堆
|
||||
|
||||
# if len(max_heap) == 1:
|
||||
# max_y = max_heap[0]
|
||||
# elif len(max_heap) == 0:
|
||||
# max_y = -min_heap[-1]
|
||||
# else:
|
||||
# max_y = heapq.nsmallest(2, max_heap)[1]
|
||||
|
||||
# if len(min_heap) < 2 :
|
||||
# min_y = -max_heap[-1]
|
||||
# else:
|
||||
# min_y = heapq.nsmallest(2, min_heap)[-1]
|
||||
|
||||
|
||||
# # 获取最大和最小的值
|
||||
# q10 = min_y
|
||||
# q90 = -max_y
|
||||
|
||||
# # 获取最大和最小的模型名称
|
||||
# min_model = row[row == q10].idxmin()
|
||||
# max_model = row[row == q90].idxmax()
|
||||
|
||||
# # 设置上下界比例
|
||||
# rote = 1
|
||||
|
||||
# q10 = q10 * rote
|
||||
# q90 = q90 * rote
|
||||
|
||||
# logger.info(min_model,q10,max_model,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)
|
||||
|
||||
# 使用最佳五个模型进行绘图
|
||||
# best_models = pd.read_csv(os.path.join(dataset,'best_modelnames.txt'),header=None).values.flatten().tolist()
|
||||
# def find_min_max_within_quantile(row):
|
||||
|