anweiguo před 1 měsícem
rodič
revize
36dc08b27e

+ 2 - 2
models_processing/model_predict/model_prediction_bp.py

@@ -12,7 +12,7 @@ app = Flask('model_prediction_bp——service')
 def model_prediction(df,args):
     if 'is_limit' in df.columns:
         df = df[df['is_limit'] == False]
-    features, time_steps, col_time, model_name,howLongAgo,farm_id = str_to_list(args['features']), int(args['time_steps']),args['col_time'],args['model_name'],int(args['howLongAgo']),args['farm_id']
+    features, time_steps, col_time, model_name,howLongAgo,farm_id,target = str_to_list(args['features']), int(args['time_steps']),args['col_time'],args['model_name'],int(args['howLongAgo']),args['farm_id'],args['target']
     feature_scaler,target_scaler = get_scaler_model_from_mongo(args)
     df = df.sort_values(by=col_time).fillna(method='ffill').fillna(method='bfill')
     scaled_features = feature_scaler.transform(df[features])
@@ -28,7 +28,7 @@ def model_prediction(df,args):
     result['model'] = model_name
     result['howLongAgo'] = howLongAgo
     result['farm_id'] = farm_id
-    return result[['dateTime', 'howLongAgo', 'model', 'farm_id', 'power_forecast', 'realPower']]
+    return result[['dateTime', 'howLongAgo', 'model', 'farm_id', 'power_forecast', target]]
 
 
 @app.route('/model_prediction_bp', methods=['POST'])

+ 2 - 2
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,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']
+    mongodb_connection,mongodb_database,mongodb_model_table,model_name,howLongAgo,farm_id,target = "mongodb://root:sdhjfREWFWEF23e@192.168.1.43:30000/",args['mongodb_database'],args['mongodb_model_table'],args['model_name'],int(args['howLongAgo']),args['farm_id'],args['target']
     client = MongoClient(mongodb_connection)
     db = client[mongodb_database]
     collection = db[mongodb_model_table]
@@ -92,7 +92,7 @@ def model_prediction(df,args):
         df['farm_id'] = farm_id
         print("model predict result  successfully!")
 
-    return df[['dateTime','howLongAgo','model','farm_id','power_forecast','realPower']]
+    return df[['dateTime','howLongAgo','model','farm_id','power_forecast',target]]
 
 
 @app.route('/model_prediction_lightgbm', methods=['POST'])

+ 2 - 2
models_processing/model_predict/model_prediction_lstm.py

@@ -63,7 +63,7 @@ def forecast_data_distribution(pre_data,args):
 def model_prediction(df,args):
     if 'is_limit' in df.columns:
         df = df[df['is_limit'] == False]
-    features, time_steps, col_time, model_name,howLongAgo,farm_id = str_to_list(args['features']), int(args['time_steps']),args['col_time'],args['model_name'],int(args['howLongAgo']),args['farm_id']
+    features, time_steps, col_time, model_name,howLongAgo,farm_id,target = str_to_list(args['features']), int(args['time_steps']),args['col_time'],args['model_name'],int(args['howLongAgo']),args['farm_id'],args['target']
     feature_scaler,target_scaler = get_scaler_model_from_mongo(args)
     df = df.sort_values(by=col_time).fillna(method='ffill').fillna(method='bfill')
     scaled_features = feature_scaler.transform(df[features])
@@ -78,7 +78,7 @@ def model_prediction(df,args):
     result['howLongAgo'] = howLongAgo
     result['farm_id'] = farm_id
     result['model'] = model_name
-    return result[['dateTime', 'howLongAgo', 'model', 'farm_id', 'power_forecast', 'realPower']]
+    return result[['dateTime', 'howLongAgo', 'model', 'farm_id', 'power_forecast', target]]
 
 
 @app.route('/model_prediction_lstm', methods=['POST'])

+ 1 - 1
models_processing/model_train/model_training_lstm.py

@@ -86,7 +86,7 @@ def build_model(data, args):
     # 使用GPU进行训练
     with tf.device('/GPU:1'):
         history = model.fit(X_train, y_train,
-                        epochs=5,
+                        epochs=100,
                         batch_size=32,
                         validation_data=(X_test, y_test),
                         verbose=2,