Skip to content

Commit b4f5d49

Browse files
minor cleanup in contrast coders and changelog
1 parent 55aa205 commit b4f5d49

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
unreleased
2+
==========
3+
* Added base class for contrast coding schemes in order to make them more maintainable
4+
* Added hierarchical column feature in target encoder
5+
* Fixed maximum recursion depth bug in hashing encoder
6+
17
v2.5.0
28
======
39

category_encoders/base_contrast_encoder.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,10 @@ def fit_contrast_coding(self, col, values, handle_missing, handle_unknown):
117117
return df
118118

119119
@staticmethod
120-
def transform_contrast_coding(X_in, mapping):
121-
"""
122-
"""
123-
124-
X = X_in.copy(deep=True)
125-
120+
def transform_contrast_coding(X, mapping):
126121
cols = X.columns.values.tolist()
127122

128-
# todo why is this necessary
123+
# See issue 370 if it is necessary to add an intercept or not.
129124
X['intercept'] = pd.Series([1] * X.shape[0], index=X.index)
130125

131126
for switch in mapping:
@@ -140,6 +135,8 @@ def transform_contrast_coding(X_in, mapping):
140135
old_column_index = cols.index(col)
141136
cols[old_column_index: old_column_index + 1] = mod.columns
142137

138+
# this could lead to problems if an intercept column is already present
139+
# (e.g. if another column has been encoded with another contrast coding scheme)
143140
cols = ['intercept'] + cols
144141

145142
return X.reindex(columns=cols)

category_encoders/helmert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from category_encoders.base_contrast_encoder import BaseContrastEncoder
88

9-
__author__ = 'willmcginnis'
9+
__author__ = 'paulwestenthanner'
1010

1111

1212
class HelmertEncoder(BaseContrastEncoder):

0 commit comments

Comments
 (0)