Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,14 +25,39 @@ def predict(age, workclass, education, marital_status, occupation, relationship,
|
|
25 |
return print(fixed_features)
|
26 |
|
27 |
def cleaning_features(data):
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
numeric_cols = ['age', 'educational-num', 'hours-per-week']
|
32 |
columns_to_encode = ['race','marital-status','relationship']
|
33 |
|
34 |
data['gender'] = le.fit_transform(data['gender'])
|
35 |
-
data['educational-num'] =
|
36 |
data['workclass'] = le.fit_transform(data['workclass'])
|
37 |
data['occupation'] = le.fit_transform(data['occupation'])
|
38 |
|
|
|
25 |
return print(fixed_features)
|
26 |
|
27 |
def cleaning_features(data):
|
28 |
+
with open('race_onehot_encoder.pkl', 'rb') as enc_file:
|
29 |
+
encoder = pickle.load(enc_file)
|
30 |
+
|
31 |
+
with open('label_encoder.pkl', 'rb') as le_file:
|
32 |
+
le = pickle.load(le_file)
|
33 |
+
|
34 |
+
with open('scaler.pkl', 'rb') as scaler_file:
|
35 |
+
scaler = pickle.load(scaler_file)
|
36 |
+
|
37 |
+
education_num_mapping = {
|
38 |
+
"Preschool": 1,
|
39 |
+
"1st-4th": 2,
|
40 |
+
"5th-6th": 3,
|
41 |
+
"7th-8th": 4,
|
42 |
+
"9th": 5,
|
43 |
+
"10th": 6,
|
44 |
+
"11th": 7,
|
45 |
+
"12th": 8,
|
46 |
+
"HS-grad": 9,
|
47 |
+
"Some-college": 10,
|
48 |
+
"Assoc-voc": 11,
|
49 |
+
"Assoc-acdm": 12,
|
50 |
+
"Bachelors": 13,
|
51 |
+
"Masters": 14,
|
52 |
+
"Doctorate": 15,
|
53 |
+
"Prof-school": 16
|
54 |
+
}
|
55 |
+
|
56 |
numeric_cols = ['age', 'educational-num', 'hours-per-week']
|
57 |
columns_to_encode = ['race','marital-status','relationship']
|
58 |
|
59 |
data['gender'] = le.fit_transform(data['gender'])
|
60 |
+
data['educational-num'] = data['educational-num'].map(education_num_mapping)
|
61 |
data['workclass'] = le.fit_transform(data['workclass'])
|
62 |
data['occupation'] = le.fit_transform(data['occupation'])
|
63 |
|