Spaces:
Sleeping
Sleeping
File size: 1,588 Bytes
3ea8af4 |
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 |
import streamlit as st
import pickle
from sklearn.ensemble import RandomForestRegressor
import numpy as np
# Load the saved model
with open('rf_model.pkl', 'rb') as file:
model = pickle.load(file)
# Define the function to make predictions
def make_prediction(model, input_data):
prediction = model.predict(input_data)
return prediction
# Create the Streamlit app
def main():
# Set page title and configure layout
st.set_page_config(page_title="Exam Score Prediction", layout="wide")
# Add a title and description
st.title("Exam Score Prediction")
st.markdown(
"This app predicts exam scores based on input features such as level, course units, attendance, mid-semester score, and assignments."
)
# Create input fields
col1, col2 = st.columns(2)
with col1:
level = st.number_input("Level", min_value=200, max_value=400, step=1)
course_units = st.number_input("Course Units", min_value=1, max_value=4, step=1)
with col2:
attendance = st.slider("Attendance", min_value=1, max_value=10, step=1)
mid_semester = st.slider("Mid Semester Score", min_value=1, max_value=20, step=1)
assignments = st.slider("Assignments", min_value=1, max_value=10, step=1)
# Create input data
input_data = np.array([[level, course_units, attendance, mid_semester, assignments]])
# Make prediction
if st.button("Predict Exam Score"):
prediction = make_prediction(model, input_data)
st.write(f"Predicted Exam Score: {prediction[0]:.2f}")
if __name__ == '__main__':
main()
|