paobranco/UBL

Distances with one hot encodings

Opened this issue · 1 comments

I have a dataset by which I am interest to apply SMOGN/SMOTER to it. The dataset has both numerical and nominal features. I am using machine learning models from sklearn and keras (yes in python, I am using rpy2 to apply SMOGN/SMOTER for communication between R and python) and they expect no strings at all in the data. Thats why I convert my nominal features to one hot encodings. However If I use 'HEOM' distance, noise is added and instead of having vectors of either 1 or 0 I am having 1.00001, 0.999, etc. How can I fix this ?? Please find below a snapshot of a 'SMOGN'-ed dataset:

numericalcategorical

The one hot encoded vectors are from columns service_General Medicine --> mohafaza_NE

SMOGN handles factors so you should just pass the non-one-hot encoded data in and encode it afterwards. Alternatively, you could declare those encoded columns as factors and it won't add noise but that wouldn't guaranteed one hot encoding in the result, as it would regard each column independently.