Auto Categorical Features Embedding

This component encodes string (categorical) features into numeric features. Features created are: a) value-counts of categorical variables (count encoding), b) ranked label-count encoding, and c) target-encoding. Multiple categorical variables (string type) may be specified at one go.
As Input, it takes train and test datasets. You have to specify:

a. Target column name
b. String columns to be encoded
c. Type of categorical encoding desired
d. Perform PCA or not

To avoid (as also check) data leakage while performing 'target-encoding', encoding is performed using only train data. The encoded values are then mapped to test data. To have reliable target encoding, dataset should generally be large.
The component (optionally) performs PCA on the DataFrame consisting of either of these three or all three encodings along with on the numeric features already present. PCA model is built on train data and applied on test data. Principal components explain 95% of variance. The output of component are two dataframes, train and test. These dataframes have Principal components (or encoded columns along with already present numeric columns). The output dataframes include target column.
The component uses python script. Python libraries used are numpy, pandas, scikit-learn and pyarrow. To speed up categorical feature generation, please reach File > Preferences > KNIME > Python > Serialization library and select Apache Arrow as Serialization library. For a description of the three methods of encoding, please refer: https://wrosinski.github.io/fe_categorical_encoding/

Options

4.Select string columns to be encoded (keep 'target' column in the left panel)
Select those string columns for which you would like to perform encoding.
1.Select target column. Must be of string type.
Target column must be of string type
2.Select type of encoding to be performed
Select one from among the four choices
3.Perform PCA? (Yes/No)
Should PCA be performed? PCA will be performed both on encoded columns and already existing numeric columns

Input Ports

Icon
Input train data here. Dataframe may contain string or numeric features
Icon
Input test data here. Dataframe may contain string or numeric features

Output Ports

Icon
Transformed train data. Output is either the encoded columns or PCA encoded DataFrame with target column
Icon
Transformed test data. Output is either the encoded columns or PCA encoded DataFrame with target column

Nodes

Extensions

Links