-
Notifications
You must be signed in to change notification settings - Fork 87
/
app.py
305 lines (264 loc) · 10.5 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
import os
import pandas as pd
import numpy as np
from tkinter import *
from tkinter import filedialog
import tkinter.font as font
from functools import partial
from pyresparser import ResumeParser
from sklearn import datasets, linear_model
class train_model:
def train(self):
data = pd.read_csv('training_dataset.csv')
array = data.values
for i in range(len(array)):
if array[i][0] == "Male":
array[i][0] = 1
else:
array[i][0] = 0
df = pd.DataFrame(array)
maindf = df[[0, 1, 2, 3, 4, 5, 6]]
mainarray = maindf.values
temp = df[7]
train_y = temp.values
self.mul_lr = linear_model.LogisticRegression(
multi_class='multinomial', solver='newton-cg', max_iter=1000)
self.mul_lr.fit(mainarray, train_y)
def test(self, test_data):
try:
test_predict = list()
for i in test_data:
test_predict.append(int(i))
y_pred = self.mul_lr.predict([test_predict])
return y_pred
except:
print("All Factors For Finding Personality Not Entered!")
def check_type(data):
if type(data) == str or type(data) == str:
return str(data).title()
if type(data) == list or type(data) == tuple:
str_list = ""
for i, item in enumerate(data):
str_list += item + ", "
return str_list
else:
return str(data)
def prediction_result(top, aplcnt_name, cv_path, personality_values):
"after applying a job"
top.withdraw()
applicant_data = {
"Candidate Name": aplcnt_name.get(),
"CV Location": cv_path
}
age = personality_values[1]
print("\n############# Candidate Entered Data #############\n")
print(applicant_data, personality_values)
personality = model.test(personality_values)
print("\n############# Predicted Personality #############\n")
print(personality)
data = ResumeParser(cv_path).get_extracted_data()
try:
del data['name']
if len(data['mobile_number']) < 10:
del data['mobile_number']
except:
pass
print("\n############# Resume Parsed Data #############\n")
for key in data.keys():
if data[key] is not None:
print('{} : {}'.format(key, data[key]))
result = Tk()
# result.geometry('700x550')
result.overrideredirect(False)
result.geometry("{0}x{1}+0+0".format(result.winfo_screenwidth(),
result.winfo_screenheight()))
result.configure(background='White')
result.title("Predicted Personality")
# Title
titleFont = font.Font(family='Arial', size=40, weight='bold')
Label(result,
text="Result - Personality Prediction",
foreground='green',
bg='white',
font=titleFont,
pady=10,
anchor=CENTER).pack(fill=BOTH)
Label(result,
text=str('{} : {}'.format("Name:", aplcnt_name.get())).title(),
foreground='black',
bg='white',
anchor='w').pack(fill=BOTH)
Label(result,
text=str('{} : {}'.format("Age:", age)),
foreground='black',
bg='white',
anchor='w').pack(fill=BOTH)
for key in data.keys():
if data[key] is not None:
Label(result,
text=str('{} : {}'.format(check_type(key.title()),
check_type(data[key]))),
foreground='black',
bg='white',
anchor='w',
width=60).pack(fill=BOTH)
Label(result,
text=str("perdicted personality: " + personality).title(),
foreground='black',
bg='white',
anchor='w').pack(fill=BOTH)
quitBtn = Button(result, text="Exit",
command=lambda: result.destroy()).pack()
terms_mean = """
# Openness:
People who like to learn new things and enjoy new experiences usually score high in openness. Openness includes traits like being insightful and imaginative and having a wide variety of interests.
# Conscientiousness:
People that have a high degree of conscientiousness are reliable and prompt. Traits include being organised, methodic, and thorough.
# Extraversion:
Extraversion traits include being; energetic, talkative, and assertive (sometime seen as outspoken by Introverts). Extraverts get their energy and drive from others, while introverts are self-driven get their drive from within themselves.
# Agreeableness:
As it perhaps sounds, these individuals are warm, friendly, compassionate and cooperative and traits include being kind, affectionate, and sympathetic. In contrast, people with lower levels of agreeableness may be more distant.
# Neuroticism:
Neuroticism or Emotional Stability relates to degree of negative emotions. People that score high on neuroticism often experience emotional instability and negative emotions. Characteristics typically include being moody and tense.
"""
Label(result,
text=terms_mean,
foreground='green',
bg='white',
anchor='w',
justify=LEFT).pack(fill=BOTH)
result.mainloop()
def perdict_person():
"""Predict Personality"""
# Closing The Previous Window
root.withdraw()
# Creating new window
top = Toplevel()
top.geometry('700x500')
top.configure(background='black')
top.title("Apply For A Job")
# Title
titleFont = font.Font(family='Helvetica', size=20, weight='bold')
lab = Label(top,
text="Personality Prediction",
foreground='red',
bg='black',
font=titleFont,
pady=10).pack()
# Job_Form
job_list = ('Select Job', '101-Developer at TTC', '102-Chef at Taj',
'103-Professor at MIT')
job = StringVar(top)
job.set(job_list[0])
l1 = Label(top, text="Applicant Name", foreground='white',
bg='black').place(x=70, y=130)
l2 = Label(top, text="Age", foreground='white', bg='black').place(x=70,
y=160)
l3 = Label(top, text="Gender", foreground='white', bg='black').place(x=70,
y=190)
l4 = Label(top, text="Upload Resume", foreground='white',
bg='black').place(x=70, y=220)
l5 = Label(top,
text="Enjoy New Experience or thing(Openness)",
foreground='white',
bg='black').place(x=70, y=250)
l6 = Label(top,
text="How Offen You Feel Negativity(Neuroticism)",
foreground='white',
bg='black').place(x=70, y=280)
l7 = Label(
top,
text="Wishing to do one's work well and thoroughly(Conscientiousness)",
foreground='white',
bg='black').place(x=70, y=310)
l8 = Label(
top,
text="How much would you like work with your peers(Agreeableness)",
foreground='white',
bg='black').place(x=70, y=340)
l9 = Label(
top,
text="How outgoing and social interaction you like(Extraversion)",
foreground='white',
bg='black').place(x=70, y=370)
sName = Entry(top)
sName.place(x=450, y=130, width=160)
age = Entry(top)
age.place(x=450, y=160, width=160)
gender = IntVar()
R1 = Radiobutton(top, text="Male", variable=gender, value=1, padx=7)
R1.place(x=450, y=190)
R2 = Radiobutton(top, text="Female", variable=gender, value=0, padx=3)
R2.place(x=540, y=190)
cv = Button(top, text="Select File", command=lambda: OpenFile(cv))
cv.place(x=450, y=220, width=160)
openness = Entry(top)
openness.insert(0, '1-10')
openness.place(x=450, y=250, width=160)
neuroticism = Entry(top)
neuroticism.insert(0, '1-10')
neuroticism.place(x=450, y=280, width=160)
conscientiousness = Entry(top)
conscientiousness.insert(0, '1-10')
conscientiousness.place(x=450, y=310, width=160)
agreeableness = Entry(top)
agreeableness.insert(0, '1-10')
agreeableness.place(x=450, y=340, width=160)
extraversion = Entry(top)
extraversion.insert(0, '1-10')
extraversion.place(x=450, y=370, width=160)
submitBtn = Button(top,
padx=2,
pady=0,
text="Submit",
bd=0,
foreground='white',
bg='red',
font=(12))
submitBtn.config(command=lambda: prediction_result(top, sName, loc, (
gender.get(), age.get(), openness.get(), neuroticism.get(),
conscientiousness.get(), agreeableness.get(), extraversion.get())))
submitBtn.place(x=350, y=400, width=200)
top.mainloop()
def OpenFile(b4):
global loc
name = filedialog.askopenfilename(
initialdir="C:/Users/Batman/Documents/Programming/tkinter/",
filetypes=(("Document", "*.docx*"), ("PDF", "*.pdf*"), ('All files',
'*')),
title="Choose a file.")
try:
filename = os.path.basename(name)
loc = name
except:
filename = name
loc = name
b4.config(text=filename)
return
if __name__ == "__main__":
model = train_model()
model.train()
root = Tk()
root.geometry('700x500')
root.configure(background='white')
root.title("Personality Prediction System")
titleFont = font.Font(family='Helvetica', size=25, weight='bold')
homeBtnFont = font.Font(size=12, weight='bold')
lab = Label(root,
text="Personality Prediction System",
bg='white',
font=titleFont,
pady=30).pack()
b2 = Button(root,
padx=4,
pady=4,
width=30,
text="Predict Personality",
bg='black',
foreground='white',
bd=1,
font=homeBtnFont,
command=perdict_person).place(relx=0.5,
rely=0.5,
anchor=CENTER)
root.mainloop()