-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
544 lines (439 loc) · 17.7 KB
/
main.py
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# Import necessary modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from utilities import change_width, show_values, annotate_bar
# Read CSV files
students_df = pd.read_csv("csv/students.csv")
aptitude_test_df = pd.read_csv("csv/aptitude_test.csv")
group_discussion_df = pd.read_csv("csv/group_discussion.csv")
mocks_df = pd.read_csv("csv/mocks.csv")
# Set style and palette
sns.set_theme(style="darkgrid", palette="husl")
# Convert department and preference to category datatype
students_df["department"] = students_df["department"].astype("category")
students_df["preference"] = students_df["preference"].astype("category")
"""
/**************************************************************************************************/
PIE CHART FOR NUMBER OF STUDENTS WHO PARTICIPATED IN MOCK PLACEMENTS CATEGORIZED BY MODE PREFERENCE
/**************************************************************************************************/
"""
# Number of interviews held on 20/01/2021 and 21/02/2021
num_of_students_mode = students_df["preference"].value_counts()
# Total number of students who participated in MOCK PLACEMENTS
total_students = np.sum(num_of_students_mode.values)
# Number of interviews held on 20/01/2021 and 21/02/2021
num_of_students_mode = (
students_df["preference"].value_counts(normalize=True).sort_index()
)
modes = num_of_students_mode.index
num_of_students = num_of_students_mode.values
# Create pie chart
plt.pie(
num_of_students,
labels=modes,
normalize=False,
shadow=True,
autopct=lambda pct: show_values(pct, total_students),
startangle=90,
)
plt.title("NUMBER OF STUDENTS WHO PARTICIPATED IN MOCK PLACEMENTS - MODE WISE")
plt.show()
"""
/*********************************************************************************/
PIE CHART FOR NUMBER OF STUDENTS PER DEPARTMENT WHO PARTICIPATED IN MOCK PLACEMENTS
/*********************************************************************************/
"""
# Number of students per department who participated in MOCK PLACEMENTS
students_per_department = students_df["department"].value_counts()
# Total number of students who participated in MOCK PLACEMENTS
total_students = np.sum(students_per_department.values)
students_per_department = students_df["department"].value_counts(normalize=True)
departments = students_per_department.index
num_of_students = students_per_department.values
# Create pie chart
plt.pie(
num_of_students,
labels=departments,
normalize=False,
shadow=True,
autopct=lambda pct: show_values(pct, total_students),
startangle=90,
)
plt.title("NUMBER OF STUDENTS WHO PARTICIPATED IN MOCK PLACEMENTS - DEPARTMENT WISE")
plt.show()
"""
/**********************************************************************************************************************/
GROUPED BAR PLOT FOR NUMBER OF STUDENTS PER DEPARTMENT WHO REGISTERED FOR MOCK PLACEMENTS CATEGORIZED BY INTERVIEW MODE
/**********************************************************************************************************************/
"""
# Number of students who participated in OFFLINE and ONLINE MOCK PLACEMENTS
students_offline_department = (
students_df[students_df["preference"] == "Offline"]["department"]
.value_counts()
.sort_index()
)
students_online_department = (
students_df[students_df["preference"] == "Online"]["department"]
.value_counts()
.sort_index()
)
num_students_offline = students_offline_department.values
num_students_online = students_online_department.values
# Width of each bar
bar_width = 0.25
# Set position of bar on X axis
r1 = np.arange(len(departments))
r2 = [x + bar_width for x in r1]
# Plot the bar graph
bar1 = plt.bar(r1, num_students_offline, width=bar_width, label="Offline")
bar2 = plt.bar(r2, num_students_online, width=bar_width, label="Online")
# Label both the bar plots
annotate_bar(bar1)
annotate_bar(bar2)
# Add xticks on the middle of the group bars
plt.xticks(
[r + bar_width for r in range(len(num_students_offline))], sorted(departments)
)
plt.yticks(np.arange(0, 120, 20))
plt.xlabel("Department")
plt.ylabel("Count Of Students")
plt.title(
"COUNT OF STUDENTS WHO PARTICIPATED IN ONLINE AND OFFLINE MOCK PLACEMENTS - DEPARTMENT WISE"
)
plt.legend()
plt.show()
# Convert department to category datatype
aptitude_test_df["department"] = aptitude_test_df["department"].astype("category")
"""
/*****************************************************/
BAR PLOT FOR AVERAGE APTITUDE TEST SCORE PER DEPARTMENT
/*****************************************************/
"""
# Series for the average aptitude test score in each department
average_aptitude_score_department = (
aptitude_test_df.groupby(["department"])["total_score"]
.mean()
.sort_values(ascending=True)
)
departments = average_aptitude_score_department.index
average_aptitude_scores = average_aptitude_score_department.values
# Create barplot
plot = sns.barplot(x=departments, y=average_aptitude_scores)
# Annotate the bar graphs
for bar in plot.patches:
plot.annotate(
format(bar.get_height(), ".2f"),
(bar.get_x() + bar.get_width() / 2, bar.get_height()),
ha="center",
va="center",
size=15,
xytext=(0, 8),
textcoords="offset points",
)
# Set bar width
change_width(plot, 0.5)
# Set values to be displayed on y-axis
plt.yticks(np.arange(5, 55, 5))
plt.xlabel("Department")
plt.ylabel("Aptitude Test Score Out Of 50")
plt.title("AVERAGE APTITUDE TEST SCORE - DEPARTMENT WISE")
plt.show()
# Convert department to category datatype
group_discussion_df["department"] = group_discussion_df["department"].astype("category")
"""
/********************************************************/
BAR PLOT FOR AVERAGE GROUP DISCUSSION SCORE PER DEPARTMENT
/********************************************************/
"""
# Series for the average GD score in each department
average_gd_score_department = (
group_discussion_df.groupby(["department"])["total_score"]
.mean()
.sort_values(ascending=True)
)
departments = average_gd_score_department.index
average_gd_scores = average_gd_score_department.values
# Create barplot
plot = sns.barplot(x=departments, y=average_gd_scores)
# Annotate the bar graphs
for bar in plot.patches:
plot.annotate(
format(bar.get_height(), ".2f"),
(bar.get_x() + bar.get_width() / 2, bar.get_height()),
ha="center",
va="center",
size=15,
xytext=(0, 8),
textcoords="offset points",
)
# Set bar width
change_width(plot, 0.5)
# Set values to be displayed on y-axis
plt.yticks(np.arange(5, 35, 5))
plt.xlabel("Department")
plt.ylabel("Group Discussion Score Out Of 30")
plt.title("AVERAGE GROUP DISCUSSION SCORE - DEPARTMENT WISE")
plt.show()
# Convert student_department, interviewer to category datatype
mocks_df["student_department"] = mocks_df["student_department"].astype("category")
mocks_df["interview_mode"] = mocks_df["interview_mode"].astype("category")
mocks_online_df = mocks_df[mocks_df["interview_mode"] == "Online"]
mocks_offline_df = mocks_df[mocks_df["interview_mode"] == "Offline"]
mocks_20_df = mocks_df[mocks_df["interview_date"] == "20-02-2021"]
mocks_21_df = mocks_df[mocks_df["interview_date"] == "21-02-2021"]
mocks_27_df = mocks_df[mocks_df["interview_date"] == "27-02-2021"]
mocks_28_df = mocks_df[mocks_df["interview_date"] == "28-02-2021"]
"""
/**********************************************************************************/
PIE CHART FOR NUMBER OF INTERVIEWERS WHO PATICIPATED IN MOCK PLACEMENTS - DATE WISE
/**********************************************************************************/
"""
num_of_interviewers_date = mocks_df.groupby(["interview_date"])["interviewer"].nunique()
dates = num_of_interviewers_date.index
total_interviewers = np.sum(num_of_interviewers_date.values)
plt.pie(
num_of_interviewers_date,
labels=dates,
shadow=True,
autopct=lambda pct: show_values(pct, total_interviewers),
startangle=90,
)
plt.title("NUMBER OF HR's WHO PARTICIPATED IN MOCK PLACEMENTS - DATE WISE")
plt.show()
"""
/*********************************************************/
PIE CHART FOR NUMBER OF INTERVIEWS CONDUCTED ON EACH DATE
/*********************************************************/
"""
# Number of interviews held on each date
number_of_interviews_date = mocks_df["interview_date"].value_counts()
# Total number of students who participated in MOCK PLACEMENTS
total_interviews = np.sum(number_of_interviews_date.values)
# Number of interviews held on each date
number_of_interviews_date = mocks_df["interview_date"].value_counts(normalize=True)
dates = number_of_interviews_date.index
num_of_interviews = number_of_interviews_date.values
# Create pie chart
plt.pie(
num_of_interviews,
labels=dates,
normalize=False,
shadow=True,
autopct=lambda pct: show_values(pct, total_interviews),
startangle=90,
)
plt.title("NUMBER OF INTERVIEWS CONDUCTED DURING MOCK PLACEMENTS - DATE WISE")
plt.show()
"""
/*****************************************************************************************/
GROUPED BAR PLOT FOR AVERAGE INTERVIEW SCORE PER DEPARTMENT CATEGORIZED BY INTERVIEW MODE
/*****************************************************************************************/
"""
# Series for the average interview score in each department
average_interview_score_department_online = mocks_online_df.groupby(
["student_department"]
)["interview_total"].mean()
average_interview_score_department_offline = mocks_offline_df.groupby(
["student_department"]
)["interview_total"].mean()
average_interview_scores_online = (
average_interview_score_department_online.values.round(2)
)
average_interview_scores_offline = (
average_interview_score_department_offline.values.round(2)
)
# Width of each bar
bar_width = 0.40
# Set position of bar on X axis
r1 = np.arange(len(departments))
r2 = [x + bar_width for x in r1]
# Plot the bar graph
bar1 = plt.bar(r1, average_interview_scores_offline, width=bar_width, label="Offline")
bar2 = plt.bar(r2, average_interview_scores_online, width=bar_width, label="Online")
# Label both the bar plots
annotate_bar(bar1)
annotate_bar(bar2)
# Add xticks on the middle of the group bars
plt.xticks(
[r + bar_width for r in range(len(num_students_offline))], sorted(departments)
)
plt.yticks(np.arange(0, 35, 5))
plt.xlabel("Department")
plt.ylabel("Interview Score Out Of 30")
plt.title("AVERAGE INTERVIEW SCORE - DEPARTMENT WISE")
plt.legend()
plt.show()
"""
/*******************************************************************************************************************/
GROUPED BAR PLOT FOR AVERAGE NUMBER OF INTERVIEWS ATTENDED BY A STUDENT PER DEPARTMENT CATEGORIZED BY INTERVIEW MODE
/*******************************************************************************************************************/
"""
# Series for the number of interviews attended by each department in online MOCK PLACEMENTS
interviews_per_department_online = mocks_online_df.groupby(["student_department"])[
"registration_number"
].count()
# Series for the number of interviews attended by each department in online MOCK PLACEMENTS
interviews_per_department_offline = mocks_offline_df.groupby(["student_department"])[
"registration_number"
].count()
# Series for the number of students from the department who participated in online MOCK PLACEMENTS
students_per_department_online = mocks_online_df.groupby(["student_department"])[
"registration_number"
].nunique()
# Series for the number of students from the department who participated in offline MOCK PLACEMENTS
students_per_department_offline = mocks_offline_df.groupby(["student_department"])[
"registration_number"
].nunique()
# Series for the average number of interviews a student attended in each department in online MOCK PLACEMENTS
average_interview_department_online = interviews_per_department_online.divide(
students_per_department_online
)
# Series for the average number of interviews a student attended in each department in offline MOCK PLACEMENTS
average_interview_department_offline = interviews_per_department_offline.divide(
students_per_department_offline
)
# Width of each bar
bar_width = 0.385
# Set position of bar on X axis
r1 = np.arange(len(departments))
r2 = [x + bar_width for x in r1]
# Plot the bar graph
bar1 = plt.bar(
r1,
average_interview_department_offline.values.round(2),
width=bar_width,
label="Offline",
)
bar2 = plt.bar(
r2,
average_interview_department_online.values.round(2),
width=bar_width,
label="Online",
)
# Label both the bar plots
annotate_bar(bar1)
annotate_bar(bar2)
# Add xticks on the middle of the group bars
plt.xticks(
[r + bar_width for r in range(len(num_students_offline))], sorted(departments)
)
plt.yticks(np.arange(0, 4, 1))
plt.xlabel("Department")
plt.ylabel("Number of Interviews Attended")
plt.title("AVERAGE NUMBER OF INTERVIEWS ATTENDED BY A STUDENT - DEPARTMENT WISE")
plt.legend()
plt.show()
def average_score_interviewer(average_scores, interviewer, date):
plot = sns.barplot(x=average_score_20, y=interviewer_20)
for bar in plot.patches:
plot.text(
0.75 + bar.get_width(),
bar.get_y() + 0.55 * bar.get_height(),
"{:1.2f}".format(bar.get_width()),
ha="center",
va="center",
)
plt.xticks(np.arange(0, 35, 5))
plt.xlabel("Interview Score Out Of 30")
plt.ylabel("Interviewer")
plt.title("AVERAGE SCORE AWARDED BY EACH HR ON {}".format(date))
plt.show()
"""
/*********************************************************/
BAR PLOT FOR AVERAGE SCORE AWARDED BY EACH HR ON 20/02/2021
/*********************************************************/
"""
average_interview_score_20 = mocks_20_df.groupby(["interviewer"])[
"interview_total"
].mean()
interviewer_20 = average_interview_score_20.index
average_score_20 = average_interview_score_20.values
average_score_interviewer(average_score_20, interviewer_20, "20/02/2021")
"""
/*********************************************************/
BAR PLOT FOR AVERAGE SCORE AWARDED BY EACH HR ON 21/02/2021
/*********************************************************/
"""
average_interview_score_21 = mocks_21_df.groupby(["interviewer"])[
"interview_total"
].mean()
interviewer_21 = average_interview_score_21.index
average_score_21 = average_interview_score_21.values
average_score_interviewer(average_score_21, interviewer_21, "21/02/2021")
"""
/*********************************************************/
BAR PLOT FOR AVERAGE SCORE AWARDED BY EACH HR ON 27/02/2021
/*********************************************************/
"""
average_interview_score_27 = mocks_27_df.groupby(["interviewer"])[
"interview_total"
].mean()
interviewer_27 = average_interview_score_27.index
average_score_27 = average_interview_score_27.values
average_score_interviewer(average_score_27, interviewer_27, "27/02/2021")
"""
/*********************************************************/
BAR PLOT FOR AVERAGE SCORE AWARDED BY EACH HR ON 28/02/2021
/*********************************************************/
"""
average_interview_score_28 = mocks_28_df.groupby(["interviewer"])[
"interview_total"
].mean()
interviewer_28 = average_interview_score_28.index
average_score_28 = average_interview_score_28.values
average_score_interviewer(average_score_28, interviewer_28, "28/02/2021")
def students_per_interviewer(interviewers, students, date, xrange):
# Create barplot
plot = sns.barplot(x=students, y=interviewers)
# Annotate the bar graphs
for bar in plot.patches:
plot.text(
0.22 + bar.get_width(),
bar.get_y() + 0.55 * bar.get_height(),
"{:1.0f}".format(bar.get_width()),
ha="center",
va="center",
)
plt.xticks(np.arange(0, xrange + 5, 5))
plt.xlabel("Number Of Students Interviewed")
plt.ylabel("Interviewer")
plt.title("NUMBER OF STUDENTS INTERVIEWED BY EACH HR ON {}".format(date))
plt.show()
"""
/*******************************************************************/
BAR PLOT FOR NUMBER OF STUDENTS INTERVIEWED BY EACH HR ON 20/02/2021
/*******************************************************************/
"""
students_per_interviewer_20 = mocks_20_df["interviewer"].value_counts()
interviewer_20 = students_per_interviewer_20.index
num_of_students_20 = students_per_interviewer_20.values
students_per_interviewer(interviewer_20, num_of_students_20, "20/02/2021", 15)
"""
/*******************************************************************/
BAR PLOT FOR NUMBER OF STUDENTS INTERVIEWED BY EACH HR ON 21/02/2021
/*******************************************************************/
"""
students_per_interviewer_21 = mocks_21_df["interviewer"].value_counts()
interviewer_21 = students_per_interviewer_21.index
num_of_students_21 = students_per_interviewer_21.values
students_per_interviewer(interviewer_21, num_of_students_21, "21/02/2021", 25)
"""
/*******************************************************************/
BAR PLOT FOR NUMBER OF STUDENTS INTERVIEWED BY EACH HR ON 27/02/2021
/*******************************************************************/
"""
students_per_interviewer_27 = mocks_27_df["interviewer"].value_counts()
interviewer_27 = students_per_interviewer_27.index
num_of_students_27 = students_per_interviewer_27.values
students_per_interviewer(interviewer_27, num_of_students_27, "27/02/2021", 40)
"""
/*******************************************************************/
BAR PLOT FOR NUMBER OF STUDENTS INTERVIEWED BY EACH HR ON 28/02/2021
/*******************************************************************/
"""
students_per_interviewer_28 = mocks_28_df["interviewer"].value_counts()
interviewer_28 = students_per_interviewer_28.index
num_of_students_28 = students_per_interviewer_28.values
students_per_interviewer(interviewer_28, num_of_students_28, "28/02/2021", 30)