Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +58 -37
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,61 @@
|
|
| 1 |
-
import altair as alt
|
| 2 |
import numpy as np
|
| 3 |
-
import
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
.
|
| 35 |
-
.
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
+
import joblib
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
+
# Load the trained model
|
| 6 |
+
import os
|
| 7 |
+
model_path = os.path.join(os.path.dirname(__file__), "student_performance_model.h5")
|
| 8 |
+
model = joblib.load(model_path)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def predict_marks(Hours_studied, Previous_Score, Extracurriculum_Activivities, Sleep_Hours, Sample_Question):
|
| 12 |
+
"Predict the student marks based on the input data"
|
| 13 |
+
input_data = np.array([[Hours_studied, Previous_Score, Extracurriculum_Activivities, Sleep_Hours, Sample_Question]])
|
| 14 |
+
prediction = model.predict(input_data)
|
| 15 |
+
prediction = round(float(prediction), 2)
|
| 16 |
+
|
| 17 |
+
# Ensure the prediction does not exceed 100
|
| 18 |
+
if prediction > 100:
|
| 19 |
+
prediction = 100
|
| 20 |
+
|
| 21 |
+
return prediction
|
| 22 |
+
|
| 23 |
+
def main():
|
| 24 |
+
# Sidebar Welcome Note with Emojis
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
st.title("๐ Student Marks Predictor ๐")
|
| 28 |
+
|
| 29 |
+
# Input data
|
| 30 |
+
name = st.text_input("๐ค Enter your name")
|
| 31 |
+
Hours_studied = st.number_input("๐ Hours you studied", min_value=0.0, max_value=20.0, value=0.0)
|
| 32 |
+
Previous_Score = st.number_input("๐ Previous exam score", min_value=0, max_value=100, value=0)
|
| 33 |
+
Extracurriculum_Activivities = st.number_input("๐ญ Extracurricular activities done", min_value=0, max_value=10, value=0)
|
| 34 |
+
Sleep_Hours = st.number_input("๐ด Hours you slept", min_value=0.0, max_value=12.0, value=0.0)
|
| 35 |
+
Sample_Question = st.number_input("โ๏ธ Sample questions practiced", min_value=0, max_value=50, value=0)
|
| 36 |
+
|
| 37 |
+
# Sidebar interaction
|
| 38 |
+
st.sidebar.title(f" # Hey {name}")
|
| 39 |
+
st.sidebar.title(f"๐Welcome to your Marks Predictor! ๐")
|
| 40 |
+
st.sidebar.write("""
|
| 41 |
+
Hey there! Ready to see what your future marks might be? ๐
|
| 42 |
+
Remember, I'm here to help you succeed! ๐ช
|
| 43 |
+
""")
|
| 44 |
+
|
| 45 |
+
st.sidebar.markdown("---")
|
| 46 |
+
|
| 47 |
+
# Predict button
|
| 48 |
+
if st.button("๐ฎ Predict Your Marks"):
|
| 49 |
+
prediction = predict_marks(Hours_studied, Previous_Score, Extracurriculum_Activivities, Sleep_Hours, Sample_Question)
|
| 50 |
+
|
| 51 |
+
# Display the predictions
|
| 52 |
+
if prediction >= 90:
|
| 53 |
+
st.balloons()
|
| 54 |
+
st.success(f"๐ **{name}, amazing!** You're on track to score {prediction} marks! Keep up the excellent work! ๐ช")
|
| 55 |
+
elif prediction >= 35:
|
| 56 |
+
st.warning(f"โ ๏ธ **{name}, not bad!** You're likely to pass with {prediction} marks, but there's room to aim higher! ๐")
|
| 57 |
+
else:
|
| 58 |
+
st.error(f"๐จ **{name}, oh no!** You might score below 35 marks. Consider putting in some more effort! ๐")
|
| 59 |
+
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
+
main()
|