Base.replaceFeatureWithBinaryFeatures

Base.replaceFeatureWithBinaryFeatures(featureToReplace, *, useLog=None)

Create binary features for each unique value in a feature.

Modify this object so that the chosen feature is removed, and binary valued features are added, one for each unique value seen in the original feature.

Parameters:
  • featureToReplace (int or str) – The index or name of the feature being replaced.

  • useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.

Returns:

list – The new feature names after replacement.

Examples

>>> lst = [['a'], ['b'], ['c']]
>>> X = nimble.data(lst, featureNames=['replace'])
>>> replaced = X.replaceFeatureWithBinaryFeatures('replace')
>>> replaced
['replace=a', 'replace=b', 'replace=c']
>>> X
<DataFrame 3pt x 3ft
     replace=a  replace=b  replace=c
   ┌────────────────────────────────
 0 │   1.000      0.000      0.000
 1 │   0.000      1.000      0.000
 2 │   0.000      0.000      1.000
>

Keywords: dummy, dummies, dummy variables, indicator, one-hot encoding, 1 hot encoding, one hot encoding, onehot encoding, categories, category, split, nominal, categorical, get_dummies