airakoze commited on
Commit
36c4cb6
β€’
1 Parent(s): 7c04ec8

initial commit

Browse files
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Warfarin Dosage
3
- emoji: πŸ“š
4
  colorFrom: yellow
5
  colorTo: red
6
  sdk: gradio
 
1
  ---
2
  title: Warfarin Dosage
3
+ emoji: πŸ’‰
4
  colorFrom: yellow
5
  colorTo: red
6
  sdk: gradio
ann_model_regression.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70a2c3d2d149e8985ff03632fe35315837ea47b87b3f842466bceebcef4c336c
3
+ size 102630
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+
4
+ gender_categories = ["Male", "Female"]
5
+ gender = gr.inputs.Dropdown(gender_categories, label="Gender")
6
+
7
+ race_categories = ["White", "Black", "Other"]
8
+ race = gr.inputs.Dropdown(race_categories, label="Race")
9
+
10
+ age_categories = ["80 - 89", "70 - 79", "50 - 59", "60 - 69", "0 - 9", "40 - 49", "30 - 39", "20 - 29", "10 - 19"]
11
+ age = gr.inputs.Dropdown(age_categories, label="Age")
12
+
13
+ height = gr.inputs.Textbox(label = "Height (cm)")
14
+ weight = gr.inputs.Textbox(label = "Weight (kg)")
15
+
16
+ diabetes_categories = ["Yes", "No"]
17
+ diabetes = gr.inputs.Dropdown(diabetes_categories, label="Diabetes")
18
+
19
+ simvastatin_categories = ["Yes", "No"]
20
+ simvastatin = gr.inputs.Dropdown(simvastatin_categories, label="Simvastatin (Zocor)")
21
+
22
+ amiodarone_categories = ["Yes", "No"]
23
+ amiodarone = gr.inputs.Dropdown(amiodarone_categories, label="Amiodarone (Cordarone)")
24
+
25
+ target_inr = gr.inputs.Textbox(label = "Target INR (mg/week)")
26
+ inr = gr.inputs.Textbox(label = "INR on Reported Therapeutic Dose of Warfarin")
27
+
28
+ cyp2c9_genotypes_categories = ["*1/*1", "*1/*3", "*1/*2", "*2/*2", "*1/*5", "*2/*3", "*3/*3"]
29
+ cyp2c9_genotypes = gr.inputs.Dropdown(cyp2c9_genotypes_categories, label = "Cyp2C9 genotypes")
30
+
31
+ vk0rc1_genotype_categories = ["A/G", "G/G", "A/A"]
32
+ vk0rc1_genotype = gr.inputs.Dropdown(vk0rc1_genotype_categories, label = "VKORC1 genotype: -1639 G>A (3673); chr16:31015190; rs9923231; C/T")
33
+
34
+ model_selection = gr.inputs.Dropdown(["Linear Regression (Regression)", "Ridge Regression (Regression)", "Random Forest (Regression)", "Neural Network (Regression)", "K-Nearest Neighbors (Classification)", "Logistic Regression (Classification)", "Random Forest (Classification)"], label="Machine Learning Model")
35
+
36
+ warfarin_dose = gr.outputs.Textbox(label = "Warfarin Dose")
37
+
38
+ linear_model = pickle.load(open('linear_model_regression.pkl', 'rb'))
39
+ ridge_model = pickle.load(open('ridge_model_regression.pkl', 'rb'))
40
+ forest_mode = pickle.load(open('forest_model_regression.pkl', 'rb'))
41
+ ann_model = pickle.load(open('ann_model_regression.pkl', 'rb'))
42
+ knn_model_clf = pickle.load(open('knn_model_classification.pkl', 'rb'))
43
+ logistic_model_clf = pickle.load(open('logistic_model_classification.pkl', 'rb'))
44
+ random_forest_model_clf = pickle.load(open('random_forest_model_classification.pkl', 'rb'))
45
+
46
+ def predict_warfarin_dose(gender, race, age, height, weight, diabetes, simvastatin, amiodarone, target_inr, inr, cyp2c9_genotypes, vk0rc1_genotyp, model_selection):
47
+ new_instance = [gender_categories.index(gender), race_categories.index(race), age_categories.index(age), height, weight, diabetes_categories.index(diabetes), simvastatin_categories.index(simvastatin), amiodarone_categories.index(amiodarone), target_inr, inr, cyp2c9_genotypes_categories.index(cyp2c9_genotypes), vk0rc1_genotype_categories.index(vk0rc1_genotype)]
48
+ if model_selection == "Linear Regression (Regression)":
49
+ prediction = linear_model.predict(new_instance)
50
+ elif model_selection == "Ridge Regression (Regression)":
51
+ prediction = ridge_model.predict(new_instance)
52
+ elif model_selection == "Random Forest (Regression)":
53
+ prediction = forest_mode.predict(new_instance)
54
+ elif model_selection == "Neural Network (Regression)":
55
+ prediction = ann_model.predict(new_instance)
56
+ elif model_selection == "K-Nearest Neighbors (Classification)":
57
+ prediction = knn_model_clf.predict(new_instance)
58
+ elif model_selection == "Logistic Regression (Classification)":
59
+ prediction = logistic_model_clf.predict(new_instance)
60
+ else:
61
+ prediction = random_forest_model_clf.predict(new_instance)
62
+ return prediction
63
+
64
+ interface = gr.Interface(fn=predict_warfarin_dose, inputs=[gender, race, age, height, weight, diabetes, simvastatin, amiodarone, target_inr, inr, cyp2c9_genotypes, vk0rc1_genotype, model_selection], outputs=warfarin_dose)
65
+ interface.launch()
forest_model_regression.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:891ff8b9cb3296fda99ed35d3a6f8c0132c3fe7135e1d219594d5f3b4f3d97d1
3
+ size 2156240
knn_model_classification.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49397b66ebe3533e97e212f8a705c4f6a87843d7124eaa2c95052c93f897e006
3
+ size 65667
linear_model_regression.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05e975a4d81074768a09ff467be92a03b6b21d233849f213fd191c5e64755f9d
3
+ size 651
logistic_model_classification.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c2f67d257015e2c115b24df5f93087c34de7f0e63f77ad72951e04429ee33ad
3
+ size 3262482
random_forest_model_classification.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c2f67d257015e2c115b24df5f93087c34de7f0e63f77ad72951e04429ee33ad
3
+ size 3262482
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pickle5
ridge_model_regression.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f96a4d0a404038142dcd183706c7f4140cca46e9f758ba869ffa5539183ff6ef
3
+ size 553