forked from smartinternz02/SBSPS-Challenge-10196-1690824000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
693 lines (536 loc) · 22.6 KB
/
app.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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
import streamlit as st
from streamlit_option_menu import option_menu
import pickle
from pathlib import Path
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import streamlit as st
from matplotlib.ticker import FuncFormatter
plt.rcParams["figure.autolayout"] = False
img = Image.open('download.jpeg')
st.set_page_config(page_title = 'FutureX', page_icon = img)
hide_menu_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_menu_style, unsafe_allow_html=True)
st.markdown('<h1 style="text-align: center;">FutureX</h1>', unsafe_allow_html=True)
st.markdown('<h2 style="text-align: centre;">"Cracking the Campus Code: Exploring Placement Patterns and Trends"</h2>', unsafe_allow_html=True)
# 1. as sidebar menu
with st.sidebar:
selected = option_menu(
menu_title = "Main Page of Project",
options = ["Project Introduction", "Data Input", "Round-wise Placement", "Model Analysis"],
)
if selected == "Project Introduction":
st.subheader(f"The page provides us a breif summary of the overall code we have employed in our project")
#if selected == "Real Time working":
#st.title(f"Welcome!")
if selected == "Working":
st.title("Code Demo")
if selected == "Project Introduction":
st.subheader('...')
#user_input = st.text_input('Enter Placement Score')
df = pd.read_excel("Student-Employability-Datasets.xlsx")
df.head() #st.write(df.head())
df.describe() #st.write(df.describe())
new_df = df.drop(
columns = [
'CLASS',
'Name of Student',
'Student Performance Rating'
]
)
total = pd.DataFrame({
'Skills' : new_df.columns,
'Total Value' : new_df.sum()
})
fig, ax = plt.subplots()
fig.set_figwidth(15)
fig.set_figheight(7.5)
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style="darkgrid", palette="deep")
ax = sns.barplot(
y = 'Skills',
x='Total Value',
data = total.sort_values(
'Total Value',
ascending = False
)
)
ax.set_title('Summation of Values per skill')
st.title('Summation of Values per Skill')
st.pyplot(fig)
fig.patch.set_facecolor('ghostwhite')
df_employed = df.loc[df['CLASS'] == 'Employable']
df_employed = df_employed.drop(columns = ['Name of Student','CLASS'])
ave_skills = pd.DataFrame({
'Average Score' : df_employed.mean()
})
ave_skills #st.write(ave_skills)
df_employed.head()
pie_data = ave_skills.drop(index = ['Student Performance Rating'], axis = 0)
pie_data
palette_color = sns.color_palette(palette = 'deep')
fig = plt.figure(figsize=(20,10))
fig.patch.set_facecolor('ghostwhite')
plt.pie(
pie_data['Average Score'],
labels = pie_data.index,
colors = palette_color,
autopct = '%.0f%%'
)
centre_circle = plt.Circle((0, 0), 0.72, fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.title('Percentage Distribution of Skills for Employable on Average')
st.title('Percentage Distribution of Skills for Employable on Average')
st.pyplot(fig)
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style="darkgrid", palette="deep")
sns.barplot(
y = ave_skills.index,
x= 'Average Score',
data = ave_skills.sort_values(
'Average Score',
ascending = False
)
)
plt.xticks(np.arange(0,5.25,0.25))
plt.title('Average Score of the Employable Students per Category')
st.title('Average Score of the Employable Students per Category')
st.pyplot(fig)
df_ave = pd.DataFrame({
'Student' : df['Name of Student'].loc[df['CLASS'] == 'Employable'],
'Average Score': df.loc[df['CLASS'] == 'Employable']\
._get_numeric_data().mean(axis = 1)
})
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style='darkgrid', palette = 'dark')
ax = sns.histplot(
x = 'Average Score',
data = df_ave
)
df_ave.plot(
kind='kde',
ax=ax,
secondary_y=True,
color = 'orange'
)
plt.xticks(np.arange(2,6.25,0.25))
st.title('Mean Scores per Student Histogram for Employable')
plt.title('Mean Scores per Student Histogram for Employable')
st.pyplot(fig)
df_less = df.loc[df['CLASS'] == 'LessEmployable']\
.drop(columns = ['CLASS', 'Name of Student'])
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
less_ave_skills = pd.DataFrame({
'Average' : df_less.mean()
})
sns.set_theme(style="darkgrid", palette="deep")
sns.barplot(
y = less_ave_skills.index,
x= 'Average',
data = less_ave_skills.sort_values(
'Average',
ascending = False
)
)
plt.xticks(np.arange(0,5.25,0.25))
st.title('Average Score of the LESS Employable Students per Category')
plt.title('Average Score of the LESS Employable Students per Category')
st.pyplot(fig)
df_ave_less = pd.DataFrame({
'Student' : df['Name of Student'].loc[
df['CLASS'] == 'LessEmployable'
],
'Average Score': df.loc[
df['CLASS'] == 'LessEmployable'
]._get_numeric_data().mean(axis = 1)
})
df_ave_less.head()
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style='darkgrid', palette = 'dark')
ax = sns.histplot(
x = 'Average Score',
data = df_ave_less
)
df_ave_less.plot(
kind='kde',
ax=ax,
secondary_y=True,
color = 'darkorange'
)
plt.xticks(np.arange(2,6.25,0.25))
st.title('Mean Scores per Student Histogram for LESS Employable')
plt.title('Mean Scores per Student Histogram for LESS Employable')
st.pyplot(fig)
st.title('LESS EMPLOYABLE STUDENTS')
st.write(df_less.loc[df_ave_less['Average Score'] > 3.5].head(10))
st.title('EMPLOYABLE STUDENTS')
st.write(df_employed.loc[df_ave['Average Score'] > 3.5].head(10))
sns.pairplot(
vars = [
'GENERAL APPEARANCE',
'MANNER OF SPEAKING',
'PHYSICAL CONDITION',
'MENTAL ALERTNESS',
'SELF-CONFIDENCE',
'ABILITY TO PRESENT IDEAS',
'COMMUNICATION SKILLS'
],
hue = 'CLASS',
kind = 'scatter',
data = df
)
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
ax = sns.heatmap(
df.drop(
columns = [
'Name of Student',
'CLASS',
'Student Performance Rating'
]
).corr().round(2),
annot=True,
vmin = -1,
vmax = 1,
center = 0,
cmap ='YlGnBu'
)
plt.xticks(rotation = 45)
st.title('Correlation Matrix for the Dataset')
plt.title("Correlation Matrix for the Dataset")
st.pyplot(fig)
st.subheader('These tables and graphs demonstrates to us how the test values and train values have been utilized to obtain graphs for the placement trends')
if selected == "Data Input":
st.header("please Input the necessary placement scores")
user_data_list = []
entry_counter = 1
while True:
name_key = f"Name_{entry_counter}"
General_Appearance_key = f"General Appearance_{entry_counter}"
Manner_of_Speaking_key = f"Manner of Speaking_{entry_counter}"
Physical_Condition_key = f"Physical Condition_{entry_counter}"
Mental_Alertness_key = f"Mental Alertness_{entry_counter}"
Self_Confidence_key = f"Self Confidence_{entry_counter}"
Ability_to_Present_Ideas_key = f"Ability to Present Ideas_{entry_counter}"
Communication_Skills_key = f"Communication Skills_{entry_counter}"
submit_key = f"Submit_{entry_counter}"
add_more_data_key = f"Add More Data_{entry_counter}"
user_name = st.text_input("Name", key=name_key)
General_Appearance = st.number_input("General Appearance", key = General_Appearance_key)
Manner_of_Speaking = st.number_input("Manner of Speaking", key = Manner_of_Speaking_key)
Physical_Condition = st.number_input("Physical Condition", key = Physical_Condition_key)
Mental_Alertness = st.number_input("Mental Alertness", key = Mental_Alertness_key)
Self_Confidence = st.number_input("Self Confidence", key = Self_Confidence_key)
Ability_to_Present_Ideas = st.number_input("Ability to Present Ideas", key = Ability_to_Present_Ideas_key)
Communication_Skills = st.number_input("Communication Skills", key = Communication_Skills_key)
if st.button("Submit", key=submit_key):
new_entry = {"User Name": user_name, "General Appearance": General_Appearance, "Manner of Speaking": Manner_of_Speaking, "Physical Condition": Physical_Condition, "Mental Alertness": Mental_Alertness, "Self Confidence": Self_Confidence, "Ability to Present Ideas": Ability_to_Present_Ideas, "Communication Skills": Communication_Skills}
user_data_list.append(new_entry)
#user_data.to_excel("User_data.xlsx", index=False)
st.success("Data submitted successfully!")
add_more_data = st.button("Add More Data", key=add_more_data_key)
if not add_more_data:
break
entry_counter += 1
user_data_df = pd.DataFrame(user_data_list)
user_data_df.to_excel("User_data.xlsx", index=False)
if selected == "Round-wise Placement":
from sklearn.ensemble import VotingClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
df = pd.read_excel("Student-Employability-Datasets.xlsx")
df['CLASS'] = df['CLASS'].str.replace('LessEmployable', '0')
df['CLASS'] = df['CLASS'].str.replace('Employable', '1')
df['CLASS'].dtypes
df['CLASS']
df['CLASS'] = df['CLASS'].astype(float)
df
# Separate features and target
X = df.drop(columns=["CLASS"]) # Features
y = df["CLASS"] # Target
chosen_feature = ['Student Performance Rating','GENERAL APPEARANCE','ABILITY TO PRESENT IDEAS','MENTAL ALERTNESS','MANNER OF SPEAKING','PHYSICAL CONDITION','SELF-CONFIDENCE','COMMUNICATION SKILLS'] # Replace with the name of the feature you want to choose
X_selected = X[chosen_feature]
X_train, X_test, y_train, y_test = train_test_split(X_selected, y, test_size=0.2, random_state=42)
from sklearn.metrics import mean_squared_error
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
clf = RandomForestClassifier()
clf.fit(X_train.values,y_train)
y_pred = clf.predict(X_test)
# Evaluate the model
mse = mean_squared_error(y_test, y_pred)
print(f"Mean Squared Error: {mse}")
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy}")
from sklearn.tree import DecisionTreeClassifier
classifier = DecisionTreeClassifier(random_state=0)
#without scaling
classifier.fit(X_train,y_train)
y_pred = classifier.predict(X_test)
# Evaluate the model
mse = mean_squared_error(y_test, y_pred)
print(f"Mean Squared Error: {mse}")
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy}")
model1 = RandomForestClassifier(random_state=42)
model2 = KNeighborsClassifier(n_neighbors=1)
model3 = DecisionTreeClassifier(random_state=0)
ensemble = VotingClassifier(
estimators = [('model1', model1), ('model3', model3), ('model2', model2)],
voting='hard'
)
ensemble = RandomForestClassifier(
n_estimators=100,
random_state=42
)
ensemble.fit(X_train, y_train)
y_pred = ensemble.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
st.subheader(f'We have achieved an accuracy of: {accuracy}')
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.ensemble import RandomForestClassifier
# Create a RandomForestClassifier
rf_classifier = RandomForestClassifier()
# Define the search space for hyperparameters
param_grid = {
'n_estimators': [100, 200, 300],
'max_depth': [None, 10, 20],
'min_samples_split': [2, 5, 10]
}
# Perform grid search with cross-validation
grid_search = GridSearchCV(estimator=rf_classifier, param_grid=param_grid, cv=5)
grid_search.fit(X_train, y_train)
# Get the best hyperparameters and corresponding model
best_params = grid_search.best_params_
best_model = grid_search.best_estimator_
# Evaluate the best model on the test set
test_accuracy = best_model.score(X_test, y_test)
print("Best Hyperparameters:", best_params)
print("Test Accuracy:", test_accuracy)
# Assuming 'X' is your original dataset with 8 features
# Selecting only the first 4 features
#X_subset = df.iloc[:, :4]
#Passing values to round 01 of the placement
chosen_feature = ['GENERAL APPEARANCE','MENTAL ALERTNESS','PHYSICAL CONDITION','SELF-CONFIDENCE'] # Replace with the name of the feature you want to choose
X_selected = X[chosen_feature]
X_train, X_test, y_train, y_test = train_test_split(X_selected, y, test_size=0.2, random_state=42)
from sklearn.ensemble import VotingClassifier
from sklearn.model_selection import train_test_split
model1 = RandomForestClassifier(random_state=42)
model2 = KNeighborsClassifier(n_neighbors=1)
model3 = DecisionTreeClassifier(random_state=0)
ensemble = VotingClassifier(
estimators=[('model1', model1), ('model3', model3)],
voting='hard' # Use 'soft' for weighted voting based on probabilities
)
ensemble = RandomForestClassifier(
n_estimators=100, # Number of base models
random_state=42
)
ensemble.fit(X_train, y_train)
y_pred = ensemble.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f"Ensemble Accuracy: {accuracy}")
y_train_pred = ensemble.predict(X_train)
for i in range(len(y_train)):
st.write(f"Actual: {y_train.iloc[i]}, Predicted: {y_train_pred[i]}")
# Assuming you have y_test and y_pred from previous code
y_pred_zeros = y_test[y_pred == 0]
# Count the number of instances with predicted value 0
num_zeros = len(y_pred_zeros)
st.write(f"Number of instances with predicted value 0: {num_zeros}")
# Create a DataFrame with X_test, y_test, and y_pred
test_data = pd.DataFrame(data=X_test, columns=X_test.columns)
test_data["actual"] = y_test
test_data["predicted"] = y_pred
# Group instances with predicted value 0
grouped_less_emp_round1 = test_data[test_data["predicted"] == 0]
r1_less_emp = pd.DataFrame(grouped_less_emp_round1)
r1_less_emp.to_excel("Round_1_less_emp.xlsx", index=False)
# Group instances with predicted value 1
grouped_emp_round1 = test_data[test_data["predicted"] == 1]
r1_emp = pd.DataFrame(grouped_emp_round1)
r1_emp.to_excel("Round_1_emp.xlsx", index=False)
# Display the grouped instances
st.write(grouped_less_emp_round1)
ave_skills = pd.DataFrame({
'Average Score' : grouped_less_emp_round1.mean()
})
ave_skills
ave_skills = ave_skills.drop(index = ['actual'], axis = 0)
ave_skills = ave_skills.drop(index = ['predicted'], axis = 0)
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style="darkgrid", palette="deep")
sns.barplot(
y = ave_skills.index,
x= 'Average Score',
data = ave_skills.sort_values(
'Average Score',
ascending = False
)
)
plt.xticks(np.arange(0,5.25,0.25))
plt.title('Average Score of the Less Employable Students per Category in ROUND 1')
st.pyplot(fig)
#Round2
#df = pd.read_excel("Round_1_emp.xlsx")
grouped_emp_round1["Student Performance Rating"] = df["Student Performance Rating"]
grouped_emp_round1["COMMUNICATION SKILLS"] = df["COMMUNICATION SKILLS"]
grouped_emp_round1["MANNER OF SPEAKING"] = df["MANNER OF SPEAKING"]
grouped_emp_round1["ABILITY TO PRESENT IDEAS"] = df["ABILITY TO PRESENT IDEAS"]
grouped_emp_round1
chosen_feature = ['MANNER OF SPEAKING', 'ABILITY TO PRESENT IDEAS', 'COMMUNICATION SKILLS', 'Student Performance Rating'] # Replace with the name of the feature you want to choose
X_selected = X[chosen_feature]
X_train, X_test, y_train, y_test = train_test_split(X_selected, y, test_size=0.2, random_state=42)
from sklearn.ensemble import VotingClassifier
from sklearn.model_selection import train_test_split
model1 = RandomForestClassifier(random_state=42)
model2 = KNeighborsClassifier(n_neighbors=1)
model3 = DecisionTreeClassifier(random_state=0)
ensemble = VotingClassifier(
estimators=[('model1', model1), ('model3', model3), ('model2', model2)],
voting='hard' # Use 'soft' for weighted voting based on probabilities
)
ensemble = RandomForestClassifier(
n_estimators=100, # Number of base models
random_state=42
)
ensemble.fit(X_train, y_train)
y_pred = ensemble.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f"Ensemble Accuracy: {accuracy}")
y_train_pred = ensemble.predict(X_train)
for i in range(len(y_train)):
print(f"Actual: {y_train.iloc[i]}, Predicted: {y_train_pred[i]}")
# Assuming you have y_test and y_pred from previous code
y_pred_zeros = y_test[y_pred == 0]
# Count the number of instances with predicted value 0
num_zeros = len(y_pred_zeros)
st.write(f"Number of instances with predicted value 0: {num_zeros}")
# Create a DataFrame with X_test, y_test, and y_pred
test_data = pd.DataFrame(data=X_test, columns=X_test.columns)
test_data["actual"] = y_test
test_data["predicted"] = y_pred
# Group instances with predicted value 0
grouped_less_emp_round2 = test_data[test_data["predicted"] == 0]
# Group instances with predicted value 1
grouped_emp_round2 = test_data[test_data["predicted"] == 1]
r2_emp = pd.DataFrame(grouped_emp_round2)
r2_emp.to_excel("Round_2_emp.xlsx", index=False)
# Display the grouped instances
print(grouped_less_emp_round2)
ave_skills_lemp_r2 = pd.DataFrame({ 'Average Score' : grouped_less_emp_round2.mean() })
ave_skills_lemp_r2
ave_skills_lemp_r2 = ave_skills_lemp_r2.drop(index = ['actual'], axis = 0)
ave_skills_lemp_r2 = ave_skills_lemp_r2.drop(index = ['predicted'], axis = 0)
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style="darkgrid", palette="deep")
sns.barplot(
y = ave_skills_lemp_r2.index,
x= 'Average Score',
data = ave_skills_lemp_r2.sort_values(
'Average Score',
ascending = False
)
)
plt.xticks(np.arange(0,5.25,0.25))
plt.title('Average Score of the Less Employable Students per Category in ROUND 2')
st.pyplot(fig)
#Fianl Employed Students Score
# Group instances with predicted value 1
grouped_emp_round2 = test_data[test_data["predicted"] == 1]
# Display the grouped instances
print(grouped_emp_round2)
grouped_emp_round2["GENERAL APPEARANCE"] = df["GENERAL APPEARANCE"]
grouped_emp_round2["MENTAL ALERTNESS"] = df["MENTAL ALERTNESS"]
grouped_emp_round2["PHYSICAL CONDITION"] = df["PHYSICAL CONDITION"]
grouped_emp_round2["SELF-CONFIDENCE"] = df["SELF-CONFIDENCE"]
grouped_emp_round2
ave_skills_emp = pd.DataFrame({ 'Average Score' : grouped_emp_round2.mean() })
ave_skills_emp
ave_skills_emp = ave_skills_emp.drop(index = ['actual'], axis = 0)
ave_skills_emp = ave_skills_emp.drop(index = ['predicted'], axis = 0)
fig = plt.figure(figsize=(15,7.5))
fig.patch.set_facecolor('ghostwhite')
sns.set_theme(style="darkgrid", palette="deep")
sns.barplot(
y = ave_skills_emp.index,
x= 'Average Score',
data = ave_skills_emp.sort_values(
'Average Score',
ascending = False
)
)
plt.xticks(np.arange(0,5.25,0.25))
plt.title('Average Score of the Employable Students')
st.pyplot(fig)
if selected == "Model Analysis":
st.header("Graphical Representation of the Model and its Accurace")
classifiers = [
'RandomForestClassifier',
'KNeighborsClassifier',
'LogisticRegressionCV',
'CategoricalNB',
'SGDClassifier',
'BernoulliNB',
'DecisionTreeClassifier',
'NuSVC',
'MultinomialNB',
'BernoulliNB',
'CategoricalNB',
'Perceptron',
'DecisionTreeRegressor',
'VotingClassifier',
'BaggingClassifier',
'VotingClassifier(GradientBoostingClassifier, AdaBoostClassifier)'
]
scores = [
0.909547739,
0.894472362,
0.594639866,
0.587939698,
0.587939698,
0.556113903,
0.909547739,
0.850921273,
0.556113903,
0.556113903,
0.587939698,
0.443886097,
-1, # You have a missing score for DecisionTreeRegressor
0.911222781,
0.909547739,
0.817420436
]
fig, ax = plt.subplots(figsize=(10, 10))
ax.barh(classifiers, scores, color='skyblue')
ax.set_xlabel('Accuracy Score')
ax.set_title('Classifier Performance')
ax.set_xlim(0, 1) # Set the x-axis limits between 0 and 1 for accuracy scores
# Display the scores on the bars
for i, score in enumerate(scores):
if score != -1:
ax.text(score, i, f' {score:.4f}', va='center', fontsize=12, color='black')
ax.invert_yaxis()
# Invert the y-axis to display the highest score at the top
ax.set_facecolor('none')
st.pyplot(fig)