|
@@ -73,7 +73,7 @@ def forecast_data_distribution(pre_data,args):
|
|
|
|
|
|
|
|
|
|
def model_prediction(df,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)
|
|
client = MongoClient(mongodb_connection)
|
|
db = client[mongodb_database]
|
|
db = client[mongodb_database]
|
|
collection = db[mongodb_model_table]
|
|
collection = db[mongodb_model_table]
|
|
@@ -85,13 +85,14 @@ def model_prediction(df,args):
|
|
model_binary = model_data['model'] # 确保这个字段是存储模型的二进制数据
|
|
model_binary = model_data['model'] # 确保这个字段是存储模型的二进制数据
|
|
# 反序列化模型
|
|
# 反序列化模型
|
|
model = pickle.loads(model_binary)
|
|
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['model'] = model_name
|
|
- df['howlongago'] = howlongago
|
|
|
|
|
|
+ df['howLongAgo'] = howLongAgo
|
|
|
|
+ df['farm_id'] = farm_id
|
|
print("model predict result successfully!")
|
|
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'])
|
|
@app.route('/model_prediction_lightgbm', methods=['POST'])
|