sylvain471 commited on
Commit
f9be216
β€’
1 Parent(s): 22d82b9

Sync App files

Browse files
Files changed (3) hide show
  1. README.md +6 -7
  2. drug_app.py +57 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,12 +1,11 @@
1
  ---
2
  title: Drug Classification
3
- emoji: πŸ“ˆ
4
- colorFrom: indigo
5
- colorTo: purple
6
  sdk: gradio
7
  sdk_version: 4.44.1
8
- app_file: app.py
9
  pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Drug Classification
3
+ emoji: πŸ’Š
4
+ colorFrom: yellow
5
+ colorTo: red
6
  sdk: gradio
7
  sdk_version: 4.44.1
8
+ app_file: drug_app.py
9
  pinned: false
10
+ license: apache-2.0
11
+ ---
 
drug_app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import skops.io as sio
3
+
4
+ #pipe = sio.load("./Model/drug_pipeline.skops", trusted=True)
5
+ pipe = sio.load("../Model/drug_pipeline.skops",trusted = ['numpy.dtype'])
6
+
7
+
8
+ def predict_drug(age, sex, blood_pressure, cholesterol, na_to_k_ratio):
9
+ """Predict drugs based on patient features.
10
+
11
+ Args:
12
+ age (int): Age of patient
13
+ sex (str): Sex of patient
14
+ blood_pressure (str): Blood pressure level
15
+ cholesterol (str): Cholesterol level
16
+ na_to_k_ratio (float): Ratio of sodium to potassium in blood
17
+
18
+ Returns:
19
+ str: Predicted drug label
20
+ """
21
+ features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio]
22
+ predicted_drug = pipe.predict([features])[0]
23
+
24
+ return f"Predicted Drug: {predicted_drug}"
25
+
26
+
27
+ inputs = [
28
+ gr.Slider(15, 74, step=1, label="Age"),
29
+ gr.Radio(["M", "F"], label="Sex"),
30
+ gr.Radio(["HIGH", "LOW", "NORMAL"], label="Blood Pressure"),
31
+ gr.Radio(["HIGH", "NORMAL"], label="Cholesterol"),
32
+ gr.Slider(6.2, 38.2, step=0.1, label="Na_to_K"),
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?"
45
+ article = "This app is a part of the Beginner's Guide to CI/CD for Machine Learning. It teaches how to automate training, evaluation, and deployment of models to Hugging Face using GitHub Actions."
46
+
47
+
48
+ gr.Interface(
49
+ fn=predict_drug,
50
+ inputs=inputs,
51
+ outputs=outputs,
52
+ examples=examples,
53
+ title=title,
54
+ description=description,
55
+ article=article,
56
+ theme=gr.themes.Soft(),
57
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ scikit-learn
2
+ skops