Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
model = joblib.load('model.pkl')
|
| 6 |
+
st.title("🤯 Student Result Predictor")
|
| 7 |
+
|
| 8 |
+
# take the input
|
| 9 |
+
gender = st.selectbox('Gender', ['Female','Male'])
|
| 10 |
+
ethinic = st.selectbox('ethinic',['Group A','Group B','Group C','Group D', 'Group E'])
|
| 11 |
+
parent_education = st.selectbox('parent education',["bachelor's degree","Associate's Degree","some college","high school","master's degree","some high school"])
|
| 12 |
+
lunch = st.selectbox('Lunch', ['standard', 'free/reduced'])
|
| 13 |
+
test_preparation = st.selectbox('Test Preparation', ['Completed','None'])
|
| 14 |
+
math_score = st.number_input('Math Score',0, 100)
|
| 15 |
+
Reading_score = st.number_input('Reading Score',0, 100)
|
| 16 |
+
Writing_score = st.number_input('Writing Score',0, 100)
|
| 17 |
+
|
| 18 |
+
# ethinic case
|
| 19 |
+
group_A = group_B = group_C = group_D = group_E = 0
|
| 20 |
+
if ethinic == 'Group B':
|
| 21 |
+
group_B = 1
|
| 22 |
+
elif ethinic == 'Group C':
|
| 23 |
+
group_C = 1
|
| 24 |
+
elif ethinic == 'Group D':
|
| 25 |
+
group_D = 1
|
| 26 |
+
else:
|
| 27 |
+
group_E = 1
|
| 28 |
+
|
| 29 |
+
# parent education case,
|
| 30 |
+
associate = bachelor = highschool = master = some_college = some_school = 0
|
| 31 |
+
if parent_education == "bachelor's degree":
|
| 32 |
+
bachelor = 1
|
| 33 |
+
elif parent_education == "some college":
|
| 34 |
+
some_college = 1
|
| 35 |
+
elif parent_education == "high school":
|
| 36 |
+
highschool = 1
|
| 37 |
+
elif parent_education == "master's degree":
|
| 38 |
+
master = 1
|
| 39 |
+
elif parent_education == "associate's degree":
|
| 40 |
+
associate = 1
|
| 41 |
+
else:
|
| 42 |
+
some_school = 1
|
| 43 |
+
|
| 44 |
+
# gender case
|
| 45 |
+
if gender == 'male':
|
| 46 |
+
gender = 1
|
| 47 |
+
else:
|
| 48 |
+
gender = 0
|
| 49 |
+
|
| 50 |
+
# lunch case
|
| 51 |
+
if lunch == 'standard':
|
| 52 |
+
lunch = 1
|
| 53 |
+
else:
|
| 54 |
+
lunch = 0
|
| 55 |
+
|
| 56 |
+
# test Preparation
|
| 57 |
+
if test_preparation == 'None':
|
| 58 |
+
test_preparation = 1
|
| 59 |
+
else:
|
| 60 |
+
test_preparation = 0
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
input_data = pd.DataFrame({
|
| 64 |
+
'math score':[math_score],
|
| 65 |
+
'reading score':[Reading_score],
|
| 66 |
+
'writing score':[Writing_score],
|
| 67 |
+
'group_A':[group_A],
|
| 68 |
+
'group_B':[group_B],
|
| 69 |
+
'group_C':[group_C],
|
| 70 |
+
'group_D':[group_D],
|
| 71 |
+
'group_E':[group_E],
|
| 72 |
+
'associate':[associate],
|
| 73 |
+
'bachelor':[bachelor],
|
| 74 |
+
'high_school':[highschool],
|
| 75 |
+
'master':[master],
|
| 76 |
+
'some_college':[some_college],
|
| 77 |
+
'some_school':[some_school],
|
| 78 |
+
'gender':[gender],
|
| 79 |
+
'lunch_standard':[lunch],
|
| 80 |
+
'preparation':[test_preparation]
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
# predict output
|
| 85 |
+
if st.button("Predict"):
|
| 86 |
+
prediction = model.predict(input_data)[0]
|
| 87 |
+
st.success("🥳 Pass" if prediction == 1 else "⛔ Fail,Try Hard")
|