Inspired by http://www.willmcginnis.com/2015/11/29/beyond-one-hot-an-exploration-of-categorical-variables/
$ python setup.py install
For a full categorical dataset:
from categorical_encoder.encoder_service import EncoderService
encoder_service = EncoderService(encoder_type='binary')
print encoder_service.fit_transform(
X=[
['red', 'car'],
['blue', 'car'],
['green', 'plane']
]
)
[[1, 0, 0], [0, 0, 0], [0, 1, 1]]
For a column:
from categorical_encoder.encoder_service import EncoderService
encoder_service = EncoderService(encoder_type='binary')
print encoder_service.fit_transform_column(name="color", column=[
'red', 'blue', 'green'
])
{'color_1': [0, 0, 1], 'color_0': [1, 0, 0]}
$ make demo
$ make test