Commit
·
3291fa0
1
Parent(s):
ac3a0cf
added prediction function
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from model import SmokerModel
|
|
|
|
| 3 |
|
| 4 |
MODEL = SmokerModel("ensemble_softvoting_model.joblib","min_max_scaler.joblib")
|
| 5 |
|
|
@@ -16,7 +17,22 @@ def predict(
|
|
| 16 |
'''
|
| 17 |
Predict the label for the data inputed
|
| 18 |
'''
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
def load_interface():
|
| 22 |
'''
|
|
@@ -64,7 +80,7 @@ def load_interface():
|
|
| 64 |
clear_btn = gr.Button("Clear")
|
| 65 |
|
| 66 |
#set label txt box
|
| 67 |
-
#TODO: change to gr.
|
| 68 |
smoker_label = gr.Label(label="Predicted Label")
|
| 69 |
|
| 70 |
#set event listeners
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from model import SmokerModel
|
| 3 |
+
import numpy as np
|
| 4 |
|
| 5 |
MODEL = SmokerModel("ensemble_softvoting_model.joblib","min_max_scaler.joblib")
|
| 6 |
|
|
|
|
| 17 |
'''
|
| 18 |
Predict the label for the data inputed
|
| 19 |
'''
|
| 20 |
+
# Combine the input data into a NumPy array
|
| 21 |
+
input_array = np.array([
|
| 22 |
+
age, height, weight,
|
| 23 |
+
waist, eye_L, eye_R,
|
| 24 |
+
hear_L, hear_R, systolic,
|
| 25 |
+
relaxation, fasting_blood_sugar, cholesterol,
|
| 26 |
+
triglyceride, HDL, LDL,
|
| 27 |
+
hemoglobin, urine_protein,
|
| 28 |
+
serum_creatinine, AST, ALT,
|
| 29 |
+
Gtp, dental_caries
|
| 30 |
+
])
|
| 31 |
+
|
| 32 |
+
#predict
|
| 33 |
+
label = MODEL.predict(input_array)
|
| 34 |
+
|
| 35 |
+
return label
|
| 36 |
|
| 37 |
def load_interface():
|
| 38 |
'''
|
|
|
|
| 80 |
clear_btn = gr.Button("Clear")
|
| 81 |
|
| 82 |
#set label txt box
|
| 83 |
+
#TODO: change back to gr.Textbox()?
|
| 84 |
smoker_label = gr.Label(label="Predicted Label")
|
| 85 |
|
| 86 |
#set event listeners
|