Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pickle | |
| import pandas as pd | |
| import numpy as np | |
| # Load the trained model | |
| model = pickle.load(open('model.sav', 'rb')) | |
| # Set page config and style | |
| st.set_page_config(page_title='Student Placement Prediction', page_icon=':mortar_board:') | |
| st.markdown( | |
| """ | |
| <style> | |
| .main { | |
| max-width: 800px; | |
| margin: 0 auto; | |
| } | |
| .title { | |
| text-align: center; | |
| font-size: 32px; | |
| margin-top: 20px; | |
| margin-bottom: 30px; | |
| } | |
| .header { | |
| font-size: 24px; | |
| margin-top: 20px; | |
| margin-bottom: 10px; | |
| } | |
| .subheader { | |
| font-size: 20px; | |
| margin-top: 10px; | |
| margin-bottom: 10px; | |
| } | |
| .prediction { | |
| text-align: center; | |
| font-size: 24px; | |
| font-weight: bold; | |
| margin-top: 30px; | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| st.title('Student Placement Prediction') | |
| st.markdown('<div class="main">', unsafe_allow_html=True) | |
| st.sidebar.header('Student Data') | |
| # Function to get user input | |
| def get_user_input(): | |
| gender = st.sidebar.selectbox('Gender', ['Male', 'Female']) | |
| ssc_p = st.sidebar.slider('SSC Percentage', 0.0, 100.0, 67.0) | |
| ssc_b = st.sidebar.selectbox('SSC Board', ['Central', 'Others']) | |
| hsc_p = st.sidebar.slider('HSC Percentage', 0.0, 100.0, 91.0) | |
| hsc_b = st.sidebar.selectbox('HSC Board', ['Central', 'Others']) | |
| hsc_s = st.sidebar.selectbox('HSC Stream', ['Science', 'Commerce', 'Arts']) | |
| degree_p = st.sidebar.slider('Degree Percentage', 0.0, 100.0, 58.0) | |
| degree_t = st.sidebar.selectbox('Degree Field', ['Sci&Tech', 'Comm&Mgmt', 'Others']) | |
| workex = st.sidebar.selectbox('Work Experience', ['No', 'Yes']) | |
| etest_p = st.sidebar.slider('Employability Test Percentage', 0.0, 100.0, 55.0) | |
| specialisation = st.sidebar.selectbox('MBA Specialization', ['Mkt&HR', 'Mkt&Fin']) | |
| mba_p = st.sidebar.slider('MBA Percentage', 0.0, 100.0, 58.8) | |
| user_data = { | |
| 'gender': 0 if gender == 'Male' else 1, | |
| 'ssc_p': ssc_p, | |
| 'ssc_b': 0 if ssc_b == 'Central' else 1, | |
| 'hsc_p': hsc_p, | |
| 'hsc_b': 0 if hsc_b == 'Central' else 1, | |
| 'hsc_s': 0 if hsc_s == 'Science' else 1 if hsc_s == 'Commerce' else 2, | |
| 'degree_p': degree_p, | |
| 'degree_t': 0 if degree_t == 'Sci&Tech' else 1 if degree_t == 'Comm&Mgmt' else 2, | |
| 'workex': 0 if workex == 'No' else 1, | |
| 'etest_p': etest_p, | |
| 'specialisation': 0 if specialisation == 'Mkt&HR' else 1, | |
| 'mba_p': mba_p | |
| } | |
| user_data_df = pd.DataFrame(user_data, index=[0]) | |
| return user_data_df | |
| user_data_df = get_user_input() | |
| st.markdown('<div class="header">Student Data</div>', unsafe_allow_html=True) | |
| st.write(user_data_df) | |
| if st.button('Predict'): | |
| prediction = model.predict(user_data_df) | |
| placement = "Placed" if prediction[0] == 1 else "Not Placed" | |
| prediction_text = f"Placement Prediction: <span style='color: green;'>{placement}</span>" if placement == "Placed" else f"Placement Prediction: <span style='color: red;'>{placement}</span>" | |
| st.markdown(f"<div class='prediction'>{prediction_text}</div>", unsafe_allow_html=True) | |
| st.markdown('</div>', unsafe_allow_html=True) | |