|
|
|
|
|
|
|
|
|
import gradio as gr |
|
import pandas as pd |
|
from pycaret.classification import load_model, predict_model |
|
|
|
|
|
|
|
|
|
model = load_model("tuned_blend_specific_model_19112021") |
|
|
|
|
|
|
|
def predict(model, input_df): |
|
predictions_df = predict_model(estimator=model, data=input_df) |
|
predictions = predictions_df["AMPUTATION"][0] |
|
return predictions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def predict_amputation(age, gender, race, diabetes_type): |
|
|
|
|
|
|
|
|
|
|
|
|
|
input_dict = {"AGE": 70, "GENDER": "F", "RACE": "Asian", "DIABETES_CLASS":"Type 2 diabetes", "AMPUTATION":0} |
|
|
|
|
|
input_dict = {"AGE": 80, "GENDER": "F", "RACE": "Asian", "DIABETES_CLASS":"Type 2 diabetes", "AMPUTATION":0} |
|
|
|
|
|
input_df = pd.DataFrame([input_dict]) |
|
return "ALLAH: "+str(predict(model=model, input_df=input_df)) |
|
|
|
|
|
|
|
|
|
title = "DIabetes-related Amputation Risk Calculator (DIARC)" |
|
|
|
description = "A diabetes-related amputation machine learning model trained on the diabetes dataset from the Inkosi Albert Luthuli Central Hospital (IALCH) in Durban, KwaZulu-Natal, South Africa." |
|
|
|
article = "<p style='text-align: center'><span style='font-size: 15pt;'>© DIARC. 2021. All Rights Reserved.</span></p>" |
|
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_amputation, |
|
title=title, |
|
description=description, |
|
article=article, |
|
inputs=[gr.inputs.Slider(minimum=0,maximum=100, step=1, label="Age"), gr.inputs.Dropdown(["Female", "Male"], default="Male", label="Gender"), gr.inputs.Dropdown(["Asian", "Black", "Coloured", "White", "Other"], default="Asian", label="Race"), gr.inputs.Dropdown(["1", "2"], default="1", label="Diabetes Type")], |
|
outputs="text", |
|
theme="darkhuggingface", |
|
examples=[ |
|
[50, "Male", "Black", 2], |
|
[76, "Female", "Asian", 2], |
|
[12, "Female", "White", 1], |
|
[30, "Male", "Coloured", 1], |
|
[65, "Female", "Other", 2], |
|
], |
|
) |
|
|
|
iface.test_launch() |
|
if __name__ == "__main__": |
|
iface.launch() |