diff --git a/aisenzhecode/石油苯/日度价格预测_最佳模型.pkl b/aisenzhecode/石油苯/日度价格预测_最佳模型.pkl
index 06b4fce..b25f3a2 100644
Binary files a/aisenzhecode/石油苯/日度价格预测_最佳模型.pkl and b/aisenzhecode/石油苯/日度价格预测_最佳模型.pkl differ
diff --git a/aisenzhecode/石油苯/纯苯价格预测-自定义日期ytj.ipynb b/aisenzhecode/石油苯/纯苯价格预测-自定义日期ytj.ipynb
index b2e2801..944eb98 100644
--- a/aisenzhecode/石油苯/纯苯价格预测-自定义日期ytj.ipynb
+++ b/aisenzhecode/石油苯/纯苯价格预测-自定义日期ytj.ipynb
@@ -11,23 +11,23 @@
" \n",
- " \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "C:\\Users\\h5218\\AppData\\Local\\Temp\\ipykernel_35936\\3451377547.py:725: DeprecationWarning:\n",
- "\n",
- "The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
- "\n"
- ]
}
],
"source": [
@@ -35,7 +35,7 @@
"import json\n",
"import xlrd\n",
"import xlwt\n",
- "from datetime import datetime\n",
+ "from datetime import datetime,timedelta\n",
"import time\n",
"# 变量定义\n",
"login_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n",
@@ -96,7 +96,6 @@
"from sklearn.linear_model import Lasso\n",
"from xgboost import XGBRegressor\n",
"\n",
- "import datetime\n",
"import statsmodels.api as sm\n",
"try:\n",
" from keras.preprocessing.sequence import TimeseriesGenerator\n",
@@ -191,8 +190,7 @@
"\n",
"def get_cur_time(date=''):\n",
" if date == '':\n",
- " import datetime\n",
- " now = datetime.datetime.now()\n",
+ " now = datetime.now()\n",
" else:\n",
" now = date\n",
" year = now.year\n",
@@ -222,22 +220,22 @@
"\n",
"def upload_data_to_system(token_push,date):\n",
" datavalue = forecast_price()\n",
- " data = {\n",
- " \"funcModule\": \"数据表信息列表\",\n",
- " \"funcOperation\": \"新增\",\n",
- " \"data\": [\n",
- " {\"dataItemNo\": \"C01100047|FORECAST_PRICE\",\n",
- " \"dataDate\": get_cur_time(date)[0],\n",
- " \"dataStatus\": \"add\",\n",
- " \"dataValue\": datavalue\n",
- " }\n",
+ " # data = {\n",
+ " # \"funcModule\": \"数据表信息列表\",\n",
+ " # \"funcOperation\": \"新增\",\n",
+ " # \"data\": [\n",
+ " # {\"dataItemNo\": \"C01100047|FORECAST_PRICE\",\n",
+ " # \"dataDate\": get_cur_time(date)[0],\n",
+ " # \"dataStatus\": \"add\",\n",
+ " # \"dataValue\": datavalue\n",
+ " # }\n",
"\n",
- " ]\n",
- " }\n",
- " print(data)\n",
- " headers = {\"Authorization\": token_push}\n",
- " res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n",
- " print(res.text)\n",
+ " # ]\n",
+ " # }\n",
+ " # print(data)\n",
+ " # headers = {\"Authorization\": token_push}\n",
+ " # res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n",
+ " # print(res.text)\n",
"\n",
" \n",
"# def upload_data_to_system(token):\n",
@@ -336,7 +334,6 @@
" from sklearn.linear_model import Lasso\n",
" from xgboost import XGBRegressor\n",
"\n",
- " from datetime import datetime\n",
" import statsmodels.api as sm\n",
" try:\n",
" from keras.preprocessing.sequence import TimeseriesGenerator\n",
@@ -506,19 +503,17 @@
"\n",
"\n",
"\n",
- "def start(date):\n",
+ "def start(date,token=None,token_push=None):\n",
" read_xls_data()\n",
"\n",
- " token = get_head_auth()\n",
- " if not token:\n",
- " return\n",
- " token_push = get_head_push_auth()\n",
- " if not token_push:\n",
- " return\n",
+ " if token == None:\n",
+ " token = get_head_auth()\n",
+ " token_push = get_head_push_auth()\n",
"\n",
" datas = get_data_value(token, one_cols[1:],date)\n",
- "# if not datas:\n",
- "# return\n",
+ " if not datas:\n",
+ " print(\"今天没有新数据\")\n",
+ " return\n",
"\n",
" # data_list = [two_cols, one_cols]\n",
" append_rows = [get_cur_time(date)[1]]\n",
@@ -536,7 +531,12 @@
" else:\n",
" append_rows.append(\"\")\n",
" save_xls(append_rows)\n",
+ " \n",
+ " # 获取当月的数据写入到指定文件,如果是补充数据,不需要执行\n",
+ " queryDataListItemNos()\n",
+ " # 模型训练\n",
" optimize_Model()\n",
+ " # 上传预测数据\n",
" upload_data_to_system(token_push,date)\n",
" # data_list.append(three_cols)\n",
" # write_xls(data_list)\n",
@@ -701,7 +701,7 @@
"\n",
"def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
"\n",
- " current_year_month = datetime.datetime.now().strftime('%Y-%m')\n",
+ " current_year_month = datetime.now().strftime('%Y-%m')\n",
" grouped = data_df.groupby(\"dataDate\")\n",
"\n",
" # 打开xls文件\n",
@@ -768,16 +768,14 @@
"\n",
"\n",
"\n",
- "def queryDataListItemNos():\n",
+ "def queryDataListItemNos(token=None):\n",
" df = pd.read_excel('纯苯数据项.xls')\n",
" dataItemNoList = df.iloc[0].tolist()[1:]\n",
"\n",
- " token = get_head_auth()\n",
- " if not token:\n",
- " return\n",
- "\n",
+ " if token == None:\n",
+ " token = get_head_auth()\n",
" # 获取当前日期\n",
- " current_date = datetime.datetime.now()\n",
+ " current_date = datetime.now()\n",
"\n",
" # 获取当月1日\n",
" first_day_of_month = current_date.replace(day=1)\n",
@@ -800,32 +798,27 @@
"\n",
"\n",
"if __name__ == \"__main__\":\n",
- " # queryDataListItemNos()\n",
- " pass\n",
- " # 需要单独运行放开\n",
- " # start_1()\n",
"\n",
" # 每天定时12点运行\n",
- " # while True:\n",
- " # # 获取当前时间\n",
- " # current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
- " # current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
- " # # 获取当月的数据写入到指定文件\n",
- " # queryDataListItemNos()\n",
- "\n",
- "\n",
- " # # 判断当前时间是否为执行任务的时间点\n",
- " # if current_time == \"09:15:00\":\n",
- " # print(\"执行定时任务\")\n",
- " # start()\n",
- "\n",
- " # # 休眠1秒钟,避免过多占用CPU资源\n",
- " # time.sleep(1)\n",
+ " while True:\n",
+ " # 获取当前时间\n",
+ " current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
+ " current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
" \n",
- " # elif current_time_1 == \"20:00:00\":\n",
- " # print(\"更新数据\")\n",
- " # start_1()\n",
- " # time.sleep(1)\n",
+ "\n",
+ "\n",
+ " # 判断当前时间是否为执行任务的时间点\n",
+ " if current_time == \"09:15:00\":\n",
+ " print(\"执行定时任务\")\n",
+ " start()\n",
+ "\n",
+ " # 休眠1秒钟,避免过多占用CPU资源\n",
+ " time.sleep(1)\n",
+ " \n",
+ " elif current_time_1 == \"20:00:00\":\n",
+ " print(\"更新数据\")\n",
+ " start_1()\n",
+ " time.sleep(1)\n",
"\n",
"\n",
"# # 检测数据准确性, 需要检测放开\n",
@@ -835,84 +828,36 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "20250201\n",
- "{'dataDate': '20250201', 'dataItemNo': 'C01100047|TURNOVER'}\n"
+ "20250408\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_21000\\3095856616.py:280: UserWarning:\n",
+ "C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_31052\\2446979738.py:725: DeprecationWarning:\n",
+ "\n",
+ "The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
+ "\n",
+ "C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_31052\\2446979738.py:279: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"d:\\ProgramData\\anaconda3\\Lib\\site-packages\\sklearn\\linear_model\\_coordinate_descent.py:631: ConvergenceWarning:\n",
"\n",
- "Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 5.321e+05, tolerance: 4.074e+04\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Using matplotlib backend: