mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
debugging prediction process in backend
This commit is contained in:
parent
ade3e3947a
commit
1db02fc4f4
2 changed files with 11 additions and 10 deletions
|
|
@ -183,9 +183,13 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
logger.info("Preparing data for scoring in sap change api")
|
||||
recommendations_scoring_data = pd.DataFrame(recommendations_scoring_data)
|
||||
|
||||
# Merge the cleaning data onto recommendations_scoring_data
|
||||
|
||||
# Perform the same cleaning as in the model
|
||||
recommendations_scoring_data = DataProcessor.apply_averages_cleaning(
|
||||
data_to_clean=recommendations_scoring_data,
|
||||
cleaning_data=cleaning_data,
|
||||
cols_to_merge_on=COLUMNS_TO_MERGE_ON + ["LOCAL_AUTHORITY"]
|
||||
).drop(columns=["LOCAL_AUTHORITY"])
|
||||
|
||||
recommendations_scoring_data = DataProcessor.clean_missings_after_description_process(
|
||||
recommendations_scoring_data, [
|
||||
c for c in recommendations_scoring_data.columns if
|
||||
|
|
@ -193,12 +197,6 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
]
|
||||
)
|
||||
|
||||
recommendations_scoring_data = DataProcessor.apply_averages_cleaning(
|
||||
data_to_clean=recommendations_scoring_data,
|
||||
cleaning_data=cleaning_data,
|
||||
cols_to_merge_on=COLUMNS_TO_MERGE_ON + ["LOCAL_AUTHORITY"]
|
||||
).drop(columns=["LOCAL_AUTHORITY"])
|
||||
|
||||
sap_change_model_api = SAPChangeModelAPI(portfolio_id=body.portfolio_id, timestamp=created_at)
|
||||
file_location = sap_change_model_api.upload_scoring_data(
|
||||
df=recommendations_scoring_data, bucket=get_settings().DATA_BUCKET
|
||||
|
|
@ -209,7 +207,10 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
|
||||
# Retrieve the predictions
|
||||
predictions = pd.DataFrame(
|
||||
read_csv_from_s3(bucket_name=get_settings().PREDICTIONS_BUCKET, filepath=response["storage_filepath"])
|
||||
read_csv_from_s3(
|
||||
bucket_name=get_settings().PREDICTIONS_BUCKET,
|
||||
filepath=response["storage_filepath"].split(get_settings().PREDICTIONS_BUCKET + "/")[1]
|
||||
)
|
||||
)
|
||||
|
||||
predictions["RDSAP_CHANGE"] = predictions["RDSAP_CHANGE"].astype(float).round(1)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class SAPChangeModelAPI:
|
|||
logger.info("Making request to sap change api")
|
||||
url = f"{self.base_url}/sapmodel/predict"
|
||||
payload = {
|
||||
"file_location": f"s3://retrofit-data-dev/{file_location}",
|
||||
"file_location": file_location,
|
||||
"property_id": "", # This should get removed
|
||||
"portfolio_id": self.portfolio_id,
|
||||
"created_at": self.timestamp
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue