Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
from fastapi import FastAPI
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from pydantic import BaseModel
|
| 6 |
import joblib
|
|
@@ -129,9 +129,9 @@ def predict(data: OneHotPatientData):
|
|
| 129 |
'country_Luxembourg','country_Malta','country_Netherlands','country_Poland',
|
| 130 |
'country_Portugal','country_Romania','country_Slovakia','country_Slovenia',
|
| 131 |
'country_Spain','country_Sweden',
|
| 132 |
-
'
|
| 133 |
'family_history_Yes',
|
| 134 |
-
'
|
| 135 |
'treatment_type_Combined','treatment_type_Radiation','treatment_type_Surgery'
|
| 136 |
]
|
| 137 |
|
|
@@ -141,7 +141,7 @@ def predict(data: OneHotPatientData):
|
|
| 141 |
|
| 142 |
# Predict probabilities
|
| 143 |
probabilities = model.predict_proba(input_df)[0]
|
| 144 |
-
confidence_high_risk = probabilities[1]
|
| 145 |
risk_level = "High Risk of Non-Survival" if confidence_high_risk > 0.5 else "Low Risk of Non-Survival"
|
| 146 |
|
| 147 |
result = {
|
|
@@ -152,4 +152,4 @@ def predict(data: OneHotPatientData):
|
|
| 152 |
|
| 153 |
except Exception as e:
|
| 154 |
logger.error(f"Prediction error: {str(e)}")
|
| 155 |
-
|
|
|
|
| 1 |
+
# pulmoprobe_backend/app.py
|
| 2 |
|
| 3 |
+
from fastapi import FastAPI, HTTPException
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from pydantic import BaseModel
|
| 6 |
import joblib
|
|
|
|
| 129 |
'country_Luxembourg','country_Malta','country_Netherlands','country_Poland',
|
| 130 |
'country_Portugal','country_Romania','country_Slovakia','country_Slovenia',
|
| 131 |
'country_Spain','country_Sweden',
|
| 132 |
+
'cancer_stage_Stage II','cancer_stage_Stage III','cancer_stage_Stage IV', # Corrected names
|
| 133 |
'family_history_Yes',
|
| 134 |
+
'smoking_status_Former Smoker','smoking_status_Never Smoked','smoking_status_Passive Smoker', # Corrected names
|
| 135 |
'treatment_type_Combined','treatment_type_Radiation','treatment_type_Surgery'
|
| 136 |
]
|
| 137 |
|
|
|
|
| 141 |
|
| 142 |
# Predict probabilities
|
| 143 |
probabilities = model.predict_proba(input_df)[0]
|
| 144 |
+
confidence_high_risk = probabilities[1]
|
| 145 |
risk_level = "High Risk of Non-Survival" if confidence_high_risk > 0.5 else "Low Risk of Non-Survival"
|
| 146 |
|
| 147 |
result = {
|
|
|
|
| 152 |
|
| 153 |
except Exception as e:
|
| 154 |
logger.error(f"Prediction error: {str(e)}")
|
| 155 |
+
raise HTTPException(status_code=500, detail=str(e))
|