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/
- Type: TabletrainDataInInput train data here. Dataframe may contain string or numeric features
- Type: TabletestDataInInput test data here. Dataframe may contain string or numeric features