mohammedriza-rahman's picture
Upload 3 files
28528dc verified
## importing the necessary libraries
import streamlit as st
import joblib
import numpy as np
## to save the model
#joblib.dump(mode_name,"the path where you want to save the model")
## to load the model
model = joblib.load("student_performance_model.h5")
def predict_marks(Hours_studied,Previous_score , Extracurriculum_activities, sleep_hours , sample_question):
#predict the students marks based on the input data
input_data = np.array([[Hours_studied,Previous_score , Extracurriculum_activities, sleep_hours , sample_question]])
prediction = model.predict(input_data)
prediction = round(float(prediction),2)
## ensure the prediction does not exceed 100
if prediction > 100:
prediction = 100
return prediction
def main():
st.title("Student Performance Prediction")
## input data
name = st.text_input("enter your name")
Hours_studied = st.number_input("number of hours you studied",min_value = 0.0 ,max_value=18.0,value = 0.0)
Previous_score = st.number_input("enter your previous score",min_value = 0.0 ,max_value=100.0,value = 0.0)
Extracurriculum_Activites = st.number_input("no.of extracurricular activities done",min_value = 0.0,max_value = 10.0 ,value= 0.0 )
sleep_hours = st.number_input ("Hours you slept", min_value =0.0,max_value = 12.0, value = 0.0)
sample_questions = st.number_input ("number of sample paper you solved", min_value =0.0,max_value = 20.0, value = 0.0)
## sidebar interaction
st.sidebar.title(f"# hey {name}")
st.sidebar.title(f"Welcome to your Marks predictor!...")
## prediction button
if st.button("Predict your Marks"):
prediction = predict_marks(Hours_studied,Previous_score , Extracurriculum_Activites,sleep_hours ,sample_questions)
## display the prediction
if prediction >=90:
st.balloons()
st.success(f"congrats {name} you are on a track to score {prediction} marks!.kepp it up ")
elif prediction>=35:
st.warning(f"hey {name} you are on a track to score {prediction} marks. but there's a room to aim higher!")
else:
st.error(f"{name} , oh no you might fail the exam as you will be getting {prediction}, work hard and conncentrate on your studies")
if __name__ =="__main__":
main()