-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
362 lines (298 loc) · 14.1 KB
/
app.py
File metadata and controls
362 lines (298 loc) · 14.1 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
import streamlit as st
from streamlit_option_menu import option_menu
import pandas as pd
import pickle
from fpdf import FPDF
from PIL import Image
import json
import os
import sklearn
hide_st_style = """
<style>
#MainMenu {visibility : hidden;}
footer {visibility : hidden;}
header {visibility : hidden;}
</style>
"""
# default data
dataframe = pd.read_csv("Datasets/collegePlacementData.csv")
st.set_page_config(
page_title="PLACEMATE",
page_icon="memo",
layout="wide",
initial_sidebar_state="expanded",
menu_items=None
)
#remove all the default streamlit configs here
st.markdown(hide_st_style, unsafe_allow_html=True)
with st.sidebar:
selected = option_menu(
menu_title = "PLACEMATE",
options = ["Home", "Predictions", "Resume Builder", "Bug Report", "Buy Me A Coffee" ,"About Me"],
icons = ["house", "magic", "file-earmark-text", "bug", "cup-hot" ,"person-circle"],
menu_icon= "robot",
default_index = 0,
)
# ========= HOME TAB =========
if selected == "Home":
col1, col2 = st.columns([2, 1])
with col1:
st.title('PLACEMATE :rocket:')
st.subheader("Resume Ready 📄,")
st.subheader("Placement Predicted: 🔮")
st.subheader("Be Job Ready! 👍")
st.divider()
st.header("About :memo:")
st.markdown('''
#####
<span style='font-size: 18px;'>
We are thrilled to introduce you to PLACEMATE, the all-in-one solution for student's
management and recruitment needs
providing a comprehensive platform for predicting placement possibility,
evaluating academic progress and
facilitating career development.
With PLACEMATE, students can efficiently use their data to
track their academic performance, and kick-start their placement preparation.
Join us on this exciting journey as we aim revolutionize
student management and recruitment with PLACEMATE!
</span>
''', unsafe_allow_html=True)
st.text("")
st.markdown("#### <span style='font-size: 24px;'> `Begin Your Placment Journey Now!`</span>", unsafe_allow_html=True)
with col2:
st.image("Images/home_tab_pic.png")
# ========= PREDICTION TAB =======
if selected == "Predictions":
col1, col2 = st.columns([2, 1])
with col1:
st.title("Placement Prediction ⚡")
st.subheader("Provide the inputs below 👇🏻")
st.divider()
st.markdown("##### _Here we have used <span style='color:green'>Random Forest 🤖</span> Machine Learning Algorithm to create our Model to predict the Placement of Students_.", unsafe_allow_html=True)
st.markdown("##### _You just need to provide your data to get started and predict your placement probability using our <span style = 'color:green'>well trained Model right here</span>_.", unsafe_allow_html=True)
with col2:
st.image("Images/prediction_tab_pic.png")
st.divider()
col1, col2 = st.columns(2)
with col1:
# Get user input for Age
age = st.slider('Enter the Age 👇🏻', min_value=18, max_value=27, step=1)
# Get user input for Internships
internships = st.slider('Enter Number of Internships 👇🏻', min_value=0, max_value=10, step=1)
# Get user input for CGPA
cgpa = st.slider('Enter the CGPA 👇🏻', min_value=0.0, max_value=10.0, step=0.1)
predict_button = st.button("Predict the Placement ⚡")
with col2:
# Get user input for Gender
gender = st.selectbox('Choose Gender 🧑🏻🦱👧🏻', ['Male', 'Female'])
# Get user input for Stream
stream = st.selectbox('Choose Stream 🎓', ['Electronics And Communication', 'Computer Science', 'Information Technology', 'Mechanical', 'Electrical', 'Civil'])
# Get user input for Hostel
hostel = 'No'
# Get user input for History of Backlogs
backlogs = st.selectbox("History of Backlogs 👇🏻", ['Yes', "No"])
# encoding the variables here.
#gender
if gender == 'Male': gender_encoded = 1
else: gender_encoded = 0
# stream
if stream == 'Electronics And Communication': stream_encoded = 1
elif stream == 'Computer Science': stream_encoded = 2
elif stream == 'Information Technology': stream_encoded = 3
elif stream == 'Mechanical': stream_encoded = 4
elif stream == 'Electrical': stream_encoded = 5
elif stream == 'Civil': stream_encoded = 6
else: 'Invalid Stream Selected'
# Hostel
hostel_encoded = 1 if hostel == 'Yes' else 0
# backlog history
backlogs_encoded = 1 if backlogs == 'Yes' else 0
# Check if the Predict Placement button is clicked
if predict_button:
# Prepare the user input as a dataframe
user_data = {
'Age': [age],
'Gender': [gender],
'Stream': [stream],
'Internships': [internships],
'CGPA': [cgpa],
'Hostel': [hostel],
'HistoryOfBacklogs': [backlogs]
}
user_df = pd.DataFrame(user_data)
st.divider()
# Make predictions using the loaded model
model = pickle.load(open("Models/Placement_Model", 'rb'))
# Display the prediction result
prediction = model.predict([[age, gender_encoded, stream_encoded, internships, cgpa, hostel_encoded, backlogs_encoded]])
st.markdown("* ## Prediction Result ✅")
if prediction == 1:
st.balloons()
st.markdown("### <span style='color:lightgreen'>Placed 🎉</span>", unsafe_allow_html=True)
else:
st.markdown("### <span style='color:red'>Not Placed 😢</span>", unsafe_allow_html=True)
st.divider()
st.markdown("## Prediction using <span style='color:green'>_Random Forest Classifier_ 🦾</span>", unsafe_allow_html=True)
col1, col2 = st.columns(2)
with col1:
st.markdown("* #### Best Accuracy : <span style='color:green'>_89.63%_ 🦾</span>", unsafe_allow_html=True)
st.markdown("* #### Precision Score : <span style='color:green'>_94.08%_ ⚡</span>", unsafe_allow_html=True)
with col2:
st.markdown("* #### F1 Score : <span style='color:green'>_90.54%_ 🦾</span>", unsafe_allow_html=True)
st.markdown("* #### Recall Score : <span style='color:green'>_87.27%_ ⚡</span>", unsafe_allow_html=True)
# ========= RESUME BUILDER TAB =========
if selected == "Resume Builder":
# Function to generate the resume in PDF format
class PDF(FPDF):
def __init__(self, profile_picture):
super().__init__()
self.profile_picture = profile_picture
self.set_auto_page_break(auto=False, margin=15)
def header(self):
if self.profile_picture:
self.image(self.profile_picture, 150, 23, 50)
self.set_font('Times', 'BU', 16)
self.cell(0, 10, 'CURRICULUM VITAE', 0, 1, 'C')
self.ln(10)
def footer(self):
self.set_y(-15)
def add_personal_info(self, name, address, email, phone):
self.set_font('Times', 'B', 12)
self.cell(0, 10, name, 0, 1, 'L')
self.set_font('Times', '', 12)
self.cell(0, 10, address, 0, 1, 'L')
self.cell(0, 10, email, 0, 1, 'L')
self.cell(0, 10, phone, 0, 1, 'L')
self.ln(10)
def add_section(self, title, body):
self.set_font('Times', 'B', 12)
self.cell(0, 10, title, 0, 1, 'L')
self.set_font('Times', '', 12)
self.multi_cell(0, 10, body)
self.ln(5)
def generate_pdf(name, address, email, phone, objective, education, strengths, projects, profile_picture):
pdf = PDF(profile_picture)
pdf.add_page()
pdf.add_personal_info(name, address, email, phone)
pdf.add_section("CAREER OBJECTIVE", objective)
pdf.add_section("EDUCATION QUALIFICATION", education)
pdf.add_section("STRENGTHS", strengths)
pdf.add_section("PROJECTS", projects)
pdf.set_font('Times', 'I', 12)
pdf.cell(0, 10, "I declare that the above information is true to the best of my knowledge.", 0, 1)
pdf.ln(5)
pdf.cell(0, 10, "Date: ", 0, 1)
pdf.cell(0, 10, "Place: ", 0, 1)
return pdf
# Streamlit app
st.title("Resume Builder 📄")
st.subheader("Note: 📝")
st.text("* Please Write Career Objectives, Strengths, Projects in less than 50 Words!")
st.text("* Please Mention Education Qualification in this format: ")
st.text("* Course Name - College/Institution Name - Percentage/CGPA - Year")
st.divider()
st.header("Personal Information 🧑🎓")
name = st.text_input("Full Name")
name=name.upper()
address = st.text_input("Address")
email = st.text_input("Email-ID")
phone = st.text_input("Phone Number")
phone = "Phone No. : " + phone
st.header("Upload Profile Picture 📷")
profile_picture = st.file_uploader("Make sure to select .jpg/.jpeg file only", type=["jpg", "jpeg"])
st.header("Career Objectives 🎯")
objective = st.text_area("Please Enter Your Career Objectives Below:")
st.header("Education Qualification 📚")
education = st.text_area("Please Enter Your Education Details Below:")
st.header("Strengths 💪")
strengths = st.text_area("Please Enter Your Strengths Below:")
st.header("Projects 🧑💻")
projects = st.text_area("Please Tell About the Projects You've Built:")
if st.button("Generate Resume 🔃"):
if profile_picture:
image = Image.open(profile_picture)
image.save("ProfilePics\\profile_picture.jpg")
profile_picture_path = "ProfilePics\\profile_picture.jpg"
else:
profile_picture_path = None
resume = generate_pdf(name, address, email, phone, objective, education, strengths, projects, profile_picture_path)
resume.output("resume.pdf")
st.balloons()
st.success("Resume generated successfully!")
with open("resume.pdf", "rb") as pdf_file:
st.download_button(label="Download Resume as PDF 📩", data=pdf_file, file_name="resume.pdf", mime="application/pdf")
# ========= BUG REPORT TAB =========
if selected == "Bug Report":
col1, col2 = st.columns([2, 2])
with col1:
# Function to load existing data from the file
def load_data(filename):
if os.path.exists(filename):
with open(filename, 'r') as f:
return json.load(f)
return []
# Function to save data to a file
def save_data(data, filename):
with open(filename, 'w') as f:
json.dump(data, f, indent=4)
st.title("Bug Report 🪲")
st.text("NOTE:")
st.text("You can also give some suggestions to improve our software!")
bug_report = st.text_area("Please describe the issue or report a bug:")
uploaded_file = st.file_uploader("Attach Screenshot (Optional):", type=["png", "jpg"])
image_path = None
if uploaded_file is not None:
image = Image.open(uploaded_file)
image_path = os.path.join('bug_images', f"{bug_report.replace(' ', '_')}_uploaded_file.jpg")
os.makedirs('images', exist_ok=True)
image.save(image_path)
st.markdown("**<span style='color:lightgreen'>Screenshot Attached Successfully 👍🏻</span>**", unsafe_allow_html=True)
with st.expander("Preview Attached Screenshot"):
st.image(uploaded_file)
send_button = st.button("Send Report ✈️")
if send_button:
# Collect input data
user_data = {
"bug_report": bug_report,
"image_path": image_path if image_path else None
}
# Load existing data
all_data = load_data('bug_data.json')
# Ensure all_data is a list
if not isinstance(all_data, list):
all_data = []
# Append new data
all_data.append(user_data)
# Save updated data
save_data(all_data, 'bug_data.json')
st.markdown("<span style = 'color:lightgreen'>Report Sent Successfully, We'll get back to you super soon ⚡</span>", unsafe_allow_html=True)
st.markdown("## <span style = 'color:white'>Thank You 💖</span>", unsafe_allow_html=True)
st.markdown("#### <span style = 'color:green'>Team HardCoders 🦾</span>", unsafe_allow_html=True)
with col2:
st.image("Images/AppSettings.png")
# ========= CONTRIBUTORS =========
if selected == "About Me":
col1, col2 = st.columns(2)
with col1:
st.image("Images/profile-pic.png", width=350)
with col2:
st.title("ASHWIN SARATHE 🧑💻")
st.subheader("#️⃣ KALANIKETAN POLYTECHNIC COLLEGE, JABALPUR, M.P.")
st.subheader("#️⃣ DIPLOMA IN COMPUTER SCIENCE")
st.subheader("#️⃣ 3RD YEAR STUDENT")
st.divider()
st.header("Special Thanks To -")
st.header("Mrs. Rashmi Gupta Mam for Guiding us! 🙏")
# ========= BUY ME A COFFEE =========
if selected == "Buy Me A Coffee":
url = 'https://www.buymeacoffee.com/ashwin_sarathe'
col1, col2 = st.columns(2)
with col1:
st.title("Buy Me A Coffee ☕")
st.divider()
st.header('Please Show your Support by ')
st.header("Buying me a Coffee!")
st.subheader("")
st.markdown(f'<a href="{url}" target="_blank" style="background-color: #008CBA; color: white; padding: 15px 30px; font-size: 20px; text-align: center; text-decoration: none; display: inline-block; border-radius: 4px;">Donate</a>', unsafe_allow_html=True)
with col2:
st.image("Images/c.png")