Spaces:
Sleeping
Sleeping
import gradio as gr | |
import numpy as np | |
import pandas as pd | |
from gradio.outputs import Label | |
def multi_inputs(input_2, input_3, input_1, input_5, input_4, input_6, input_7, input_8, input_9, input_10, input_11, input_12, input_13): | |
output=gr.outputs.Textbox(label = "Therapeutic Dose of Warfarin") | |
intputdata = ['Gender','Race (Reported)','Age','Height (cm)','Weight (kg)','Diabetes','Simvastatin (Zocor)','Amiodarone (Cordarone)','Target INR','INR on Reported Therapeutic Dose of Warfarin','Cyp2C9 genotypes','VKORC1 genotype: -1639 G>A (3673); chr16:31015190; rs9923231; C/T'] | |
inputs = [input_2, input_3, input_1, input_5, input_4, input_6, input_7, input_8, input_9, input_10, input_11, input_12] | |
df1 = pd.DataFrame(data= [inputs],columns= [intputdata]) | |
input_13 = 'Logistic Regression' | |
if input_13 == ' Logistic Regression ': | |
output = logistic_model.predict(df1) | |
if output == 0: | |
output = "Low dose required" | |
else: | |
output = "High Dose" | |
return output | |
input_13 = 'Decision Tree' | |
if input_13 == ' Decision Tree ': | |
output = logistic_model.predict(df1) | |
if output == 0: | |
output = "Low dose required" | |
else: | |
output = "High Dose" | |
return output | |
input_13 = 'Random Forest' | |
if input_13 == ' Random Forest ': | |
output = logistic_model.predict(df1) | |
if output == 0: | |
output = "Low dose required" | |
else: | |
output = "High Dose" | |
return output | |
input_1 = gr.inputs.Number(label = "Age") | |
input_2 = gr.inputs.Dropdown(choices=["0", "1"], label = "Gender") | |
input_3 = gr.inputs.Dropdown(choices=["0", "1", "2", "3", "4", "5"], label = "Race") | |
input_4 = gr.inputs.Number(label = "Weight") | |
input_5 = gr.inputs.Number(label = "Height") | |
input_6 = gr.inputs.Dropdown(choices=["1", "0"], label = "Diabetes") | |
input_7 = gr.inputs.Dropdown(choices=["1", "0"], label = "Simvastatin (Zocor)") | |
input_8 = gr.inputs.Dropdown(choices=["1", "0"], label = "Amiodarone (Cordarone)") | |
input_9 = gr.inputs.Number(label = "Target INR") | |
input_10 = gr.inputs.Number(label = "INR on Reported Therapeutic Dose of Warfarin") | |
input_11 = gr.inputs.Dropdown(choices=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"], label = "Cyp2C9 genotypes") | |
input_12 = gr.inputs.Dropdown(choices=["0", "2", "1"], label = "VKORC1 genotype: -1639 G>A (3673); chr16:31015190; rs9923231; C/T") | |
input_13 = gr.inputs.Dropdown(choices=["Decision Tree", "Logistic Regression", "Random Forest"], label = "Model") | |
output=gr.outputs.Textbox(label = "Therapeutic Dose of Warfarin") | |
gr.Interface(fn= multi_inputs, inputs=[input_1, input_2, input_3, input_4, input_5, input_6, input_7, input_8, input_9, input_10, input_11, input_12, input_13], | |
outputs=[output] | |
).launch() |