Spaces:
Runtime error
Runtime error
upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
import pandas as pd
|
| 4 |
+
#st.title('Placement Prediction app')
|
| 5 |
+
# st.markdown("""
|
| 6 |
+
# <style>
|
| 7 |
+
# .title {
|
| 8 |
+
# font-size: 50px;
|
| 9 |
+
# font-weight: bold;
|
| 10 |
+
# color: #4CAF50;
|
| 11 |
+
# text-align: center;
|
| 12 |
+
# font-family: 'Courier New', Courier, monospace;
|
| 13 |
+
# }
|
| 14 |
+
# </style>
|
| 15 |
+
# """, unsafe_allow_html=True)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# st.title('Placement Prediction App')
|
| 19 |
+
# st.subheader('Predicting student placement outcomes using machine learning')
|
| 20 |
+
# st.markdown('This app uses historical data to predict whether a student will be placed in a company based on their profile.')
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
model = joblib.load('/Users/nishthapandey/Desktop/PlacementPrediction/model_campus_placement_rf.joblib')
|
| 24 |
+
st.success("Model loaded successfully!")
|
| 25 |
+
except Exception as e:
|
| 26 |
+
st.error(f"Error loading model: {e}")
|
| 27 |
+
st.stop()
|
| 28 |
+
model = joblib.load(open('/Users/nishthapandey/Desktop/PlacementPrediction/model_campus_placement_rf.joblib','rb'))
|
| 29 |
+
|
| 30 |
+
def predict_placement(data):
|
| 31 |
+
# Preprocess the data
|
| 32 |
+
new_data = pd.DataFrame(data)
|
| 33 |
+
|
| 34 |
+
# Make prediction
|
| 35 |
+
prediction = model.predict(new_data)[0]
|
| 36 |
+
prob = model.predict_proba(new_data)[0][1]
|
| 37 |
+
|
| 38 |
+
return prediction, prob
|
| 39 |
+
|
| 40 |
+
def main():
|
| 41 |
+
st.header('Placement Prediciton App')
|
| 42 |
+
|
| 43 |
+
gender = st.radio('Gender', ['Male', 'Female'])
|
| 44 |
+
ssc_p = st.number_input('Secondary School Percentage', min_value=0.0, max_value=100.0, value=50.0, step=0.1)
|
| 45 |
+
ssc_b = st.radio('Board of Education (SSC)', ['Central', 'Others'])
|
| 46 |
+
hsc_p = st.number_input('Higher Secondary Percentage', min_value=0.0, max_value=100.0, value=50.0, step=0.1)
|
| 47 |
+
hsc_b = st.radio('Board of Education (HSC)', ['Central', 'Others'])
|
| 48 |
+
degree_p = st.number_input('UG Percentage', min_value=0.0, max_value=100.0, value=50.0, step=0.1)
|
| 49 |
+
branch = st.selectbox('Branch of Study', ['CSE', 'ECE/EN', 'Others'])
|
| 50 |
+
workex = st.radio('Work Experience', ['Yes', 'No'])
|
| 51 |
+
certifications = st.number_input('Number of Certifications', min_value=0, max_value=10, value=0)
|
| 52 |
+
etest_p = st.number_input('Employability Percentage', min_value=0.0, max_value=100.0, value=50.0, step=0.1)
|
| 53 |
+
backlogs = st.number_input('Number of Backlogs', min_value=0, max_value=10, value=0)
|
| 54 |
+
|
| 55 |
+
if st.button('predict'):
|
| 56 |
+
new_data = {
|
| 57 |
+
'gender': 0 if gender == "Male" else 1,
|
| 58 |
+
'ssc_p': ssc_p,
|
| 59 |
+
'ssc_b': 1 if ssc_b == "Central" else 0,
|
| 60 |
+
'hsc_p': hsc_p,
|
| 61 |
+
'hsc_b': 1 if hsc_b == "Central" else 0,
|
| 62 |
+
'degree_p': degree_p,
|
| 63 |
+
'Branch': 2 if branch == "ECE/EN" else 1 if branch == "CSE" else 0,
|
| 64 |
+
'Workex': 1 if workex == "Yes" else 0,
|
| 65 |
+
'Certifications': certifications,
|
| 66 |
+
'etest_p': etest_p,
|
| 67 |
+
'Backlogs': backlogs,
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
prediction, probability = predict_placement(new_data)
|
| 71 |
+
st.write(f'Percentage of getting placed: {probability*100:.2f}%')
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
if __name__=='__main__':
|
| 75 |
+
main()
|
| 76 |
+
|