|
import pandas as pd |
|
import numpy as np |
|
from sklearn.model_selection import train_test_split |
|
from sklearn.ensemble import RandomForestClassifier |
|
from sklearn.pipeline import Pipeline |
|
from sklearn.compose import ColumnTransformer |
|
from sklearn.preprocessing import StandardScaler, OneHotEncoder |
|
from sklearn.metrics import accuracy_score |
|
import streamlit as st |
|
|
|
|
|
data = pd.read_csv('dataset.csv') |
|
|
|
|
|
|
|
X = data.drop('PlacedOrNot', axis=1) |
|
y = data['PlacedOrNot'] |
|
|
|
|
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
|
|
|
|
|
|
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
|
|
|
preprocessor = ColumnTransformer( |
|
transformers=[ |
|
('num', StandardScaler(), ['internships', 'cgpa', 'history_of_backlogs']), |
|
('cat', OneHotEncoder(), ['gender', 'stream']) |
|
]) |
|
|
|
|
|
pipeline = Pipeline([ |
|
('preprocessor', preprocessor), |
|
('classifier', RandomForestClassifier(random_state=42)) |
|
]) |
|
|
|
|
|
pipeline.fit(X_train, y_train) |
|
|
|
|
|
y_pred = pipeline.predict(X_test) |
|
|
|
|
|
accuracy = accuracy_score(y_test, y_pred) |
|
print('Accuracy:', accuracy) |
|
|
|
joblib.dump(pipeline, 'student_placement_model.joblib') |
|
|
|
|
|
|
|
st.title('Student Job Placement Prediction') |
|
|
|
|
|
st.markdown('Please enter the following information:') |
|
internships = st.number_input('Number of Internships', min_value=0, max_value=10) |
|
cgpa = st.number_input('CGPA', min_value=0.0, max_value=10.0) |
|
history_of_backlogs = st.number_input('History of Backlogs', min_value=0, max_value=10) |
|
gender = st.selectbox('Gender', ('Male', 'Female')) |
|
stream = st.selectbox('Stream', ('Engineering', 'Science', 'Commerce')) |
|
submit = st.button('Submit') |
|
|
|
|
|
if submit: |
|
|
|
user_data = pd.DataFrame([[internships, cgpa, history_of_backlogs, gender, stream]], |
|
columns=['internships', 'cgpa', 'history_of_backlogs', 'gender', 'stream']) |
|
|
|
prediction = pipeline.predict(user_data) |
|
|
|
if prediction[0] == 1: |
|
st.success('Congratulations! The student is likely to be placed.') |
|
else: |
|
st.warning('Sorry, the student is unlikely to be placed.') |