Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ VKORC1_genotype = gr.Dropdown(choices=list(VKORC1_genotype_dict.keys()), label="
|
|
38 |
model = gr.Dropdown(choices=["Linear Regression", "Ridge Regression", "Decision Tree", "KNN","ANN", "Random Forest"], label="Model")
|
39 |
|
40 |
|
41 |
-
#
|
42 |
def multi_inputs(age, gender, race, weight, height, diabetes, simvastatin, amiodarone, INR_reported, cyp2C9_genotypes, VKORC1_genotype, model, dose):
|
43 |
# Load the appropriate model based on the selected model
|
44 |
if model == 'Linear Regression':
|
@@ -57,6 +57,7 @@ def multi_inputs(age, gender, race, weight, height, diabetes, simvastatin, amiod
|
|
57 |
# Map categorical variables to their encoded values
|
58 |
age_encoded = age_dict.get(age)
|
59 |
race_encoded = race_dict.get(race)
|
|
|
60 |
diabetes_encoded = diabetes_dict.get(diabetes)
|
61 |
simvastatin_encoded = simvastatin_dict.get(simvastatin)
|
62 |
amiodarone_encoded = amiodarone_dict.get(amiodarone)
|
@@ -64,16 +65,15 @@ def multi_inputs(age, gender, race, weight, height, diabetes, simvastatin, amiod
|
|
64 |
VKORC1_genotype_encoded = VKORC1_genotype_dict.get(VKORC1_genotype)
|
65 |
|
66 |
# Transform input data
|
67 |
-
inputs = [age_encoded,
|
68 |
-
inputs[1] = 0 if inputs[1] == "male" else 1 # Encoding gender to 0 for male and 1 for female
|
69 |
-
inputs = scaler.transform([inputs])
|
70 |
|
71 |
# Predict therapeutic dose of warfarin
|
72 |
-
input_data = np.array([inputs
|
73 |
output = model.predict(input_data)
|
74 |
|
75 |
return output
|
76 |
|
|
|
77 |
# Create the Gradio interface
|
78 |
inputs = [age, gender, race, weight, height, diabetes, simvastatin, amiodarone, INR_reported, cyp2C9_genotypes, VKORC1_genotype, model]
|
79 |
outputs = gr.Textbox(label="Predicted Therapeutic Dose of Warfarin")
|
|
|
38 |
model = gr.Dropdown(choices=["Linear Regression", "Ridge Regression", "Decision Tree", "KNN","ANN", "Random Forest"], label="Model")
|
39 |
|
40 |
|
41 |
+
# Modify the gender encoding and ensure all categorical variables are properly encoded
|
42 |
def multi_inputs(age, gender, race, weight, height, diabetes, simvastatin, amiodarone, INR_reported, cyp2C9_genotypes, VKORC1_genotype, model, dose):
|
43 |
# Load the appropriate model based on the selected model
|
44 |
if model == 'Linear Regression':
|
|
|
57 |
# Map categorical variables to their encoded values
|
58 |
age_encoded = age_dict.get(age)
|
59 |
race_encoded = race_dict.get(race)
|
60 |
+
gender_encoded = 0 if gender == "male" else 1 # Encoding gender
|
61 |
diabetes_encoded = diabetes_dict.get(diabetes)
|
62 |
simvastatin_encoded = simvastatin_dict.get(simvastatin)
|
63 |
amiodarone_encoded = amiodarone_dict.get(amiodarone)
|
|
|
65 |
VKORC1_genotype_encoded = VKORC1_genotype_dict.get(VKORC1_genotype)
|
66 |
|
67 |
# Transform input data
|
68 |
+
inputs = [age_encoded, gender_encoded, race_encoded, weight, height, diabetes_encoded, simvastatin_encoded, amiodarone_encoded, INR_reported, cyp2C9_genotypes_encoded, VKORC1_genotype_encoded]
|
|
|
|
|
69 |
|
70 |
# Predict therapeutic dose of warfarin
|
71 |
+
input_data = np.array([inputs])
|
72 |
output = model.predict(input_data)
|
73 |
|
74 |
return output
|
75 |
|
76 |
+
|
77 |
# Create the Gradio interface
|
78 |
inputs = [age, gender, race, weight, height, diabetes, simvastatin, amiodarone, INR_reported, cyp2C9_genotypes, VKORC1_genotype, model]
|
79 |
outputs = gr.Textbox(label="Predicted Therapeutic Dose of Warfarin")
|