Download routes/task.py from SiraH/Drug-classification-docker-fastapi: direct link, hf CLI and curl.
- Browser
- Download file 691 Bytes
-
https://huggingface.co/spaces/SiraH/Drug-classification-docker-fastapi/resolve/main/routes/task.py
- Command line
-
hf download hf://spaces/SiraH/Drug-classification-docker-fastapi/routes/task.py
-
curl -L -o task.py https://huggingface.co/spaces/SiraH/Drug-classification-docker-fastapi/resolve/main/routes/task.py
691 Bytes
| import skops.io as sio | |
| pipe = sio.load("./Model/drug_pipeline.skops", trusted=True) | |
| def predict_drug(age, sex, blood_pressure, cholesterol, na_to_k_ratio): | |
| """Predict drugs based on patient features. | |
| Args: | |
| age (int): Age of patient | |
| sex (str): Sex of patient | |
| blood_pressure (str): Blood pressure level | |
| cholesterol (str): Cholesterol level | |
| na_to_k_ratio (float): Ratio of sodium to potassium in blood | |
| Returns: | |
| str: Predicted drug label | |
| """ | |
| features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio] | |
| predicted_drug = pipe.predict([features])[0] | |
| label = f"Predicted Drug: {predicted_drug}" | |
| return label |