Update app.py
Browse files
app.py
CHANGED
@@ -13,10 +13,10 @@ loaded_model = pickle.load(open("classroom_xgb.pkl", 'rb'))
|
|
13 |
explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
|
14 |
|
15 |
# Create the main function for server
|
16 |
-
def main_func(Target,
|
17 |
-
new_row = pd.DataFrame.from_dict({'Target':Target,'
|
18 |
-
'
|
19 |
-
'Course':Course,'
|
20 |
orient = 'index').transpose()
|
21 |
|
22 |
prob = loaded_model.predict_proba(new_row)
|
@@ -49,12 +49,13 @@ with gr.Blocks(title=title) as demo:
|
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
Target = gr.Number(label="Target Score", value=40)
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
58 |
submit_btn = gr.Button("Analyze")
|
59 |
|
60 |
with gr.Column(visible=True) as output_col:
|
@@ -63,11 +64,12 @@ with gr.Blocks(title=title) as demo:
|
|
63 |
|
64 |
submit_btn.click(
|
65 |
main_func,
|
66 |
-
[Target,
|
67 |
[label,local_plot], api_name="Graduation_Predictor"
|
68 |
)
|
69 |
|
70 |
gr.Markdown("### Click on any of the examples below to see how it works:")
|
71 |
-
gr.Examples([['Graduate',119.6,13.000000,122.0,9773,5,18], [Target,
|
|
|
72 |
|
73 |
demo.launch()
|
|
|
13 |
explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
|
14 |
|
15 |
# Create the main function for server
|
16 |
+
def main_func(Target, Admission_Grade, 2nd_Sem_Grades, Previous_Qualification_Grade, 1st_Sem_Grades, Course, 2nd_Sem_Units_Approved, Age_at_Enrollment):
|
17 |
+
new_row = pd.DataFrame.from_dict({'Target':Target,'Admission_Grade':Admission_Grade,
|
18 |
+
'2nd_Sem_Grades':2nd_Sem_Grades,'Previous_Qualification_Grade':Previous_Qualification_Grade,'1st_Sem_Grades':1st_Sem_Grades,
|
19 |
+
'Course':Course,'2nd_Sem_Units_Approved':2nd_Sem_Units_Approved,'Age_at_Enrollment':Age_at_Enrollment},
|
20 |
orient = 'index').transpose()
|
21 |
|
22 |
prob = loaded_model.predict_proba(new_row)
|
|
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
Target = gr.Number(label="Target Score", value=40)
|
52 |
+
Admission_Grade = gr.Slider(label="AdmissionGrade Score", minimum=0, maximum=1, value=1, step=1)
|
53 |
+
2nd_Sem_Grades = gr.Slider(label="PreviousQualificationGrade Score", minimum=1, maximum=5, value=4, step=1)
|
54 |
+
Previous_Qualification_Grade = gr.Slider(label="CurricularUnits1stSemGrade Score", minimum=1, maximum=5, value=4, step=1)
|
55 |
+
1st_Sem_Grades = gr.Slider(label="Course Score", minimum=1, maximum=5, value=4, step=1)
|
56 |
+
Course = gr.Slider(label="Course", minimum=1, maximum=5, value=4, step=1)
|
57 |
+
2nd_Sem_Units_Approved = gr.Slider(label="2nd_Sem_Units_Approved", minimum=1, maximum=5, value=4, step=1)
|
58 |
+
Age_at_Enrollment = gr.Slider(label="AgeAtEnrollment Score", minimum=1, maximum=5, value=4, step=1)
|
59 |
submit_btn = gr.Button("Analyze")
|
60 |
|
61 |
with gr.Column(visible=True) as output_col:
|
|
|
64 |
|
65 |
submit_btn.click(
|
66 |
main_func,
|
67 |
+
[Target, Admission_Grade, 2nd_Sem_Grades, Previous_Qualification_Grade, 1st_Sem_Grades, Course, 2nd_Sem_Units_Approved, Age_at_Enrollment],
|
68 |
[label,local_plot], api_name="Graduation_Predictor"
|
69 |
)
|
70 |
|
71 |
gr.Markdown("### Click on any of the examples below to see how it works:")
|
72 |
+
gr.Examples([['Graduate',119.6,13.000000,122.0,9773,5,18], [Target, Admission_Grade, 2nd_Sem_Grades, Previous_Qualification_Grade, 1st_Sem_Grades, Course, 2nd_Sem_Units_Approved, Age_at_Enrollment]
|
73 |
+
, [label,local_plot], main_func, cache_examples=True)
|
74 |
|
75 |
demo.launch()
|