Spaces:
Sleeping
Sleeping
Sync App files
Browse files- drug_app.py +6 -4
drug_app.py
CHANGED
|
@@ -27,10 +27,12 @@ def predict_drug(age, sex, blood_pressure, cholesterol, na_to_k_ratio):
|
|
| 27 |
str: Predicted drug label
|
| 28 |
"""
|
| 29 |
features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio]
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
inputs = [
|
|
|
|
| 27 |
str: Predicted drug label
|
| 28 |
"""
|
| 29 |
features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio]
|
| 30 |
+
probabilities = pipe.predict_proba([features])[0]
|
| 31 |
+
class_probabilities = {
|
| 32 |
+
label: float(prob)
|
| 33 |
+
for label, prob in zip(pipe.classes_, probabilities)
|
| 34 |
+
}
|
| 35 |
+
return class_probabilities
|
| 36 |
|
| 37 |
|
| 38 |
inputs = [
|