-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuns.py
More file actions
375 lines (348 loc) · 13.7 KB
/
funs.py
File metadata and controls
375 lines (348 loc) · 13.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
from ucimlrepo import fetch_ucirepo
marital_status = {
1: 'Single',
2: 'Married',
3: 'Widower',
4: 'Divorced',
5: 'Facto Union',
6: 'Legally Separated'
}
application_mode = {
1: '1st Phase General Contingent',
2: 'Ordinance No. 612/93',
5: '1st phase - special contingent (Azores Island)',
7: 'Holders of other higher courses',
10: 'Ordinance No. 854-B/99',
15: 'International student (bachelor)',
16: '1st phase - special contingent (Madeira Island)',
17: '2nd phase - general contingent',
18: '3rd phase - general contingent',
26: 'Ordinance No. 533-A/99, item b2) (Different Plan)',
27: 'Ordinance No. 533-A/99, item b3 (Other Institution)',
39: 'Over 23 years old',
42: 'Transfer',
43: 'Change of course',
44: 'Technological specialization diploma holders',
51: 'Change of institution/course',
53: 'Short cycle diploma holders',
57: 'Change of institution/course (International)'
}
course = {
33: 'Biofuel Production Technologies',
171: 'Animation and Multimedia Design',
8014: 'Social Service (evening attendance)',
9003: 'Agronomy',
9070: 'Communication Design',
9085: 'Veterinary Nursing',
9119: 'Informatics Engineering',
9130: 'Equinculture',
9147: 'Management',
9238: 'Social Service',
9254: 'Tourism',
9500: 'Nursing',
9556: 'Oral Hygiene',
9670: 'Advertising and Marketing Management',
9773: 'Journalism and Communication',
9853: 'Basic Education',
9991: 'Management (evening attendance)'
}
daytime_evening_attendance = {
1: 'Daytime',
0: 'Evening'
}
previous_qualification = {
1: 'Secondary education',
2: "Higher education - bachelor's degree",
3: 'Higher education - degree',
4: "Higher education - master's",
5: 'Higher education - doctorate',
6: 'Frequency of higher education',
9: '12th year of schooling - not completed',
10: '11th year of schooling - not completed',
12: 'Other - 11th year of schooling',
14: '10th year of schooling',
15: '10th year of schooling - not completed',
19: 'Basic education 3rd cycle (9th/10th/11th year) or equiv.',
38: 'Basic education 2nd cycle (6th/7th/8th year) or equiv.',
39: 'Technological specialization course',
40: 'Higher education - degree (1st cycle)',
42: 'Professional higher technical course',
43: 'Higher education - master (2nd cycle)'
}
nationality = {
1: 'Portugese',
2: 'German',
6: 'Spanish',
11: 'Italian',
13: 'Dutch',
14: 'English',
17: 'Lithuanian',
21: 'Angolan',
22: 'Cape Verdean',
24: 'Guinean',
25: 'Mozambican',
26: 'Santomean',
32: 'Turkish',
41: 'Brazilian',
62: 'Romanian',
100: 'Moldova (Republic of)',
101: 'Mexican',
103: 'Ukrainian',
105: 'Russian',
108: 'Cuban',
109: 'Colombian'
}
mothers_qualification = {
1: 'Secondary Education - 12th Year of Schooling or Eq.',
2: "Higher Education - Bachelor's Degree",
3: 'Higher Education - Degree',
4: "Higher Education - Master's",
5: 'Higher Education - Doctorate',
6: 'Frequency of Higher Education',
9: '12th Year of Schooling - Not Completed',
10: '11th Year of Schooling - Not Completed',
11: '7th Year (Old)',
12: 'Other - 11th Year of Schoolin',
14: '10th Year of Schooling',
18: 'General commerce course',
19: 'Basic Education 3rd Cycle (9th/10th/11th Year) or Equiv.',
22: 'Technical-professional course',
26: '7th year of schooling',
27: '2nd cycle of the general high school course',
29: '9th Year of Schooling - Not Completed',
30: '8th year of schooling',
34: 'Unknown',
35: "Can't read or write",
36: 'Can read without having a 4th year of schooling',
37: 'Basic education 1st cycle (4th/5th year) or equiv.',
38: 'Basic Education 2nd Cycle (6th/7th/8th Year) or Equiv.',
39: 'Technological specialization course',
40: 'Higher education - degree (1st cycl',
41: 'Specialized higher studies course',
42: 'Professional higher technical course',
43: 'Higher Education - Master (2nd cycle)',
44: 'Higher Education - Doctorate (3rd cycle)'
}
fathers_qualification = {
1: 'Secondary Education - 12th Year of Schooling or Eq.',
2: "Higher Education - Bachelor's Degree",
3: 'Higher Education - Degree',
4: "Higher Education - Master's",
5: 'Higher Education - Doctorate',
6: 'Frequency of Higher Education',
9: '12th Year of Schooling - Not Completed',
10: '11th Year of Schooling - Not Completed',
11: '7th Year (Old)',
12: 'Other - 11th Year of Schooling',
13: '2nd year complementary high school course',
14: '10th Year of Schooling',
18: 'General commerce course',
19: 'Basic Education 3rd Cycle (9th/10th/11th Year) or Equiv.',
20: 'Complementary High School Course',
22: 'Technical-professional course',
25: 'Complementary High School Course - not concluded',
26: '7th year of schooling',
27: '2nd cycle of the general high school course',
29: '9th Year of Schooling - Not Completed',
30: '8th year of schooling',
31: 'General Course of Administration and Commerce',
33: 'Supplementary Accounting and Administration',
34: 'Unknown',
35: "Can't read or write",
36: 'Can read without having a 4th year of schooling',
37: 'Basic education 1st cycle (4th/5th year) or equiv.',
38: 'Basic Education 2nd Cycle (6th/7th/8th Year) or Equiv.',
39: 'Technological specialization course',
40: 'Higher education - degree (1st cycle)',
41: 'Specialized higher studies course',
42: 'Professional higher technical course',
43: 'Higher Education - Master (2nd cycle)',
44: 'Higher Education - Doctorate (3rd cycle)'
}
mothers_occupation = {
0: 'Student',
1: 'Representatives of the Legislative Power and Executive Bodies, Directors, Directors and Executive Managers',
2: 'Specialists in Intellectual and Scientific Activities',
3: 'Intermediate Level Technicians and Professions',
4: 'Administrative staff',
5: 'Personal Services, Security and Safety Workers and Sellers',
6: 'Farmers and Skilled Workers in Agriculture, Fisheries and Forestry',
7: 'Skilled Workers in Industry, Construction and Craftsmen',
8: 'Installation and Machine Operators and Assembly Workers',
9: 'Unskilled Workers',
10: 'Armed Forces Professions',
90: 'Other Situation',
99: '(blank)',
122: 'Health professionals',
123: 'teachers',
125: 'Specialists in information and communication technologies (ICT)',
131: 'Intermediate level science and engineering technicians and professions',
132: 'Technicians and professionals, of intermediate level of health',
134: 'Intermediate level technicians from legal, social, sports, cultural and similar services',
141: 'Office workers, secretaries in general and data processing operators',
143: 'Data, accounting, statistical, financial services and registry-related operators',
144: 'Other administrative support staff',
151: 'personal service workers',
152: 'sellers',
153: 'Personal care workers and the like',
171: 'Skilled construction workers and the like, except electricians',
173: 'Skilled workers in printing, precision instrument manufacturing, jewelers, artisans and the like',
175: 'Workers in food processing, woodworking, clothing and other industries and crafts',
191: 'cleaning workers',
192: 'Unskilled workers in agriculture, animal production, fisheries and forestry',
193: 'Unskilled workers in extractive industry, construction, manufacturing and transport',
194: 'Meal preparation assistants'
}
fathers_occupation = {
0: 'Student',
1: 'Representatives of the Legislative Power and Executive Bodies, Directors, Directors and Executive Managers',
2: 'Specialists in Intellectual and Scientific Activities',
3: 'Intermediate Level Technicians and Professions',
4: 'Administrative staff',
5: 'Personal Services, Security and Safety Workers and Sellers',
6: 'Farmers and Skilled Workers in Agriculture, Fisheries and Forestry',
7: 'Skilled Workers in Industry, Construction and Craftsmen',
8: 'Installation and Machine Operators and Assembly Workers',
9: 'Unskilled Workers',
10: 'Armed Forces Professions',
90: 'Other Situation',
99: '(blank)',
101: 'Armed Forces Officers',
102: 'Armed Forces Sergeants',
103: 'Other Armed Forces personnel',
112: 'Directors of administrative and commercial services',
114: 'Hotel, catering, trade and other services directors',
121: 'Specialists in the physical sciences, mathematics, engineering and related techniques',
122: 'fathers_qualification',
123: 'teachers',
124: 'Specialists in finance, accounting, administrative organization, public and commercial relations',
131: 'Intermediate level science and engineering technicians and professions',
132: 'Technicians and professionals, of intermediate level of health',
134: 'Intermediate level technicians from legal, social, sports, cultural and similar services',
135: 'Information and communication technology technicians',
141: 'Office workers, secretaries in general and data processing operators',
143: 'Data, accounting, statistical, financial services and registry-related operators',
144: 'Other administrative support staff',
151: 'personal service workers',
152: 'sellers',
153: 'Personal care workers and the like',
154: 'Protection and security services personnel',
161: 'Market-oriented farmers and skilled agricultural and animal production workers',
163: 'Farmers, livestock keepers, fishermen, hunters and gatherers, subsistence',
171: 'Skilled construction workers and the like, except electricians',
172: 'Skilled workers in metallurgy, metalworking and similar',
174: 'Skilled workers in electricity and electronics',
175: 'Workers in food processing, woodworking, clothing and other industries and crafts',
181: 'Fixed plant and machine operators',
182: 'assembly workers',
183: 'Vehicle drivers and mobile equipment operators',
192: 'Unskilled workers in agriculture, animal production, fisheries and forestry',
193: 'Unskilled workers in extractive industry, construction, manufacturing and transport',
194: 'Meal preparation assistants',
195: 'Street vendors (except food) and street service providers'
}
displaced = {
1: 'Yes',
0: 'No'
}
educational_special_needs = {
1: 'Yes',
0: 'No'
}
debtor = {
1: 'Yes',
0: 'No'
}
tuition_fees_up_to_date = {
1: 'Yes',
0: 'No'
}
gender = {
1: 'Male',
0: 'Female'
}
scholarship_holder = {
1: 'Yes',
0: 'No'
}
international = {
1: 'Yes',
0: 'No'
}
def load_data():
dataset = fetch_ucirepo(id=697)
return dataset.data.original
def map_data(data):
data['Marital Status'] = data['Marital Status'].map(marital_status)
data['Application mode'] = data['Application mode'].map(application_mode)
data['Course'] = data['Course'].map(course)
data['Daytime/evening attendance'] = data['Daytime/evening attendance'].map(daytime_evening_attendance)
data['Previous qualification'] = data['Previous qualification'].map(previous_qualification)
data['Nacionality'] = data['Nacionality'].map(nationality)
data["Mother's qualification"] = data["Mother's qualification"].map(mothers_qualification)
data["Father's qualification"] = data["Father's qualification"].map(fathers_qualification)
data["Mother's occupation"] = data["Mother's occupation"].map(mothers_occupation)
data["Father's occupation"] = data["Father's occupation"].map(fathers_occupation)
data['Displaced'] = data['Displaced'].map(displaced)
data['Educational special needs'] = data['Educational special needs'].map(educational_special_needs)
data['Debtor'] = data['Debtor'].map(debtor)
data['Tuition fees up to date'] = data['Tuition fees up to date'].map(tuition_fees_up_to_date)
data['Scholarship holder'] = data['Scholarship holder'].map(scholarship_holder)
data['Gender'] = data['Gender'].map(gender)
data['International'] = data['International'].map(international)
data['Nationality'] = data['Nacionality']
data['Dropout'] = data['Target'] == 'Dropout'
data = data.drop(columns=['Nacionality'])
return data
def get_df():
data = load_data()
data = map_data(data)
return data
def correlations():
strong_cat = [
'Daytime/evening attendance',
'Debtor',
'Tuition fees up to date',
'Gender',
'Scholarship holder'
]
strong_num = [
'Curricular units 1st sem (grade)',
'Curricular units 2nd sem (grade)'
]
weak_cat = [
'Marital Status',
'Application mode',
'Course',
'Previous qualification',
"Mother's qualification",
"Father's qualification",
"Mother's occupation",
"Father's occupation",
'Displaced',
'Educational special needs',
'International'
]
weak_num = [
'Curricular units 1st sem (approved)',
'Curricular units 2nd sem (enrolled)',
'Curricular units 2nd sem (evaluations)',
'Curricular units 2nd sem (approved)',
'Inflation rate',
'GDP'
]
no_correlation_cat = [
'Application order',
'Nationality',
]
no_correlation_num = [
'Previous qualification (grade)',
'Admission grade',
'Unemployment rate',
'Curricular units 1st sem (credited)',
'Curricular units 1st sem (enrolled)',
'Curricular units 1st sem (evaluations)',
'Curricular units 2nd sem (credited)',
'Curricular units 2nd sem (without evaluations)'
]
return strong_cat, strong_num, weak_cat, weak_num, no_correlation_cat, no_correlation_num