Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from gradio.outputs import Label
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
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):
|
| 9 |
+
|
| 10 |
+
output=gr.outputs.Textbox(label = "Therapeutic Dose of Warfarin")
|
| 11 |
+
|
| 12 |
+
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']
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
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]
|
| 16 |
+
|
| 17 |
+
df1 = pd.DataFrame(data= [inputs],columns= [intputdata])
|
| 18 |
+
input_13 = 'Logistic Regression'
|
| 19 |
+
|
| 20 |
+
if input_13 == ' Logistic Regression ':
|
| 21 |
+
output = logistic_model.predict(df1)
|
| 22 |
+
|
| 23 |
+
if output == 0:
|
| 24 |
+
output = "Low dose required"
|
| 25 |
+
else:
|
| 26 |
+
output = "High Dose"
|
| 27 |
+
return output
|
| 28 |
+
|
| 29 |
+
input_13 = 'Decision Tree'
|
| 30 |
+
|
| 31 |
+
if input_13 == ' Decision Tree ':
|
| 32 |
+
output = logistic_model.predict(df1)
|
| 33 |
+
|
| 34 |
+
if output == 0:
|
| 35 |
+
output = "Low dose required"
|
| 36 |
+
else:
|
| 37 |
+
output = "High Dose"
|
| 38 |
+
return output
|
| 39 |
+
|
| 40 |
+
input_13 = 'Random Forest'
|
| 41 |
+
|
| 42 |
+
if input_13 == ' Random Forest ':
|
| 43 |
+
output = logistic_model.predict(df1)
|
| 44 |
+
|
| 45 |
+
if output == 0:
|
| 46 |
+
output = "Low dose required"
|
| 47 |
+
else:
|
| 48 |
+
output = "High Dose"
|
| 49 |
+
return output
|
| 50 |
+
|
| 51 |
+
input_1 = gr.inputs.Number(label = "Age")
|
| 52 |
+
input_2 = gr.inputs.Dropdown(choices=["0", "1"], label = "Gender")
|
| 53 |
+
input_3 = gr.inputs.Dropdown(choices=["0", "1", "2", "3", "4", "5"], label = "Race")
|
| 54 |
+
input_4 = gr.inputs.Number(label = "Weight")
|
| 55 |
+
input_5 = gr.inputs.Number(label = "Height")
|
| 56 |
+
input_6 = gr.inputs.Dropdown(choices=["1", "0"], label = "Diabetes")
|
| 57 |
+
input_7 = gr.inputs.Dropdown(choices=["1", "0"], label = "Simvastatin (Zocor)")
|
| 58 |
+
input_8 = gr.inputs.Dropdown(choices=["1", "0"], label = "Amiodarone (Cordarone)")
|
| 59 |
+
input_9 = gr.inputs.Number(label = "Target INR")
|
| 60 |
+
input_10 = gr.inputs.Number(label = "INR on Reported Therapeutic Dose of Warfarin")
|
| 61 |
+
input_11 = gr.inputs.Dropdown(choices=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"], label = "Cyp2C9 genotypes")
|
| 62 |
+
input_12 = gr.inputs.Dropdown(choices=["0", "2", "1"], label = "VKORC1 genotype: -1639 G>A (3673); chr16:31015190; rs9923231; C/T")
|
| 63 |
+
input_13 = gr.inputs.Dropdown(choices=["Decision Tree", "Logistic Regression", "Random Forest"], label = "Model")
|
| 64 |
+
output=gr.outputs.Textbox(label = "Therapeutic Dose of Warfarin")
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
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],
|
| 68 |
+
outputs=[output]
|
| 69 |
+
).launch()
|