kingabzpro
commited on
Commit
•
21e3c04
1
Parent(s):
2373f20
Sync App files
Browse files- drug_app.py +26 -13
drug_app.py
CHANGED
@@ -4,23 +4,23 @@ import skops.io as sio
|
|
4 |
pipe = sio.load("./Model/drug_pipeline.skops", trusted=True)
|
5 |
|
6 |
|
7 |
-
def
|
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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
Returns:
|
20 |
-
|
21 |
"""
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
return label
|
25 |
|
26 |
|
@@ -42,12 +42,25 @@ examples = [
|
|
42 |
|
43 |
title = "Drug Classification"
|
44 |
description = "Enter the details to correctly identify Drug type?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
gr.Interface(
|
47 |
-
fn=
|
48 |
inputs=inputs,
|
49 |
outputs=outputs,
|
50 |
examples=examples,
|
51 |
title=title,
|
52 |
description=description,
|
|
|
|
|
53 |
).launch()
|
|
|
4 |
pipe = sio.load("./Model/drug_pipeline.skops", trusted=True)
|
5 |
|
6 |
|
7 |
+
def predict_drug(age, sex, blood_pressure, cholesterol, na_to_k_ratio):
|
8 |
+
"""Predict drug based on patient features.
|
|
|
|
|
9 |
|
10 |
Args:
|
11 |
+
age (int): Age of patient
|
12 |
+
sex (int): Sex of patient (0 for female, 1 for male)
|
13 |
+
blood_pressure (int): Blood pressure level
|
14 |
+
cholesterol (int): Cholesterol level
|
15 |
+
na_to_k_ratio (float): Ratio of sodium to potassium in blood
|
16 |
|
17 |
Returns:
|
18 |
+
str: Predicted drug label
|
19 |
"""
|
20 |
+
features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio]
|
21 |
+
predicted_drug = pipe.predict([features])[0]
|
22 |
+
|
23 |
+
label = f"Predicted Drug: {predicted_drug}"
|
24 |
return label
|
25 |
|
26 |
|
|
|
42 |
|
43 |
title = "Drug Classification"
|
44 |
description = "Enter the details to correctly identify Drug type?"
|
45 |
+
article = """<center>
|
46 |
+
|
47 |
+
[![GitHub Repo stars](https://img.shields.io/github/stars/kingabzpro/CICD-for-Machine-Learning)](https://github.com/kingabzpro/CICD-for-Machine-Learning)[![Follow me on HF](https://huggingface.co/datasets/huggingface/badges/resolve/main/follow-me-on-HF-md.svg)](https://huggingface.co/kingabzpro)
|
48 |
+
|
49 |
+
**This app is a part of the Beginner's Guide to CI/CD for Machine Learning.**
|
50 |
+
|
51 |
+
**It teaches how to automate training, evaluation, and deployment of models to Hugging Face using GitHub Actions.**
|
52 |
+
|
53 |
+
[![DataCamp](https://img.shields.io/badge/Datacamp-05192D?style=for-the-badge&logo=datacamp&logoColor=65FF8F)](https://www.datacamp.com/portfolio/kingabzpro)
|
54 |
+
|
55 |
+
</center>"""
|
56 |
|
57 |
gr.Interface(
|
58 |
+
fn=predict_drug,
|
59 |
inputs=inputs,
|
60 |
outputs=outputs,
|
61 |
examples=examples,
|
62 |
title=title,
|
63 |
description=description,
|
64 |
+
article=article,
|
65 |
+
theme=gr.themes.Soft(),
|
66 |
).launch()
|