kingabzpro
commited on
Commit
•
14b29ac
1
Parent(s):
6666b9d
Sync App files
Browse files- drug_app.py +22 -7
drug_app.py
CHANGED
@@ -5,8 +5,22 @@ pipe = sio.load("./Model/drug_pipeline.skops", trusted=True)
|
|
5 |
|
6 |
|
7 |
def classifier(Age, Sex, BP, Cholesterol, Na_to_K):
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
return label
|
11 |
|
12 |
|
@@ -19,11 +33,12 @@ inputs = [
|
|
19 |
]
|
20 |
outputs = [gr.Label(num_top_classes=5)]
|
21 |
|
22 |
-
examples=[
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
title = "Drug Classification"
|
29 |
description = "Enter the details to correctly identify Drug type?"
|
|
|
5 |
|
6 |
|
7 |
def classifier(Age, Sex, BP, Cholesterol, Na_to_K):
|
8 |
+
"""
|
9 |
+
This function takes input features Age, Sex, BP, Cholesterol, and Na_to_K,
|
10 |
+
and uses a sklearn pipeline to make a prediction on the glass label.
|
11 |
+
|
12 |
+
Args:
|
13 |
+
Age (float): The age of the patient
|
14 |
+
Sex (str): The sex of the patient (M or F)
|
15 |
+
BP (str): The blood pressure of the patient (HIGH, NORMAL, or LOW)
|
16 |
+
Cholesterol (str): The cholesterol level of the patient (HIGH or NORMAL)
|
17 |
+
Na_to_K (float): The ratio of sodium to potassium in the patient's blood
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
str: A string with the predicted drug label
|
21 |
+
"""
|
22 |
+
pred_drug = pipe.predict([[Age, Sex, BP, Cholesterol, Na_to_K]])[0]
|
23 |
+
label = f"Predicted Drug label: **{pred_drug}**"
|
24 |
return label
|
25 |
|
26 |
|
|
|
33 |
]
|
34 |
outputs = [gr.Label(num_top_classes=5)]
|
35 |
|
36 |
+
examples = [
|
37 |
+
[30, "M", "HIGH", "NORMAL", 15.4],
|
38 |
+
[35, "F", "LOW", "NORMAL", 8],
|
39 |
+
[50, "M", "HIGH", "HIGH", 34],
|
40 |
+
]
|
41 |
+
|
42 |
|
43 |
title = "Drug Classification"
|
44 |
description = "Enter the details to correctly identify Drug type?"
|