diff --git a/ETA获取数据.py b/ETA获取数据.py index b6aaa66..4ae8f78 100644 --- a/ETA获取数据.py +++ b/ETA获取数据.py @@ -706,8 +706,36 @@ edbcodelist = ['CO1 Comdty', 'ovx index', 'C2404194834', 'C2404199738', 'dxy cur # 'S5131019','ID00135604','FSGAM1 Index','S5120408','ID00136724', # 新加坡汽柴油 ] + +# 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' + } + +edbcodelist = edbcodelist+list(modelsindex.values()) + ### 文件 -data_set = '原油指标数据.xlsx' # 数据集文件 +data_set = '历史预测结果.xlsx' # 数据集文件 # data_set = 'INE_OIL(1).csv' ### 文件夹 dataset = 'yuanyoudataset' # 数据集文件夹 diff --git a/config_jingbo.py b/config_jingbo.py index d96483f..bacd157 100644 --- a/config_jingbo.py +++ b/config_jingbo.py @@ -90,54 +90,86 @@ data = { ClassifyId = 1214 -### 报告上传配置 -# 变量定义--线上环境 -# login_pushreport_url = "http://10.200.32.39/jingbo-api/api/server/login" -# upload_url = "http://10.200.32.39/jingbo-api/api/analysis/reportInfo/researchUploadReportSave" -# upload_warning_url = "http://10.200.32.39/jingbo-api/api/basicBuiness/crudeOilWarning/save" +################################################################################################################ 变量定义--线上环境 +login_pushreport_url = "http://10.200.32.39/jingbo-api/api/server/login" +upload_url = "http://10.200.32.39/jingbo-api/api/analysis/reportInfo/researchUploadReportSave" +upload_warning_url = "http://10.200.32.39/jingbo-api/api/basicBuiness/crudeOilWarning/save" -# login_data = { -# "data": { -# "account": "api_dev", -# "password": "ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=", -# "tenantHashCode": "8a4577dbd919675758d57999a1e891fe", -# "terminal": "API" -# }, -# "funcModule": "API", -# "funcOperation": "获取token" -# } +login_data = { + "data": { + "account": "api_dev", + "password": "ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=", + "tenantHashCode": "8a4577dbd919675758d57999a1e891fe", + "terminal": "API" + }, + "funcModule": "API", + "funcOperation": "获取token" +} -# upload_data = { -# "funcModule":'研究报告信息', -# "funcOperation":'上传原油价格预测报告', -# "data":{ -# "ownerAccount":'27663', #报告所属用户账号 27663 - 刘小朋 -# "reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST -# "fileName": '', #文件名称 -# "fileBase64": '' ,#文件内容base64 -# "categoryNo":'yyjgycbg', # 研究报告分类编码 -# "smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码 -# "reportEmployeeCode":"E40482" ,# 报告人 E40482 - 管理员 0000027663 - 刘小朋 -# "reportDeptCode" :"002000621000", # 报告部门 - 002000621000 SH期货研究部 -# "productGroupCode":"RAW_MATERIAL" # 商品分类 -# } -# } +upload_data = { + "funcModule":'研究报告信息', + "funcOperation":'上传原油价格预测报告', + "data":{ + "ownerAccount":'27663', #报告所属用户账号 27663 - 刘小朋 + "reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST + "fileName": '', #文件名称 + "fileBase64": '' ,#文件内容base64 + "categoryNo":'yyjgycbg', # 研究报告分类编码 + "smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码 + "reportEmployeeCode":"E40482" ,# 报告人 E40482 - 管理员 0000027663 - 刘小朋 + "reportDeptCode" :"002000621000", # 报告部门 - 002000621000 SH期货研究部 + "productGroupCode":"RAW_MATERIAL" # 商品分类 + } +} -# warning_data = { -# "funcModule":'原油特征停更预警', -# "funcOperation":'原油特征停更预警', -# "data":{ -# 'WARNING_TYPE_NAME':'特征数据停更预警', -# 'WARNING_CONTENT':'', -# 'WARNING_DATE':'' -# } -# } +warning_data = { + "funcModule":'原油特征停更预警', + "funcOperation":'原油特征停更预警', + "data":{ + 'WARNING_TYPE_NAME':'特征数据停更预警', + 'WARNING_CONTENT':'', + 'WARNING_DATE':'' + } +} + +# 生产环境数据库 +# url: jdbc:mysql://rm-2zehj3r1n60ttz9x5.mysql.rds.aliyuncs.com:3306/jingbo?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true +# username: jingbo +# password: shihua@123 +# table-schema: jingbo +# host = 'rm-2zehj3r1n60ttz9x5.mysql.rds.aliyuncs.com' +# port = 3306 +# dbusername ='jingbo' +# password = 'shihua@123' +# dbname = 'jingbo' +# table_name = 'v_tbl_crude_oil_warning' + +# 预生产环境 +# host = 'rm-2zehj3r1n60ttz9x5ko.mysql.rds.aliyuncs.com' +# port = 3306 +# dbusername ='jingbo' +# password = 'shihua@123' +# dbname = 'jingbo-test' +# table_name = 'v_tbl_crude_oil_warning' -# # 变量定义--测试环境 +### 线上开关 +# is_train = True # 是否训练 +# is_debug = False # 是否调试 +# is_eta = True # 是否使用eta接口 +# is_timefurture = True # 是否使用时间特征 +# is_fivemodels = False # 是否使用之前保存的最佳的5个模型 +# is_edbcode = False # 特征使用edbcoding列表中的 +# is_edbnamelist = False # 自定义特征,对应上面的edbnamelist +# is_update_eta = True # 预测结果上传到eta +# is_update_report = True # 是否上传报告 +# is_update_warning_data = True if datetime.datetime.now().weekday() == 1 else False # 是否上传预警数据 + + +################################################################################################################ 变量定义--测试环境 login_pushreport_url = "http://192.168.100.53:8080/jingbo-dev/api/server/login" upload_url = "http://192.168.100.53:8080/jingbo-dev/api/analysis/reportInfo/researchUploadReportSave" # upload_url = "http://192.168.100.109:8080/jingbo/api/analysis/reportInfo/researchUploadReportSave" # zhaoqiwei @@ -182,17 +214,13 @@ warning_data = { } } -### 线上开关 -# is_train = True # 是否训练 -# is_debug = False # 是否调试 -# is_eta = True # 是否使用eta接口 -# is_timefurture = True # 是否使用时间特征 -# is_fivemodels = False # 是否使用之前保存的最佳的5个模型 -# is_edbcode = False # 特征使用edbcoding列表中的 -# is_edbnamelist = False # 自定义特征,对应上面的edbnamelist -# is_update_eta = True # 预测结果上传到eta -# is_update_report = True # 是否上传报告 -# is_update_warning_data = True if datetime.datetime.now().weekday() == 1 else False # 是否上传预警数据 +# 北京环境数据库 +host = '192.168.101.27' +port = 3306 +dbusername ='root' +password = '123456' +dbname = 'jingbo_test' +table_name = 'v_tbl_crude_oil_warning' ### 开关 @@ -204,28 +232,19 @@ is_fivemodels = False # 是否使用之前保存的最佳的5个模型 is_edbcode = False # 特征使用edbcoding列表中的 is_edbnamelist = False # 自定义特征,对应上面的edbnamelist is_update_eta = False # 预测结果上传到eta -is_update_report = False # 是否上传报告 -is_update_warning_data = False # 是否上传预警数据 +is_update_report = True # 是否上传报告 +is_update_warning_data = True # 是否上传预警数据 -### 北京环境数据库jbsh_test -# url: jdbc:mysql://192.168.101.27:3306/jingbo_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true - -host = '192.168.101.27' -port = 3306 -dbusername ='root' -password = '123456' -dbname = 'jingbo_test' -table_name = 'v_tbl_crude_oil_warning' - -db_mysql = MySQLDB(host=host, user=dbusername, password=password, database=dbname) # 连接到数据库 +db_mysql = MySQLDB(host=host, user=dbusername, password=password, database=dbname) db_mysql.connect() +print("数据库连接成功",host,dbname,dbusername) # 数据截取日期 -start_year = 2000 # 数据开始年份 -end_time = '2024-11-23' # 数据截取日期 +start_year = 2018 # 数据开始年份 +end_time = '' # 数据截取日期 freq = 'B' # 时间频率,"D": 天 "W": 周"M": 月"Q": 季度"A": 年 "H": 小时 "T": 分钟 "S": 秒 "B": 工作日 delweekenday = True if freq == 'B' else False # 是否删除周末数据 is_corr = False # 特征是否参与滞后领先提升相关系数 diff --git a/lib/dataread.py b/lib/dataread.py index f4a19e6..09b4e59 100644 --- a/lib/dataread.py +++ b/lib/dataread.py @@ -259,7 +259,7 @@ def upload_warning_info(df_count): # 更新预警数据中的日期和内容 warning_data['data']['WARNING_DATE'] = warning_date - warning_data['data']['WARNING_CONTENT'] = content + '2' + warning_data['data']['WARNING_CONTENT'] = content # 调用 upload_warning_data 函数上传预警数据 upload_warning_data(warning_data) diff --git a/main_yuanyou.py b/main_yuanyou.py index 4494307..d957d81 100644 --- a/main_yuanyou.py +++ b/main_yuanyou.py @@ -109,37 +109,38 @@ def predict_main(): import datetime # 判断当前日期是不是周一 is_weekday = datetime.datetime.now().weekday() == 0 - # if is_weekday: - # logger.info('今天是周一,更新预测模型') - # # 计算最近60天预测残差最低的模型名称 - # model_results = sqlitedb.select_data('trueandpredict', order_by="ds DESC", limit="60") - # # 删除空值率为40%以上的列 - # if len(model_results) > 10: - # model_results = model_results.dropna(thresh=len(model_results)*0.6,axis=1) - # # 删除空行 - # model_results = model_results.dropna() - # modelnames = model_results.columns.to_list()[2:] - # for col in model_results[modelnames].select_dtypes(include=['object']).columns: - # model_results[col] = model_results[col].astype(np.float32) - # # 计算每个预测值与真实值之间的偏差率 - # for model in modelnames: - # model_results[f'{model}_abs_error_rate'] = abs(model_results['y'] - model_results[model]) / model_results['y'] - # # 获取每行对应的最小偏差率值 - # min_abs_error_rate_values = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].min(), axis=1) - # # 获取每行对应的最小偏差率值对应的列名 - # min_abs_error_rate_column_name = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].idxmin(), axis=1) - # # 将列名索引转换为列名 - # min_abs_error_rate_column_name = min_abs_error_rate_column_name.map(lambda x: x.split('_')[0]) - # # 取出现次数最多的模型名称 - # most_common_model = min_abs_error_rate_column_name.value_counts().idxmax() - # logger.info(f"最近60天预测残差最低的模型名称:{most_common_model}") - # # 保存结果到数据库 - # if not sqlitedb.check_table_exists('most_model'): - # sqlitedb.create_table('most_model', columns="ds datetime, most_common_model TEXT") - # sqlitedb.insert_data('most_model', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), most_common_model,), columns=('ds', 'most_common_model',)) + if is_weekday: + logger.info('今天是周一,更新预测模型') + # 计算最近60天预测残差最低的模型名称 + model_results = sqlitedb.select_data('trueandpredict', order_by="ds DESC", limit="60") + # 删除空值率为40%以上的列 + if len(model_results) > 10: + model_results = model_results.dropna(thresh=len(model_results)*0.6,axis=1) + # 删除空行 + model_results = model_results.dropna() + modelnames = model_results.columns.to_list()[2:] + for col in model_results[modelnames].select_dtypes(include=['object']).columns: + model_results[col] = model_results[col].astype(np.float32) + # 计算每个预测值与真实值之间的偏差率 + for model in modelnames: + model_results[f'{model}_abs_error_rate'] = abs(model_results['y'] - model_results[model]) / model_results['y'] + # 获取每行对应的最小偏差率值 + min_abs_error_rate_values = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].min(), axis=1) + # 获取每行对应的最小偏差率值对应的列名 + min_abs_error_rate_column_name = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].idxmin(), axis=1) + # 将列名索引转换为列名 + min_abs_error_rate_column_name = min_abs_error_rate_column_name.map(lambda x: x.split('_')[0]) + # 取出现次数最多的模型名称 + most_common_model = min_abs_error_rate_column_name.value_counts().idxmax() + logger.info(f"最近60天预测残差最低的模型名称:{most_common_model}") + # 保存结果到数据库 + if not sqlitedb.check_table_exists('most_model'): + sqlitedb.create_table('most_model', columns="ds datetime, most_common_model TEXT") + sqlitedb.insert_data('most_model', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), most_common_model,), columns=('ds', 'most_common_model',)) try: - if is_weekday: + # if is_weekday: + if True: logger.info('今天是周一,发送特征预警') # 上传预警信息到数据库 warning_data_df = df_zhibiaoliebiao.copy() @@ -147,6 +148,11 @@ def predict_main(): # 重命名列名 warning_data_df = warning_data_df.rename(columns={'指标名称': 'INDICATOR_NAME', '指标id': 'INDICATOR_ID', '频度': 'FREQUENCY', '更新周期': 'UPDATE_FREQUENCY', '指标来源': 'DATA_SOURCE', '最后更新时间': 'LAST_UPDATE_DATE', '停更周期': 'UPDATE_SUSPENSION_CYCLE'}) from sqlalchemy import create_engine + import urllib + global password + if '@' in password: + password = urllib.parse.quote_plus(password) + engine = create_engine(f'mysql+pymysql://{dbusername}:{password}@{host}:{port}/{dbname}') warning_data_df['WARNING_DATE'] = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S") warning_data_df['TENANT_CODE'] = 'T0004' diff --git a/up_week_dates.csv b/up_week_dates.csv index 6782268..2bb7d4e 100644 --- a/up_week_dates.csv +++ b/up_week_dates.csv @@ -1,16 +1,16 @@ ds,ACCURACY,PREDICT_DATE,CREAT_DATE,HIGH_PRICE_y,LOW_PRICE_y,MIN_PRICE,MAX_PRICE,Ds_Week,Pre_Week -2024-12-02,0.0,2024-12-02,2024-11-29,72.89,71.52,81.17999,81.17999,48,48 -2024-12-03,0.0,2024-12-03,2024-11-29,73.93,71.68,80.79155,80.79155,48,48 -2024-12-04,0.0,2024-12-04,2024-11-29,74.28,72.25,80.650894,80.650894,48,48 -2024-12-05,0.0,2024-12-05,2024-11-29,72.92,71.8,80.298,80.298,48,48 -2024-12-06,0.0,2024-12-06,2024-11-29,72.19,70.85,75.50838,80.264275,48,48 -2024-12-03,1.0,2024-12-03,2024-12-02,73.93,71.68,69.80779,75.83719,48,48 -2024-12-04,1.0,2024-12-04,2024-12-02,74.28,72.25,71.281296,76.24051,48,48 -2024-12-05,1.0,2024-12-05,2024-12-02,72.92,71.8,70.52623,75.95541,48,48 -2024-12-06,1.0,2024-12-06,2024-12-02,72.19,70.85,70.71932,75.99768,48,48 -2024-12-04,0.9432068965517233,2024-12-04,2024-12-03,74.28,72.25,72.36529,75.89061,48,48 -2024-12-05,0.6439196428571465,2024-12-05,2024-12-03,72.92,71.8,72.19881,75.72962,48,48 -2024-12-06,0.04017164179103775,2024-12-06,2024-12-03,72.19,70.85,72.13617,75.97762,48,48 -2024-12-05,0.0,2024-12-05,2024-12-04,72.92,71.8,82.40537,82.40537,48,48 -2024-12-06,0.0,2024-12-06,2024-12-04,72.19,70.85,82.0727,82.0727,48,48 -2024-12-06,0.0,2024-12-06,2024-12-05,72.19,70.85,83.367485,83.367485,48,48 +2024-11-26,1.0,2024-11-26,2024-11-25,73.8,71.63,71.071556,76.0069,47,47 +2024-11-27,1.0,2024-11-27,2024-11-25,72.85,71.71,71.003624,75.58056,47,47 +2024-11-28,0.7893243243243208,2024-11-28,2024-11-25,72.96,71.85,72.08385,76.20426,47,47 +2024-11-29,1.0,2024-11-29,2024-11-25,73.34,71.75,71.32973,75.70395,47,47 +2024-11-27,0.6068728070175414,2024-11-27,2024-11-26,72.85,71.71,72.158165,76.17365,47,47 +2024-11-28,0.8021441441441385,2024-11-28,2024-11-26,72.96,71.85,72.06962,76.447,47,47 +2024-11-29,0.6082389937106918,2024-11-29,2024-11-26,73.34,71.75,72.3729,76.08291,47,47 +2024-11-28,1.0,2024-11-28,2024-11-27,72.96,71.85,70.70975,75.20803,47,47 +2024-11-29,1.0,2024-11-29,2024-11-27,73.34,71.75,69.92311,75.423775,47,47 +2024-11-29,1.0,2024-11-29,2024-11-28,73.34,71.75,70.43276,75.48062,47,47 +2024-11-25,0.11832806324110515,2024-11-25,2024-11-22,74.83,72.3,74.53063,76.67314,47,47 +2024-11-26,0.0,2024-11-26,2024-11-22,73.8,71.63,74.44043,76.874565,47,47 +2024-11-27,0.0,2024-11-27,2024-11-22,72.85,71.71,74.66318,76.73413,47,47 +2024-11-28,0.0,2024-11-28,2024-11-22,72.96,71.85,74.70841,77.14105,47,47 +2024-11-29,0.0,2024-11-29,2024-11-22,73.34,71.75,74.70321,77.74617,47,47 diff --git a/原油价格预测准确率计算.ipynb b/原油价格预测准确率计算.ipynb index 3d6a783..6bace69 100644 --- a/原油价格预测准确率计算.ipynb +++ b/原油价格预测准确率计算.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 130, + "execution_count": 136, "id": "9daadf20-caa6-4b25-901c-6cc3ef563f58", "metadata": {}, "outputs": [ @@ -10,9 +10,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "(50, 9)\n", + "(75, 9)\n", "(20, 4)\n", - "(50, 12)\n", + "(75, 12)\n", " id PREDICT_DATE CREAT_DATE MIN_PRICE MAX_PRICE HIGH_PRICE_x LOW_PRICE_x \\\n", "0 1 2024-11-26 2024-11-25 71.071556 76.006900 \n", "1 2 2024-11-27 2024-11-25 71.003624 75.580560 \n", @@ -27,18 +27,18 @@ "3 2024-11-29 6.0 71.75 73.34 \n", "4 2024-12-02 5.0 71.52 72.89 \n", " id PREDICT_DATE CREAT_DATE MIN_PRICE MAX_PRICE HIGH_PRICE_x \\\n", - "45 46 2024-12-09 2024-12-06 68.894770 73.909450 \n", - "46 47 2024-12-10 2024-12-06 68.845604 73.921120 \n", - "47 48 2024-12-11 2024-12-06 69.181210 73.906260 \n", - "48 49 2024-12-12 2024-12-06 69.075340 73.862946 \n", - "49 50 2024-12-13 2024-12-06 69.076550 74.007740 \n", + "70 71 2024-11-25 2024-11-22 74.53063 76.673140 \n", + "71 72 2024-11-26 2024-11-22 74.44043 76.874565 \n", + "72 73 2024-11-27 2024-11-22 74.66318 76.734130 \n", + "73 74 2024-11-28 2024-11-22 74.70841 77.141050 \n", + "74 75 2024-11-29 2024-11-22 74.70321 77.746170 \n", "\n", - " LOW_PRICE_x RIGHT_ROTE ds 序号 LOW_PRICE_y HIGH_PRICE_y \n", - "45 2024-12-09 NaN NaN NaN \n", - "46 2024-12-10 NaN NaN NaN \n", - "47 2024-12-11 NaN NaN NaN \n", - "48 2024-12-12 NaN NaN NaN \n", - "49 2024-12-13 NaN NaN NaN \n" + " LOW_PRICE_x RIGHT_ROTE ds 序号 LOW_PRICE_y HIGH_PRICE_y \n", + "70 2024-11-25 10.0 72.30 74.83 \n", + "71 2024-11-26 9.0 71.63 73.80 \n", + "72 2024-11-27 8.0 71.71 72.85 \n", + "73 2024-11-28 7.0 71.85 72.96 \n", + "74 2024-11-29 6.0 71.75 73.34 \n" ] } ], @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 131, + "execution_count": 137, "id": "e51c3fd0-6bff-45de-b8b6-971e7986c7a7", "metadata": {}, "outputs": [ @@ -101,51 +101,14 @@ "2 2024-11-28 0.789324 72.96 71.85 72.083850 76.204260\n", "3 2024-11-29 1.000000 73.34 71.75 71.329730 75.703950\n", "4 2024-12-02 0.853412 72.89 71.52 71.720825 76.264275\n", - "5 2024-11-27 0.606873 72.85 71.71 72.158165 76.173650\n", - "6 2024-11-28 0.802144 72.96 71.85 72.069620 76.447000\n", - "7 2024-11-29 0.608239 73.34 71.75 72.372900 76.082910\n", - "8 2024-12-02 0.457007 72.89 71.52 72.263900 76.198685\n", - "9 2024-12-03 0.758302 73.93 71.68 72.223820 76.041725\n", - "10 2024-11-28 1.000000 72.96 71.85 70.709750 75.208030\n", - "11 2024-11-29 1.000000 73.34 71.75 69.923110 75.423775\n", - "12 2024-12-02 1.000000 72.89 71.52 70.810356 75.786860\n", - "13 2024-12-03 1.000000 73.93 71.68 70.814430 75.791115\n", - "14 2024-12-04 1.000000 74.28 72.25 70.476650 75.623730\n", - "15 2024-11-29 1.000000 73.34 71.75 70.432760 75.480620\n", - "16 2024-12-02 1.000000 72.89 71.52 69.651825 75.270940\n", - "17 2024-12-03 1.000000 73.93 71.68 70.536285 75.826430\n", - "18 2024-12-04 1.000000 74.28 72.25 70.568340 75.770290\n", - "19 2024-12-05 1.000000 72.92 71.80 70.222640 76.113310\n", - "20 2024-12-02 0.000000 72.89 71.52 81.179990 81.179990\n", - "21 2024-12-03 0.000000 73.93 71.68 80.791550 80.791550\n", - "22 2024-12-04 0.000000 74.28 72.25 80.650894 80.650894\n", - "23 2024-12-05 0.000000 72.92 71.80 80.298000 80.298000\n", - "24 2024-12-06 0.000000 72.19 70.85 75.508380 80.264275\n", - "25 2024-12-03 1.000000 73.93 71.68 69.807790 75.837190\n", - "26 2024-12-04 1.000000 74.28 72.25 71.281296 76.240510\n", - "27 2024-12-05 1.000000 72.92 71.80 70.526230 75.955410\n", - "28 2024-12-06 1.000000 72.19 70.85 70.719320 75.997680\n", - "29 2024-12-09 0.000000 NaN NaN 71.642590 75.828636\n", - "30 2024-12-04 0.943207 74.28 72.25 72.365290 75.890610\n", - "31 2024-12-05 0.643920 72.92 71.80 72.198810 75.729620\n", - "32 2024-12-06 0.040172 72.19 70.85 72.136170 75.977620\n", - "33 2024-12-09 0.000000 NaN NaN 72.165790 75.880104\n", - "34 2024-12-10 0.000000 NaN NaN 72.000620 75.906100\n", - "35 2024-12-05 0.000000 72.92 71.80 82.405370 82.405370\n", - "36 2024-12-06 0.000000 72.19 70.85 82.072700 82.072700\n", - "37 2024-12-09 0.000000 NaN NaN 82.652700 82.652700\n", - "38 2024-12-10 0.000000 NaN NaN 81.920910 81.920910\n", - "39 2024-12-11 0.000000 NaN NaN 81.091270 81.091270\n", - "40 2024-12-06 0.000000 72.19 70.85 83.367485 83.367485\n", - "41 2024-12-09 0.000000 NaN NaN 82.869705 82.869705\n", - "42 2024-12-10 0.000000 NaN NaN 82.580550 82.580550\n", - "43 2024-12-11 0.000000 NaN NaN 82.442154 82.442154\n", - "44 2024-12-12 0.000000 NaN NaN 82.276510 82.276510\n", - "45 2024-12-09 0.000000 NaN NaN 68.894770 73.909450\n", - "46 2024-12-10 0.000000 NaN NaN 68.845604 73.921120\n", - "47 2024-12-11 0.000000 NaN NaN 69.181210 73.906260\n", - "48 2024-12-12 0.000000 NaN NaN 69.075340 73.862946\n", - "49 2024-12-13 0.000000 NaN NaN 69.076550 74.007740\n" + ".. ... ... ... ... ... ...\n", + "70 2024-11-25 0.118328 74.83 72.30 74.530630 76.673140\n", + "71 2024-11-26 0.000000 73.80 71.63 74.440430 76.874565\n", + "72 2024-11-27 0.000000 72.85 71.71 74.663180 76.734130\n", + "73 2024-11-28 0.000000 72.96 71.85 74.708410 77.141050\n", + "74 2024-11-29 0.000000 73.34 71.75 74.703210 77.746170\n", + "\n", + "[75 rows x 6 columns]\n" ] } ], @@ -176,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": 138, "id": "0f942c69", "metadata": {}, "outputs": [], @@ -189,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 133, + "execution_count": 139, "id": "a7b05510", "metadata": {}, "outputs": [ @@ -293,592 +256,86 @@ "
75 rows × 10 columns
\n", "" ], "text/plain": [ @@ -888,51 +345,12 @@ "2 2024-11-28 0.789324 2024-11-28 2024-11-25 72.96 71.85 \n", "3 2024-11-29 1.000000 2024-11-29 2024-11-25 73.34 71.75 \n", "4 2024-12-02 0.853412 2024-12-02 2024-11-25 72.89 71.52 \n", - "5 2024-11-27 0.606873 2024-11-27 2024-11-26 72.85 71.71 \n", - "6 2024-11-28 0.802144 2024-11-28 2024-11-26 72.96 71.85 \n", - "7 2024-11-29 0.608239 2024-11-29 2024-11-26 73.34 71.75 \n", - "8 2024-12-02 0.457007 2024-12-02 2024-11-26 72.89 71.52 \n", - "9 2024-12-03 0.758302 2024-12-03 2024-11-26 73.93 71.68 \n", - "10 2024-11-28 1.000000 2024-11-28 2024-11-27 72.96 71.85 \n", - "11 2024-11-29 1.000000 2024-11-29 2024-11-27 73.34 71.75 \n", - "12 2024-12-02 1.000000 2024-12-02 2024-11-27 72.89 71.52 \n", - "13 2024-12-03 1.000000 2024-12-03 2024-11-27 73.93 71.68 \n", - "14 2024-12-04 1.000000 2024-12-04 2024-11-27 74.28 72.25 \n", - "15 2024-11-29 1.000000 2024-11-29 2024-11-28 73.34 71.75 \n", - "16 2024-12-02 1.000000 2024-12-02 2024-11-28 72.89 71.52 \n", - "17 2024-12-03 1.000000 2024-12-03 2024-11-28 73.93 71.68 \n", - "18 2024-12-04 1.000000 2024-12-04 2024-11-28 74.28 72.25 \n", - "19 2024-12-05 1.000000 2024-12-05 2024-11-28 72.92 71.80 \n", - "20 2024-12-02 0.000000 2024-12-02 2024-11-29 72.89 71.52 \n", - "21 2024-12-03 0.000000 2024-12-03 2024-11-29 73.93 71.68 \n", - "22 2024-12-04 0.000000 2024-12-04 2024-11-29 74.28 72.25 \n", - "23 2024-12-05 0.000000 2024-12-05 2024-11-29 72.92 71.80 \n", - "24 2024-12-06 0.000000 2024-12-06 2024-11-29 72.19 70.85 \n", - "25 2024-12-03 1.000000 2024-12-03 2024-12-02 73.93 71.68 \n", - "26 2024-12-04 1.000000 2024-12-04 2024-12-02 74.28 72.25 \n", - "27 2024-12-05 1.000000 2024-12-05 2024-12-02 72.92 71.80 \n", - "28 2024-12-06 1.000000 2024-12-06 2024-12-02 72.19 70.85 \n", - "29 2024-12-09 0.000000 2024-12-09 2024-12-02 NaN NaN \n", - "30 2024-12-04 0.943207 2024-12-04 2024-12-03 74.28 72.25 \n", - "31 2024-12-05 0.643920 2024-12-05 2024-12-03 72.92 71.80 \n", - "32 2024-12-06 0.040172 2024-12-06 2024-12-03 72.19 70.85 \n", - "33 2024-12-09 0.000000 2024-12-09 2024-12-03 NaN NaN \n", - "34 2024-12-10 0.000000 2024-12-10 2024-12-03 NaN NaN \n", - "35 2024-12-05 0.000000 2024-12-05 2024-12-04 72.92 71.80 \n", - "36 2024-12-06 0.000000 2024-12-06 2024-12-04 72.19 70.85 \n", - "37 2024-12-09 0.000000 2024-12-09 2024-12-04 NaN NaN \n", - "38 2024-12-10 0.000000 2024-12-10 2024-12-04 NaN NaN \n", - "39 2024-12-11 0.000000 2024-12-11 2024-12-04 NaN NaN \n", - "40 2024-12-06 0.000000 2024-12-06 2024-12-05 72.19 70.85 \n", - "41 2024-12-09 0.000000 2024-12-09 2024-12-05 NaN NaN \n", - "42 2024-12-10 0.000000 2024-12-10 2024-12-05 NaN NaN \n", - "43 2024-12-11 0.000000 2024-12-11 2024-12-05 NaN NaN \n", - "44 2024-12-12 0.000000 2024-12-12 2024-12-05 NaN NaN \n", - "45 2024-12-09 0.000000 2024-12-09 2024-12-06 NaN NaN \n", - "46 2024-12-10 0.000000 2024-12-10 2024-12-06 NaN NaN \n", - "47 2024-12-11 0.000000 2024-12-11 2024-12-06 NaN NaN \n", - "48 2024-12-12 0.000000 2024-12-12 2024-12-06 NaN NaN \n", - "49 2024-12-13 0.000000 2024-12-13 2024-12-06 NaN NaN \n", + ".. ... ... ... ... ... ... \n", + "70 2024-11-25 0.118328 2024-11-25 2024-11-22 74.83 72.30 \n", + "71 2024-11-26 0.000000 2024-11-26 2024-11-22 73.80 71.63 \n", + "72 2024-11-27 0.000000 2024-11-27 2024-11-22 72.85 71.71 \n", + "73 2024-11-28 0.000000 2024-11-28 2024-11-22 72.96 71.85 \n", + "74 2024-11-29 0.000000 2024-11-29 2024-11-22 73.34 71.75 \n", "\n", " MIN_PRICE MAX_PRICE Ds_Week Pre_Week \n", "0 71.071556 76.006900 47 47 \n", @@ -940,54 +358,17 @@ "2 72.083850 76.204260 47 47 \n", "3 71.329730 75.703950 47 47 \n", "4 71.720825 76.264275 48 48 \n", - "5 72.158165 76.173650 47 47 \n", - "6 72.069620 76.447000 47 47 \n", - "7 72.372900 76.082910 47 47 \n", - "8 72.263900 76.198685 48 48 \n", - "9 72.223820 76.041725 48 48 \n", - "10 70.709750 75.208030 47 47 \n", - "11 69.923110 75.423775 47 47 \n", - "12 70.810356 75.786860 48 48 \n", - "13 70.814430 75.791115 48 48 \n", - "14 70.476650 75.623730 48 48 \n", - "15 70.432760 75.480620 47 47 \n", - "16 69.651825 75.270940 48 48 \n", - "17 70.536285 75.826430 48 48 \n", - "18 70.568340 75.770290 48 48 \n", - "19 70.222640 76.113310 48 48 \n", - "20 81.179990 81.179990 48 48 \n", - "21 80.791550 80.791550 48 48 \n", - "22 80.650894 80.650894 48 48 \n", - "23 80.298000 80.298000 48 48 \n", - "24 75.508380 80.264275 48 48 \n", - "25 69.807790 75.837190 48 48 \n", - "26 71.281296 76.240510 48 48 \n", - "27 70.526230 75.955410 48 48 \n", - "28 70.719320 75.997680 48 48 \n", - "29 71.642590 75.828636 49 49 \n", - "30 72.365290 75.890610 48 48 \n", - "31 72.198810 75.729620 48 48 \n", - "32 72.136170 75.977620 48 48 \n", - "33 72.165790 75.880104 49 49 \n", - "34 72.000620 75.906100 49 49 \n", - "35 82.405370 82.405370 48 48 \n", - "36 82.072700 82.072700 48 48 \n", - "37 82.652700 82.652700 49 49 \n", - "38 81.920910 81.920910 49 49 \n", - "39 81.091270 81.091270 49 49 \n", - "40 83.367485 83.367485 48 48 \n", - "41 82.869705 82.869705 49 49 \n", - "42 82.580550 82.580550 49 49 \n", - "43 82.442154 82.442154 49 49 \n", - "44 82.276510 82.276510 49 49 \n", - "45 68.894770 73.909450 49 49 \n", - "46 68.845604 73.921120 49 49 \n", - "47 69.181210 73.906260 49 49 \n", - "48 69.075340 73.862946 49 49 \n", - "49 69.076550 74.007740 49 49 " + ".. ... ... ... ... \n", + "70 74.530630 76.673140 47 47 \n", + "71 74.440430 76.874565 47 47 \n", + "72 74.663180 76.734130 47 47 \n", + "73 74.708410 77.141050 47 47 \n", + "74 74.703210 77.746170 47 47 \n", + "\n", + "[75 rows x 10 columns]" ] }, - "execution_count": 133, + "execution_count": 139, "metadata": {}, "output_type": "execute_result" } @@ -998,7 +379,7 @@ }, { "cell_type": "code", - "execution_count": 134, + "execution_count": 140, "id": "1374e354", "metadata": {}, "outputs": [ @@ -1006,14 +387,20 @@ "name": "stdout", "output_type": "stream", "text": [ - "['2024-11-29', '2024-11-30', '2024-12-01', '2024-12-02', '2024-12-03', '2024-12-04', '2024-12-05', '2024-12-06']\n", + "['2024-11-22', '2024-11-23', '2024-11-24', '2024-11-25', '2024-11-26', '2024-11-27', '2024-11-28', '2024-11-29']\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "(15, 10)\n" ] } ], "source": [ "# 取结束日期上一周的日期\n", - "endtime = '2024-12-9'\n", + "endtime = '2024-12-3'\n", "endtimeweek = datetime.datetime.strptime(endtime, '%Y-%m-%d')\n", "up_week = endtimeweek - datetime.timedelta(days=endtimeweek.weekday() + 14)\n", "up_week_dates = [up_week + datetime.timedelta(days=i) for i in range(14)][4:-2]\n", @@ -1030,7 +417,7 @@ }, { "cell_type": "code", - "execution_count": 135, + "execution_count": 141, "id": "8aa47e90", "metadata": {}, "outputs": [ @@ -1038,22 +425,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "2024-12-02 00:00:00\n", + "2024-11-25 00:00:00\n", "权重: 0.07\n", - "准确率: 0.0\n", - "2024-12-03 00:00:00\n", + "准确率: 1.7749209486165771\n", + "2024-11-26 00:00:00\n", "权重: 0.13\n", "准确率: 7.5\n", - "2024-12-04 00:00:00\n", + "2024-11-27 00:00:00\n", "权重: 0.2\n", - "准确率: 9.716034482758616\n", - "2024-12-05 00:00:00\n", + "准确率: 8.034364035087705\n", + "2024-11-28 00:00:00\n", "权重: 0.27\n", - "准确率: 6.1646986607143\n", - "2024-12-06 00:00:00\n", + "准确率: 9.718006756756724\n", + "2024-11-29 00:00:00\n", "权重: 0.33\n", - "准确率: 3.1205149253731137\n", - "26.50124806884603\n" + "准确率: 10.824716981132076\n", + "37.85200872159308\n" ] } ], @@ -1069,14 +456,6 @@ "\n", "print(accuracy_rote)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3e69cacc", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {