-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transform.py
41 lines (33 loc) · 1.21 KB
/
Transform.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
class Transformer(object):
def __init__(self):
pass
def transform_objects_to_floats(self, adf, features_list):
for feat in features_list:
adf[feat] = adf[feat].astype(float)
def transform_floats_to_objects(self, adf, features_list):
for feat in features_list:
adf[feat] = adf[feat].astype(str)
def log_transform_positive_skew(self, adf, features_to_transform=None, skewness_threshold=1):
if not features_to_transform:
for feat in adf.columns:
if adf[feat].skew() > skewness_threshold:
adf[feat] = np.log1p(adf[feat])
elif features_to_transform:
for feat in adf.columns:
if adf[feat].skew() > skewness_threshold:
adf[feat] = np.log1p(adf[feat])
def categorical_label_encoder(self):
pass
def categorical_dummy_encoder(self):
pass
def high_cardinality_features_encoder(self):
pass
# def exp_transform_negative_skew(self, adf, features_to_transform=None, skewness_threshold=1):
# if not features_to_transform:
# for feat in adf.columns:
# if adf[feat].skew() < skewness_threshold:
# adf[feat] = np.exp(adf[feat])
# elif features_to_transform:
# for feat in adf.columns:
# if adf[feat].skew() < skewness_threshold:
# adf[feat] = np.exp(adf[feat])