Spaces:
Runtime error
Runtime error
Sync App files
Browse filesFiles changed (2)
- drug_app.py+57
- requirements.txt+2-1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import gradio as grimport skops.io as siopipe = 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 patientsex (str): Sex of patientblood_pressure (str): Blood pressure levelcholesterol (str): Cholesterol levelna_to_k_ratio (float): Ratio of sodium to potassium in bloodReturns: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 labelinputs = [gr.Slider(15, 74, step=1, label="Age"),gr.Radio(["M", "F"], label="Sex"),gr.Radio(["HIGH", "LOW", "NORMAL"], label="Blood Pressure"),gr.Radio(["HIGH", "NORMAL"], label="Cholesterol"),gr.Slider(6.2, 38.2, step=0.1, label="Na_to_K"),]outputs = [gr.Label(num_top_classes=5)]examples = [[30, "M", "HIGH", "NORMAL", 15.4],[35, "F", "LOW", "NORMAL", 8],[50, "M", "HIGH", "HIGH", 34],]title = "Drug Classification"description = "Enter the details to correctly identify Drug type?"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."gr.Interface(fn=predict_drug,inputs=inputs,outputs=outputs,examples=examples,title=title,description=description,article=article,theme=gr.themes.Soft(),).launch()
12scikit-learn==1.4.2skops==0.9.0123scikit-learn==1.4.2skops==0.9.0gradio==4.38.1
drug_app.py+57
requirements.txt+2-1