Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,24 +122,22 @@ def predict(data: OneHotPatientData):
|
|
| 122 |
feature_order = [
|
| 123 |
'age', 'bmi', 'cholesterol_level', 'hypertension', 'asthma',
|
| 124 |
'cirrhosis', 'other_cancer', 'gender_Male',
|
| 125 |
-
'country_Belgium','country_Bulgaria','country_Croatia','country_Cyprus',
|
| 126 |
-
'
|
| 127 |
-
'country_France','country_Germany','country_Greece','country_Hungary',
|
| 128 |
-
'country_Ireland','country_Italy','country_Latvia','country_Lithuania',
|
| 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
|
| 133 |
'family_history_Yes',
|
| 134 |
-
'smoking_status_Former Smoker','smoking_status_Never Smoked','smoking_status_Passive Smoker',
|
| 135 |
-
'treatment_type_Combined','treatment_type_Radiation','treatment_type_Surgery'
|
| 136 |
]
|
| 137 |
|
| 138 |
-
# Fill missing fields with 0
|
| 139 |
input_dict_complete = {col: input_dict.get(col, 0) for col in feature_order}
|
| 140 |
input_df = pd.DataFrame([input_dict_complete], columns=feature_order)
|
| 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"
|
|
|
|
| 122 |
feature_order = [
|
| 123 |
'age', 'bmi', 'cholesterol_level', 'hypertension', 'asthma',
|
| 124 |
'cirrhosis', 'other_cancer', 'gender_Male',
|
| 125 |
+
'country_Belgium', 'country_Bulgaria', 'country_Croatia', 'country_Cyprus',
|
| 126 |
+
'country_Czech Republic', 'country_Denmark', 'country_Estonia', 'country_Finland',
|
| 127 |
+
'country_France', 'country_Germany', 'country_Greece', 'country_Hungary',
|
| 128 |
+
'country_Ireland', 'country_Italy', 'country_Latvia', 'country_Lithuania',
|
| 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',
|
| 133 |
'family_history_Yes',
|
| 134 |
+
'smoking_status_Former Smoker', 'smoking_status_Never Smoked', 'smoking_status_Passive Smoker',
|
| 135 |
+
'treatment_type_Combined', 'treatment_type_Radiation', 'treatment_type_Surgery'
|
| 136 |
]
|
| 137 |
|
|
|
|
| 138 |
input_dict_complete = {col: input_dict.get(col, 0) for col in feature_order}
|
| 139 |
input_df = pd.DataFrame([input_dict_complete], columns=feature_order)
|
| 140 |
|
|
|
|
| 141 |
probabilities = model.predict_proba(input_df)[0]
|
| 142 |
confidence_high_risk = probabilities[1]
|
| 143 |
risk_level = "High Risk of Non-Survival" if confidence_high_risk > 0.5 else "Low Risk of Non-Survival"
|