-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
993 lines (859 loc) · 70.7 KB
/
app.py
File metadata and controls
993 lines (859 loc) · 70.7 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
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
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
import numpy as np
import pandas as pd
#import preprocessor as p
import counselor
from tensorflow.keras.models import load_model
import joblib
from pathlib import Path
from PIL import Image
import streamlit as st
import imagify
from bokeh.plotting import figure, output_file, show
import math
from bokeh.palettes import Greens
from bokeh.transform import cumsum
from bokeh.models import LabelSet, ColumnDataSource
#ap = Path.joinpath(Path.cwd(), 'models')
#dsp = Path.joinpath(Path.cwd(), 'dataset')
#model = load_model(Path.joinpath(artifacts_path, 'botmodel.h5'))
#tok = joblib.load(Path.joinpath(artifacts_path, 'tokenizer_t.pkl'))
#words = joblib.load(Path.joinpath(artifacts_path, 'words.pkl'))
#df2 = pd.read_csv(Path.joinpath(datasets_path, 'bot.csv'))
model = load_model('botmodel.h5')
tok = joblib.load('tokenizer_t.pkl')
words = joblib.load('words.pkl')
df2 = pd.read_csv('bot.csv')
flag=1
import string
import re
import json
import nltk
#run on the first time alone :
#nltk.download('wordnet')
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
def main():
lem = WordNetLemmatizer()
n=1
def tokenizer(x):
tokens = x.split()
rep = re.compile('[%s]' % re.escape(string.punctuation))
tokens = [rep.sub('', i) for i in tokens]
tokens = [i for i in tokens if i.isalpha()]
tokens = [lem.lemmatize(i.lower()) for i in tokens]
tokens = [i.lower() for i in tokens if len(i) > 1]
return tokens
def no_stop_inp(tokenizer,df,c):
no_stop = []
x = df[c][0]
tokens = tokenizer(x)
no_stop.append(' '.join(tokens))
df[c] = no_stop
return df
def inpenc(tok,df,c):
t = tok
x = x = [df[c][0]]
enc = t.texts_to_sequences(x)
padded = pad_sequences(enc, maxlen=16, padding='post')
return padded
def predinp(model,x):
pred = np.argmax(model.predict(x))
return pred
def botp(df3,pred):
l = df3.user[0].split()
if len([i for i in l if i in words])==0 :
pred = 1
return pred
def botop(df2,pred):
x2 = df2.groupby('labels').get_group(pred).shape[0]
idx1 = np.random.randint(0,x2)
op = list(df2.groupby('labels').get_group(pred).bot)
return op[idx1]
def botans(df3):
tok = joblib.load('tokenizer_t.pkl')
word = joblib.load('words.pkl')
df3 = no_stop_inp(tokenizer, df3, 'user')
inp = inpenc(tok, df3, 'user')
pred = predinp(model, inp)
pred = botp(df3, pred)
ans = botop(df2, pred)
return ans
def get_text():
x = st.text_input("You : ")
x=x.lower()
xx = x[:13]
if(xx =="start my test"):
global flag
flag=0
input_text = [x]
df_input = pd.DataFrame(input_text,columns=['user'])
return df_input
#flag=1
qvals = {"Select an Option": 0, "Strongly Agree": 5, "Agree": 4, "Neutral": 3, "Disagree": 2,
"Strongly Disagree": 1}
st.title("CounselBot")
banner=Image.open("img/21.png")
st.image(banner, use_column_width=True)
st.write("Hi! I'm CounselBot, your personal career counseling bot. Ask your queries in the text box below and hit enter. If and when you are ready to take our personality test, type \"start my test\" and you're good to go!")
df3 = get_text()
if (df3.loc[0, 'user']==""):
ans = "Hi, I'm CounselBot. \nHow can I help you?"
elif(flag==0):
#st.write(flag)
ans = "Sure, good luck!"
else:
ans = botans(df3)
st.text_area("CounselBot:", value=ans, height=100, max_chars=None)
if(flag==0):
#x=start_test()
#st.text_area("confirm", value="starting test", height=100, max_chars=None)
st.title("PERSONALITY TEST:")
#st.write("Would you like to begin with the test?")
kr = st.selectbox("Would you like to begin with the test?", ["Select an Option", "Yes", "No"])
if (kr == "Yes"):
kr1 = st.selectbox("Select level of education",
["Select an Option", "Grade 10", "Grade 12", "Undergraduate"])
##################################### GRADE 10 ###########################################
if(kr1=="Grade 10"):
lis = []
if (kr == "Yes"):
st.header("Question 1")
st.write("I find writing programs for computer applications interesting")
n = imagify.imageify(n)
inp = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"],
key='1')
if ((inp != "Select an Option")):
lis.append(qvals[inp])
st.header("Question 2")
st.write("I can understand mathematical problems with ease")
n = imagify.imageify(n)
inp2 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='2')
if (inp2 != "Select an Option"):
lis.append(qvals[inp2])
st.header("Question 3")
st.write("Learning about the existence of individual chemical components is interesting")
n = imagify.imageify(n)
inp3 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='3')
if (inp3 != "Select an Option"):
lis.append(qvals[inp3])
st.header("Question 4")
st.write("The way plants and animals thrive gets me curious")
n = imagify.imageify(n)
inp4 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='4')
if (inp4 != "Select an Option"):
lis.append(qvals[inp4])
st.header("Question 5")
st.write("Studying about the way fundamental constituents of the universe interact with each other is fascinating")
n = imagify.imageify(n)
inp5 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='5')
if (inp5 != "Select an Option"):
lis.append(qvals[inp5])
st.header("Question 6")
st.write(
"Accounting and business management is my cup of tea")
n = imagify.imageify(n)
inp6 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='6')
if (inp6 != "Select an Option"):
lis.append(qvals[inp6])
st.header("Question 7")
st.write(
"I would like to know more about human behaviour, relations and patterns of thinking")
n = imagify.imageify(n)
inp7 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='7')
if (inp7 != "Select an Option"):
lis.append(qvals[inp7])
st.header("Question 8")
st.write(
"I find the need to be aware of stories from the past.")
n = imagify.imageify(n)
inp8 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='8')
if (inp8 != "Select an Option"):
lis.append(qvals[inp8])
st.header("Question 9")
st.write(
"I see myself as a sportsperson/professional trainer")
n = imagify.imageify(n)
inp9 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='9')
if (inp9 != "Select an Option"):
lis.append(qvals[inp9])
st.header("Question 10")
st.write(
"I enjoy creating works of art")
n = imagify.imageify(n)
inp10 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='10')
if (inp10 != "Select an Option"):
lis.append(qvals[inp10])
st.success("Test Completed")
#st.write(lis)
st.title("RESULTS:")
df = pd.read_csv(r"Subjects.csv")
input_list = lis
subjects = {1: "Computers",
2: "Mathematics",
3: "Chemistry",
4: "Biology",
5: "Physics",
6: "Commerce",
7: "Psychology",
8: "History",
9: "Physical Education",
10: "Design"}
def output(listofanswers):
class my_dictionary(dict):
def __init__(self):
self = dict()
def add(self, key, value):
self[key] = value
ques = my_dictionary()
for i in range(0, 10):
ques.add(i, input_list[i])
all_scores = []
for i in range(9):
all_scores.append(ques[i] / 5)
li = []
for i in range(len(all_scores)):
li.append([all_scores[i], i])
li.sort(reverse=True)
sort_index = []
for x in li:
sort_index.append(x[1] + 1)
all_scores.sort(reverse=True)
a = sort_index[0:5]
b = all_scores[0:5]
s = sum(b)
d = list(map(lambda x: x * (100 / s), b))
return a, d
l, data = output(input_list)
out = []
for i in range(0, 5):
n = l[i]
c = subjects[n]
out.append(c)
output_file("pie.html")
graph = figure(title="Recommended subjects", height=500,
width=500)
radians = [math.radians((percent / 100) * 360) for percent
in data]
start_angle = [math.radians(0)]
prev = start_angle[0]
for i in radians[:-1]:
start_angle.append(i + prev)
prev = i + prev
end_angle = start_angle[1:] + [math.radians(0)]
x = 0
y = 0
radius = 0.8
color = Greens[len(out)]
graph.xgrid.visible = False
graph.ygrid.visible = False
graph.xaxis.visible = False
graph.yaxis.visible = False
for i in range(len(out)):
graph.wedge(x, y, radius,
start_angle=start_angle[i],
end_angle=end_angle[i],
color=color[i],
legend_label=out[i] + "-" + str(
round(data[i])) + "%")
graph.add_layout(graph.legend[0], 'right')
st.bokeh_chart(graph, use_container_width=True)
labels = LabelSet(x='text_pos_x', y='text_pos_y',
text='percentage', level='glyph',
angle=0, render_mode='canvas')
graph.add_layout(labels)
st.header('More information on the subjects')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(subjects[int(l[i])])
st.write(df['about'][int(l[i]) - 1])
st.header('Choice of Degrees')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(subjects[int(l[i])])
st.write(df['further career'][int(l[i]) - 1])
st.header('Trends over the years')
# We'll be using a csv file for that
def Convert(string):
li = list(string.split(","))
li = list(map(float, li))
return li
x = ['2000', '2005', '2010', '2015', '2020']
y = []
for i in range(0, 5):
t = Convert(df['trends'][int(l[i]) - 1])
y.append(t)
output_file("line.html")
graph2 = figure(title="Trends")
graph2.line(x, y[0], line_color="Purple",
legend_label=out[0])
graph2.line(x, y[1], line_color="Blue",
legend_label=out[1])
graph2.line(x, y[2], line_color="Green",
legend_label=out[2])
graph2.line(x, y[3], line_color="Magenta",
legend_label=out[3])
graph2.line(x, y[4], line_color="Red",
legend_label=out[4])
graph2.add_layout(graph2.legend[0], 'right')
st.bokeh_chart(graph2, use_container_width=True)
banner1 = Image.open("img/coun.png")
st.image(banner1, use_column_width=True)
st.header("Contacts of experts from various fields")
for i in range(0, 5):
st.subheader(subjects[int(l[i])])
xl=(df['contacts'][int(l[i]) - 1]).split(",")
for k in xl:
ml=list(k.split(","))
for kk in ml:
st.write(kk,sep="\n")
########################################## GRADE 12 ########################################################
elif (kr1 == "Grade 12"):
lis = []
st.header("Question 1")
st.write("I enjoy debating and negotiating issues in public")
n = imagify.imageify(n)
inp = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"],
key='1')
if ((inp != "Select an Option")):
lis.append(qvals[inp])
st.header("Question 2")
st.write("Studying the anatomy of the human body and giving first aid to people is something I'm always looking forward to")
n = imagify.imageify(n)
inp2 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='2')
if (inp2 != "Select an Option"):
lis.append(qvals[inp2])
st.header("Question 3")
st.write("I can lead a team and easily manage projects")
n = imagify.imageify(n)
inp3 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='3')
if (inp3 != "Select an Option"):
lis.append(qvals[inp3])
st.header("Question 4")
st.write("Working with tools, equipment, and machinery is enjoyable")
n = imagify.imageify(n)
inp4 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='4')
if (inp4 != "Select an Option"):
lis.append(qvals[inp4])
st.header("Question 5")
st.write(
"Budgeting, costing and estimating for a business isn't exhausting")
n = imagify.imageify(n)
inp5 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='5')
if (inp5 != "Select an Option"):
lis.append(qvals[inp5])
st.header("Question 6")
st.write(
"I can see myself taking part in competitive sporting events to become a professional")
n = imagify.imageify(n)
inp6 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='6')
if (inp6 != "Select an Option"):
lis.append(qvals[inp6])
st.header("Question 7")
st.write(
"I don't burn out while doing translations, reading and correcting language")
n = imagify.imageify(n)
inp7 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='7')
if (inp7 != "Select an Option"):
lis.append(qvals[inp7])
st.header("Question 8")
st.write(
"I would love to act in or direct a play or film")
n = imagify.imageify(n)
inp8 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='8')
if (inp8 != "Select an Option"):
lis.append(qvals[inp8])
st.header("Question 9")
st.write(
"Making sketches of people or landscapes is a hobby I see as a career")
n = imagify.imageify(n)
inp9 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='9')
if (inp9 != "Select an Option"):
lis.append(qvals[inp9])
st.header("Question 10")
st.write(
"I can easily work with numbers and calculations most of the time")
n = imagify.imageify(n)
inp10 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='10')
if (inp10 != "Select an Option"):
lis.append(qvals[inp10])
st.header("Question 11")
st.write(
"I enjoy doing clerical work i.e. filing, counting stock and issuing receipts")
n = imagify.imageify(n)
inp11 = st.selectbox("",
["Select an Option", "Strongly Agree",
"Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='11')
if (inp11 != "Select an Option"):
lis.append(qvals[inp11])
st.header("Question 12")
st.write(
"I love studying the culture and life style of human societies")
n = imagify.imageify(n)
inp12 = st.selectbox("",
["Select an Option", "Strongly Agree",
"Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='12')
if (inp12 != "Select an Option"):
lis.append(qvals[inp12])
st.header("Question 13")
st.write(
"Teaching children and young people is something I see myself doing on a daily basis")
n = imagify.imageify(n)
inp13 = st.selectbox("",
["Select an Option",
"Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='13')
if (inp13 != "Select an Option"):
lis.append(qvals[inp13])
st.header("Question 14")
st.write(
"I won't have a problem persevering in the army or police force")
n = imagify.imageify(n)
inp14 = st.selectbox("",
["Select an Option",
"Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"],
key='14')
if (inp14 != "Select an Option"):
lis.append(qvals[inp14])
st.header("Question 15")
st.write(
"Introducing consumers to new products and convincing them to buy the same is something that comes with ease")
n = imagify.imageify(n)
inp15 = st.selectbox("",
["Select an Option",
"Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"],
key='15')
if (inp15 != "Select an Option"):
lis.append(qvals[inp10])
st.success("Test Completed")
#st.write(lis)
st.title("RESULTS:")
df = pd.read_csv(r"Graduate.csv")
input_list = lis
streams = {1: "Law",
2: "Healthcare",
3: "Management",
4: "Engineering",
5: "Finance",
6: "Sports",
7: "Language and communication",
8: "Performing Arts",
9: "Applied and Visual arts",
10: "Science and math",
11: "Clerical and secretarial",
12: "Social Science",
13: "Education and Social Support",
14: "Armed Forces",
15: "Marketing and sales"}
def output(listofanswers):
class my_dictionary(dict):
def __init__(self):
self = dict()
def add(self, key, value):
self[key] = value
ques = my_dictionary()
for i in range(0, 15):
ques.add(i, input_list[i])
all_scores = []
for i in range(14):
all_scores.append(ques[i] / 5)
li = []
for i in range(len(all_scores)):
li.append([all_scores[i], i])
li.sort(reverse=True)
sort_index = []
for x in li:
sort_index.append(x[1] + 1)
all_scores.sort(reverse=True)
a = sort_index[0:5]
b = all_scores[0:5]
s = sum(b)
d = list(
map(lambda x: x * (100 / s), b))
return a, d
l, data = output(input_list)
out = []
for i in range(0, 5):
n = l[i]
c = streams[n]
out.append(c)
output_file("pie.html")
graph = figure(title="Recommended fields",
height=500, width=500)
radians = [
math.radians((percent / 100) * 360) for
percent in data]
start_angle = [math.radians(0)]
prev = start_angle[0]
for i in radians[:-1]:
start_angle.append(i + prev)
prev = i + prev
end_angle = start_angle[1:] + [
math.radians(0)]
x = 0
y = 0
radius = 0.8
color = Greens[len(out)]
graph.xgrid.visible = False
graph.ygrid.visible = False
graph.xaxis.visible = False
graph.yaxis.visible = False
for i in range(len(out)):
graph.wedge(x, y, radius,
start_angle=start_angle[i],
end_angle=end_angle[i],
color=color[i],
legend_label=out[
i] + "-" + str(
round(data[i])) + "%")
graph.add_layout(graph.legend[0],
'right')
st.bokeh_chart(graph,
use_container_width=True)
labels = LabelSet(x='text_pos_x',
y='text_pos_y',
text='percentage',
level='glyph',
angle=0,
render_mode='canvas')
graph.add_layout(labels)
st.header(
'More information on the fields')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(streams[int(l[i])])
st.write(df['About'][int(l[i]) - 1])
st.header('Average annual salary')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(streams[int(l[i])])
st.write("Rs. "+ str(
df['avgsal'][int(l[i]) - 1]))
st.header('Trends over the years')
# We'll be using a csv file for that
def Convert(string):
li = list(string.split(","))
li = list(map(float, li))
return li
x = ['2000', '2005', '2010', '2015', '2020']
y = []
for i in range(0, 5):
t = Convert(df['trends'][int(l[i]) - 1])
y.append(t)
output_file("line.html")
graph2 = figure(title="Trends")
graph2.line(x, y[0], line_color="Purple",
legend_label=out[0])
graph2.line(x, y[1], line_color="Blue",
legend_label=out[1])
graph2.line(x, y[2], line_color="Green",
legend_label=out[2])
graph2.line(x, y[3], line_color="Magenta",
legend_label=out[3])
graph2.line(x, y[4], line_color="Red",
legend_label=out[4])
graph2.add_layout(graph2.legend[0], 'right')
st.bokeh_chart(graph2,
use_container_width=True)
banner1 = Image.open("img/coun.png")
st.image(banner1, use_column_width=True)
st.header(
"Contacts of experts from various fields")
for i in range(0, 5):
st.subheader(streams[int(l[i])])
xl = (
df['contacts'][int(l[i]) - 1]).split(
",")
for k in xl:
ml = list(k.split(","))
for kk in ml:
st.write(kk, sep="\n")
###################################### UNDERGRADUATE ##########################################
elif (kr1 == "Undergraduate"):
lis = []
if (kr == "Yes"):
st.header("Question 1")
st.write("I can be the person who handles all aspects of information security and protects the virtual data resources of a company")
n = imagify.imageify(n)
inp = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"],
key='1')
if ((inp != "Select an Option")):
lis.append(qvals[inp])
st.header("Question 2")
st.write("I enjoy studying business and information requirements of an organisation and using this data to develop processes that help achieve strategic goals.")
n = imagify.imageify(n)
inp2 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='2')
if (inp2 != "Select an Option"):
lis.append(qvals[inp2])
st.header("Question 3")
st.write("I can assess a problem and design a brand new system or improve an existing system to make it better and more efficient. ")
n = imagify.imageify(n)
inp3 = st.selectbox("", ["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='3')
if (inp3 != "Select an Option"):
lis.append(qvals[inp3])
st.header("Question 4")
st.write("Designing, developing, modifying, editing and working with databases and large datasets is my cup of tea")
n = imagify.imageify(n)
inp4 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral", "Disagree",
"Strongly Disagree"], key='4')
if (inp4 != "Select an Option"):
lis.append(qvals[inp4])
st.header("Question 5")
st.write(
"I can mine data using BI software tools, compare, visualize and communicate the results with ease")
n = imagify.imageify(n)
inp5 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='5')
if (inp5 != "Select an Option"):
lis.append(qvals[inp5])
st.header("Question 6")
st.write(
"Implementing and providing support for Microsoft's Dynamics CRM is a skill I possess")
n = imagify.imageify(n)
inp6 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='6')
if (inp6 != "Select an Option"):
lis.append(qvals[inp6])
st.header("Question 7")
st.write(
"I can be innovative and creative when it comes to making user-friendly mobile applications")
n = imagify.imageify(n)
inp7 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree", "Neutral",
"Disagree",
"Strongly Disagree"], key='7')
if (inp7 != "Select an Option"):
lis.append(qvals[inp7])
st.header("Question 8")
st.write(
"I can perform well in a varied discipline, combining aspects of psychology, business, market research, design, and technology.")
n = imagify.imageify(n)
inp8 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='8')
if (inp8 != "Select an Option"):
lis.append(qvals[inp8])
st.header("Question 9")
st.write(
"I am responsible enough to maintain the quality systems, such as laboratory control and document control and training, to ensure control of the manufacturing process.")
n = imagify.imageify(n)
inp9 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='9')
if (inp9 != "Select an Option"):
lis.append(qvals[inp9])
st.header("Question 10")
st.write(
"Be it front-end or back-end, I would love designing and developing websites more than anything else")
n = imagify.imageify(n)
inp10 = st.selectbox("",
["Select an Option", "Strongly Agree", "Agree",
"Neutral",
"Disagree",
"Strongly Disagree"], key='10')
if (inp10 != "Select an Option"):
lis.append(qvals[inp10])
st.success("Test Completed")
#st.write(lis)
st.title("RESULTS:")
df = pd.read_csv(r'Occupations.csv', encoding= 'windows-1252')
input_list = lis
professions = {1: "Systems Security Administrator",
2: "Business Systems Analyst",
3: "Software Systems Engineer",
4: "Database Developer",
5: "Business Intelligence Analyst",
6: "CRM Technical Developer",
7: "Mobile Applications Developer",
8: "UX Designer",
9: "Quality Assurance Associate",
10: "Web Developer"}
def output(listofanswers):
class my_dictionary(dict):
def __init__(self):
self = dict()
def add(self, key, value):
self[key] = value
ques = my_dictionary()
for i in range(0, 10):
ques.add(i, input_list[i])
all_scores = []
for i in range(9):
all_scores.append(ques[i] / 5)
li = []
for i in range(len(all_scores)):
li.append([all_scores[i], i])
li.sort(reverse=True)
sort_index = []
for x in li:
sort_index.append(x[1] + 1)
all_scores.sort(reverse=True)
a = sort_index[0:5]
b = all_scores[0:5]
s = sum(b)
d = list(map(lambda x: x * (100 / s), b))
return a, d
l, data = output(input_list)
out = []
for i in range(0, 5):
n = l[i]
c = professions[n]
out.append(c)
output_file("pie.html")
graph = figure(title="Recommended professions", height=500,
width=500)
radians = [math.radians((percent / 100) * 360) for percent
in data]
start_angle = [math.radians(0)]
prev = start_angle[0]
for i in radians[:-1]:
start_angle.append(i + prev)
prev = i + prev
end_angle = start_angle[1:] + [math.radians(0)]
x = 0
y = 0
radius = 0.8
color = Greens[len(out)]
graph.xgrid.visible = False
graph.ygrid.visible = False
graph.xaxis.visible = False
graph.yaxis.visible = False
for i in range(len(out)):
graph.wedge(x, y, radius,
start_angle=start_angle[i],
end_angle=end_angle[i],
color=color[i],
legend_label=out[i] + "-" + str(
round(data[i])) + "%")
graph.add_layout(graph.legend[0], 'right')
st.bokeh_chart(graph, use_container_width=True)
labels = LabelSet(x='text_pos_x', y='text_pos_y',
text='percentage', level='glyph',
angle=0, render_mode='canvas')
graph.add_layout(labels)
st.header('More information on the professions')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(professions[int(l[i])])
st.write(df['Information'][int(l[i]) - 1])
st.header('Monthly Income')
# We'll be using a csv file for that
for i in range(0, 5):
st.subheader(professions[int(l[i])])
st.write("Rs. " + str(df['Income'][int(l[i]) - 1]))
st.header('Trends over the years')
# We'll be using a csv file for that
def Convert(string):
li = list(string.split(","))
li = list(map(float, li))
return li
x = ['2000', '2005', '2010', '2015', '2020']
y = []
for i in range(0, 5):
t = Convert(df['trends'][int(l[i]) - 1])
y.append(t)
output_file("line.html")
graph2 = figure(title="Trends")
graph2.line(x, y[0], line_color="Purple",
legend_label=out[0])
graph2.line(x, y[1], line_color="Blue", legend_label=out[1])
graph2.line(x, y[2], line_color="Green",
legend_label=out[2])
graph2.line(x, y[3], line_color="Magenta",
legend_label=out[3])
graph2.line(x, y[4], line_color="Red", legend_label=out[4])
graph2.add_layout(graph2.legend[0], 'right')
st.bokeh_chart(graph2, use_container_width=True)
banner1 = Image.open("img/coun.png")
st.image(banner1, use_column_width=True)
st.header("Contacts of experts from various fields")
for i in range(0, 5):
st.subheader(professions[int(l[i])])
xl=(df['contacts'][int(l[i]) - 1]).split(",")
for k in xl:
ml=list(k.split(","))
for kk in ml:
st.write(kk,sep="\n")
if __name__=="__main__":
main()