From 26dd6a7a0787be7dcb15e358f25d892123180270 Mon Sep 17 00:00:00 2001 From: liurui Date: Tue, 3 Dec 2024 17:04:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=A2=84=E6=B5=8B=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E4=B8=BA=20Brent=E8=BF=9E1=E5=90=88=E7=BA=A6=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_jingbo.py | 12 ++++++------ main_yuanyou.py | 4 ++-- models/nerulforcastmodels.py | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/config_jingbo.py b/config_jingbo.py index cd65552..ba24fac 100644 --- a/config_jingbo.py +++ b/config_jingbo.py @@ -198,7 +198,7 @@ warning_data = { ### 开关 is_train = True # 是否训练 is_debug = False # 是否调试 -is_eta = False # 是否使用eta接口 +is_eta = True # 是否使用eta接口 is_timefurture = True # 是否使用时间特征 is_fivemodels = False # 是否使用之前保存的最佳的5个模型 is_edbcode = True # 特征使用edbcoding列表中的 @@ -224,7 +224,7 @@ db_mysql.connect() # 数据截取日期 -start_year = 2013 # 数据开始年份 +start_year = 2000 # 数据开始年份 end_time = '' # 数据截取日期 freq = 'B' # 时间频率,"D": 天 "W": 周"M": 月"Q": 季度"A": 年 "H": 小时 "T": 分钟 "S": 秒 "B": 工作日 delweekenday = True if freq == 'B' else False # 是否删除周末数据 @@ -233,15 +233,15 @@ add_kdj = False # 是否添加kdj指标 if add_kdj and is_edbnamelist: edbnamelist = edbnamelist+['K','D','J'] ### 模型参数 -y = 'Brent活跃合约' # 原油指标数据的目标变量 +y = 'Brent连1合约价格' # 原油指标数据的目标变量 Brent连1合约价格 Brent活跃合约 # y = '期货结算价(连续):布伦特原油:前一个观测值' # ineoil的目标变量 -horizon =5 # 预测的步长 -input_size = 40 # 输入序列长度 +horizon =20 # 预测的步长 +input_size = 120 # 输入序列长度 train_steps = 50 if is_debug else 1000 # 训练步数,用来限定epoch次数 val_check_steps = 30 # 评估频率 early_stop_patience_steps = 5 # 早停的耐心步数 # --- 交叉验证用的参数 -test_size = 200 # 测试集大小,定义100,后面使用的时候重新赋值 +test_size = 100 # 测试集大小,定义100,后面使用的时候重新赋值 val_size = test_size # 验证集大小,同测试集大小 ### 特征筛选用到的参数 diff --git a/main_yuanyou.py b/main_yuanyou.py index 83f9255..ede05ca 100644 --- a/main_yuanyou.py +++ b/main_yuanyou.py @@ -1,7 +1,7 @@ # 读取配置 from config_jingbo import * from lib.dataread import * -# from lib.tools import * +from lib.tools import SendMail from models.nerulforcastmodels import ex_Model,model_losss,model_losss_juxiting,brent_export_pdf,tansuanli_export_pdf,pp_export_pdf,model_losss_juxiting import glob @@ -227,7 +227,7 @@ def predict_main(): file=max(glob.glob(os.path.join(dataset,'*.pdf')), key=os.path.getctime), ssl=ssl, ) - # m.send_mail() + m.send_mail() if __name__ == '__main__': diff --git a/models/nerulforcastmodels.py b/models/nerulforcastmodels.py index fdcfb61..c3ebc46 100644 --- a/models/nerulforcastmodels.py +++ b/models/nerulforcastmodels.py @@ -366,8 +366,9 @@ def model_losss(sqlitedb): continue sqlitedb.insert_data('trueandpredict',tuple(row_dict.values()),columns=columns) # 最多频率的模型名称 - min_model_max_frequency_model = df_combined3['min_model'][-60:].value_counts().idxmax() - max_model_max_frequency_model = df_combined3['max_model'][-60:].value_counts().idxmax() + num = df_combined3.shape[0] if df_combined3.shape[0] < 60 else 60 + min_model_max_frequency_model = df_combined3['min_model'][-num:].value_counts().idxmax() + max_model_max_frequency_model = df_combined3['max_model'][-num:].value_counts().idxmax() df_predict['min_model'] = min_model_max_frequency_model df_predict['max_model'] = max_model_max_frequency_model df_predict['min_within_quantile'] = df_predict[min_model_max_frequency_model]