Skip to content

Commit e346213

Browse files
Merge pull request #102 from yours7himanshu/visuals
Visuals
2 parents 9cce517 + a2363a2 commit e346213

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

python_rec/pred_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def predictor(arr):
5454
else:
5555
return "Not Placed"
5656

57-
# if __name__ == "__main__":
58-
# prompt1 = sys.argv[1]
59-
# prompt2 = sys.argv[2]
60-
# prompt3 = sys.argv[3]
61-
# prompt = [prompt1,prompt2,prompt3]
62-
# output = predictor(prompt)
63-
# print(json.dumps({"result": output}))
57+
if __name__ == "__main__":
58+
prompt1 = sys.argv[1]
59+
prompt2 = sys.argv[2]
60+
prompt3 = sys.argv[3]
61+
prompt = [prompt1,prompt2,prompt3]
62+
output = predictor(prompt)
63+
print(json.dumps({"result": output}))

python_rec/student_analysis.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def adjust_placement(row):
4242

4343
def create_bar_plot(x, y,title,xlabel):
4444
buf = io.BytesIO()
45-
plt.figure(figsize=(8,6))
45+
plt.figure(figsize=(10,6))
4646
bars=plt.barh(x,y, color='skyblue', edgecolor='black')
4747
max_index = np.argmax(y.values)
4848
min_index = np.argmin(y.values)
@@ -51,9 +51,10 @@ def create_bar_plot(x, y,title,xlabel):
5151
for bar in bars:
5252
width = bar.get_width()
5353
plt.text(width + 0.5, bar.get_y() + bar.get_height() / 2,
54-
f'{width:.2f}', va='center', fontsize=10, color='black')
54+
f'{width:.2f}', va='center', fontsize=15, color='black')
5555
plt.title(title, fontsize=16, fontweight='bold')
56-
plt.xlabel(xlabel, fontsize=12)
56+
plt.xlabel(xlabel, fontsize=21,fontweight='bold', color='#34495e', labelpad=10, family='serif')
57+
5758
plt.xlim(0, 100)
5859
plt.tight_layout()
5960
plt.gca().invert_yaxis()
@@ -69,16 +70,16 @@ def top_students():
6970
name=x['Name_x']
7071
marks=x['Marks']
7172
branch=x['Branch']
72-
plt.figure(figsize=(12,5))
73+
plt.figure(figsize=(12,7))
7374
plot=sns.barplot(data=df, x=name, y=marks, hue=branch)
7475
for p in plot.patches:
7576
height = p.get_height()
7677
plot.annotate(f'{height:.1f}',
7778
(p.get_x() + p.get_width() / 2., height),
7879
ha='center', va='bottom',
79-
fontsize=9, color='black')
80-
plt.legend(title='Branch', loc='center left', bbox_to_anchor=(1, 0.5), fontsize='small', title_fontsize='small')
81-
plt.xticks(rotation=45)
80+
color='black', fontsize=12, fontweight='bold')
81+
plt.legend(title='Branch', loc='center left', bbox_to_anchor=(1, 0.5), title_fontsize='medium')
82+
plt.xticks(rotation=70,fontsize=16,fontweight='bold',family='serif')
8283
plt.title("Student Marks by Branch")
8384
plt.tight_layout()
8485
plt.savefig(buf, format='png')
@@ -103,8 +104,8 @@ def scatter():
103104
plt.figure(figsize=(8, 6))
104105
sns.scatterplot(data=new_df, x=df['Attendance'], y=new_df['Marks'], hue=new_df['Branch'], s=100)
105106
plt.title("Attendance vs Marks")
106-
plt.xlabel("Attendance")
107-
plt.ylabel("Marks")
107+
plt.xlabel("Attendance",fontsize=17,fontweight='bold')
108+
plt.ylabel("Marks",fontsize=17,fontweight='bold')
108109
plt.grid(True)
109110
plt.tight_layout()
110111
plt.savefig(buf, format='png')
@@ -118,28 +119,34 @@ def fees_status():
118119

119120
buf = io.BytesIO()
120121
grouped = df.groupby(['Branch', 'Fees_status']).size().reset_index(name='count')
121-
plt.figure(figsize=(10, 6))
122-
sns.barplot(data=grouped, x='Branch', y='count', hue='Fees_status', palette='Set2')
122+
plt.figure(figsize=(10,7))
123+
sns.barplot(data=grouped, x='Branch', y='count', hue='Fees_status', palette='Set2',)
123124
plt.title('Fee Status by Branch')
124-
plt.xlabel('Branch')
125-
plt.ylabel('Number of Students')
126-
plt.legend(title='Fees Status')
127-
plt.xticks(rotation=45)
125+
plt.xlabel('Branch',fontsize=17,fontweight='bold')
126+
plt.ylabel('Number of Students',fontsize=17,fontweight='bold')
127+
plt.legend(title='Fees Status',loc='upper right')
128+
plt.xticks(rotation=80, fontsize=12,fontweight='bold', color='#34495e', family='serif')
129+
for p in plt.gca().patches:
130+
plt.gca().annotate(f'{int(p.get_height())}',
131+
(p.get_x() + p.get_width() / 2., p.get_height()),
132+
ha='center', va='bottom', fontsize=12, fontweight='bold')
133+
128134
plt.tight_layout()
135+
plt.grid(True)
129136
plt.savefig(buf, format='png')
130137
plt.close()
131138
buf.seek(0)
132139
return base64.b64encode(buf.read()).decode('utf-8')
133140
def placement_status():
134141
buf = io.BytesIO()
135-
plt.figure(figsize=(6,4))
142+
plt.figure(figsize=(6,5))
136143
sns.set(style="whitegrid")
137144
palette = {'Placed': "#1f77b4", 'Unplaced': "#ff7f0e"}
138145
sns.countplot(data=df, x='Placed',palette=palette,width=0.3)
139146
plt.legend(title='Placement Status', loc='upper right', labels=['Placed', 'Unplaced'], fontsize=12)
140147
plt.title("Number of Students Placed vs Unplaced", fontsize=16, fontweight='bold')
141-
plt.xlabel("Placement Status", fontsize=12)
142-
plt.ylabel("Number of Students", fontsize=12)
148+
plt.xlabel("Placement Status",fontsize=17,fontweight='bold')
149+
plt.ylabel("Number of Students",fontsize=17,fontweight='bold')
143150
for p in plt.gca().patches:
144151
plt.gca().annotate(f'{int(p.get_height())}',
145152
(p.get_x() + p.get_width() / 2., p.get_height()),
@@ -159,9 +166,9 @@ def branch_placement():
159166
sns.countplot(data=df, x='Branch', hue='Placed', palette=palette)
160167

161168
plt.title("Branch-wise Placement Status", fontsize=16, fontweight='bold')
162-
plt.xlabel("Branch", fontsize=12)
163-
plt.ylabel("Number of Students", fontsize=12)
164-
plt.xticks(rotation=45)
169+
plt.xlabel("Branch", fontsize=17,fontweight='bold')
170+
plt.ylabel("Number of Students", fontsize=17,fontweight='bold')
171+
plt.xticks(rotation=45,fontsize=12,fontweight='bold', color='#34495e', family='serif')
165172
for p in plt.gca().patches:
166173
height = p.get_height()
167174
if height > 0:
@@ -181,8 +188,8 @@ def branch_placement():
181188

182189

183190
print(json.dumps({'result':{
184-
'barplot1':create_bar_plot(branches,att_mean,"Engineering Branch Scores","Attendance"),
185-
'barplot2':create_bar_plot(branches,marks_mean,"Engineering Branch Scores","Marks"),
191+
'barplot1':create_bar_plot(branches,att_mean,"Engineering Branch Scores","Attendance (Mean)"),
192+
'barplot2':create_bar_plot(branches,marks_mean,"Engineering Branch Scores","Marks (Mean)"),
186193
'scatter':scatter(),
187194
'top_students':top_students(),
188195
'pieplot':pieplot(),

0 commit comments

Comments
 (0)