From 1f827d8224d8631afb9477c08c7cfaaa74fa75cd Mon Sep 17 00:00:00 2001 From: workpc Date: Fri, 13 Dec 2024 14:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=87=86=E7=A1=AE=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_yuanyou.py | 38 ++++++++++++++++++------------------ models/nerulforcastmodels.py | 34 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/main_yuanyou.py b/main_yuanyou.py index 38e5722..2abeabf 100644 --- a/main_yuanyou.py +++ b/main_yuanyou.py @@ -178,25 +178,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('模型训练完成') diff --git a/models/nerulforcastmodels.py b/models/nerulforcastmodels.py index 5946441..91ba459 100644 --- a/models/nerulforcastmodels.py +++ b/models/nerulforcastmodels.py @@ -395,28 +395,28 @@ def model_losss(sqlitedb): df_predict2 = df_combined3.tail(horizon) # 保存到数据库 - # if not sqlitedb.check_table_exists('accuracy'): - # columns = ','.join(df_combined3.columns.to_list()+['id','CREAT_DATE']) - # sqlitedb.create_table('accuracy',columns=columns) - # existing_data = sqlitedb.select_data(table_name = "accuracy") - # update_y = sqlitedb.select_data(table_name = "accuracy",where_condition='y is null') - # df_combined4 = df_combined3[(df_combined3['ds'].isin(update_y['ds'])) & (df_combined3['y'].notnull())] - # if len(df_combined4) > 0: - # for index, row in df_combined4.iterrows(): - # sqlitedb.update_data('accuracy',f"y = {row['y']}",f"ds = '{row['ds']}'") - # print(df_combined4) - # if not existing_data.empty: - # max_id = existing_data['id'].astype(int).max() - # df_predict2['id'] = range(max_id + 1, max_id + 1 + len(df_predict2)) - # else: - # df_predict2['id'] = range(1, 1 + len(df_predict2)) + if not sqlitedb.check_table_exists('accuracy'): + columns = ','.join(df_combined3.columns.to_list()+['id','CREAT_DATE']) + sqlitedb.create_table('accuracy',columns=columns) + existing_data = sqlitedb.select_data(table_name = "accuracy") + update_y = sqlitedb.select_data(table_name = "accuracy",where_condition='y is null') + df_combined4 = df_combined3[(df_combined3['ds'].isin(update_y['ds'])) & (df_combined3['y'].notnull())] + if len(df_combined4) > 0: + for index, row in df_combined4.iterrows(): + sqlitedb.update_data('accuracy',f"y = {row['y']}",f"ds = '{row['ds']}'") + print(df_combined4) + if not existing_data.empty: + max_id = existing_data['id'].astype(int).max() + df_predict2['id'] = range(max_id + 1, max_id + 1 + len(df_predict2)) + else: + df_predict2['id'] = range(1, 1 + len(df_predict2)) - # df_predict2['CREAT_DATE'] = now if end_time == '' else end_time + df_predict2['CREAT_DATE'] = now if end_time == '' else end_time # df_predict2['PREDICT_DATE'] = df_predict2['ds'] # df_predict2['MIN_PRICE'] = df_predict2['min_within_quantile'] # df_predict2['MAX_PRICE'] = df_predict2['max_within_quantile'] # df_predict2 = df_predict2[['id','PREDICT_DATE','CREAT_DATE','MIN_PRICE','MAX_PRICE']] - # df_predict2.to_sql("accuracy", con=sqlitedb.connection, if_exists='append', index=False) + df_predict2.to_sql("accuracy", con=sqlitedb.connection, if_exists='append', index=False)