-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarks_app.py
93 lines (57 loc) · 2.39 KB
/
marks_app.py
1
2
3
4
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 31 16:48:25 2023
@author: ankit
"""
import numpy as np
import pickle
import streamlit as st
# loading the saved model
# model = pickle.load(open("Marks-Prediction-System/trained_model.pkl",'rb'))
model = pickle.load(open("marks-prediction-system/trained_model.pkl",'rb'))
# creating a function for prediction
def marks_prediction(input_data):
# changing data to numpy array
input_data_array = np.asarray(input_data)
# reshape the array as we are predicting for one instance
input_data_reshaped = input_data_array.reshape(1,-1)
temp = np.array(input_data_reshaped, dtype=float)
# Main function
result = model.predict(temp)
strr = "Marks Predicted : "
temp = [strr]
temp2 = [result[0][0]]
merged_list = temp + temp2
# Convert the merged list to a string without brackets and commas
merged_str = " ".join(str(item) for item in merged_list)
if result[0]>100:
return 100
elif (result[0] >= 0 and result[0]<=100):
return merged_str
else:
return "Invalid Input "
def main():
# giving a title
#st.title('')
st.markdown("<h1 style='text-align: center; color: red;'>Student Marks Prediction </h1>", unsafe_allow_html=True)
# getting the input data from input user
Hours = st.text_input("Enter the number of hour of actually study (range between 1-13 for correct prediction) ")
# code for prediction
prediction = '' # null string
# creating a button for prediction
if st.button('Predict Test Result'):
prediction = marks_prediction([Hours])
st.success(prediction)
st.markdown("***")
st.markdown("""
About the data to be filled :
Hours : As number of hours of study before exams is positively correlated
with marks obtained by students so more hours of study genrally gives more
marks (exception exists like us 💀) and if you found your marks wrong then
go and BLAME your teacher 🙃
""")
st.write(" \n\n\n\n\n\n")
st.markdown("******")
st.write("Contributor : [Ankit Nainwal](https://github.com/nano-bot01) ")
if __name__ == '__main__':
main()