Parcourir la source

awg 更新LGB

anweiguo il y a 1 mois
Parent
commit
696fe519d3
1 fichiers modifiés avec 7 ajouts et 6 suppressions
  1. 7 6
      models_processing/model_predict/model_prediction_lightgbm.py

+ 7 - 6
models_processing/model_predict/model_prediction_lightgbm.py

@@ -73,7 +73,7 @@ def forecast_data_distribution(pre_data,args):
 
 
 def model_prediction(df,args):
-    mongodb_connection,mongodb_database,mongodb_model_table,model_name,col_reserve,howlongago = "mongodb://root:sdhjfREWFWEF23e@192.168.1.43:30000/",args['mongodb_database'],args['mongodb_model_table'],args['model_name'],str_to_list(args['col_reserve']),int(args['howlongago'])
+    mongodb_connection,mongodb_database,mongodb_model_table,model_name,howLongAgo,farm_id = "mongodb://root:sdhjfREWFWEF23e@192.168.1.43:30000/",args['mongodb_database'],args['mongodb_model_table'],args['model_name'],int(args['howLongAgo']),args['farm_id']
     client = MongoClient(mongodb_connection)
     db = client[mongodb_database]
     collection = db[mongodb_model_table]
@@ -85,13 +85,14 @@ def model_prediction(df,args):
         model_binary = model_data['model']  # 确保这个字段是存储模型的二进制数据
         # 反序列化模型 
         model = pickle.loads(model_binary)
-        df['predict'] = model.predict(df[model.feature_name()])
-        df.loc[df['predict']<0,'predict']=0
+        df['power_forecast'] = model.predict(df[model.feature_name()])
+        df.loc[df['power_forecast'] < 0, 'power_forecast'] = 0
         df['model'] = model_name
-        df['howlongago'] = howlongago
+        df['howLongAgo'] = howLongAgo
+        df['farm_id'] = farm_id
         print("model predict result  successfully!")
-    features_reserve = col_reserve + ['model', 'predict', 'howlongago']
-    return df[list(set(features_reserve))]
+
+    return df[['dateTime','howLongAgo','model','farm_id','power_forecast','realPower']]
 
 
 @app.route('/model_prediction_lightgbm', methods=['POST'])