In this example, the CSV Generator Snap contains employee data with categorical fields. The Copy Snap duplicates the data flow and feeds it into the Categorical to Numeric and Profile Snaps. The Profile Snap computes data statistics and sends them to the Categorical to Numeric Snap. The Categorical to Numeric Snap then converts the position values (categorical) into team numbers (numeric), based on the selected encoding methods.
The CSV Generator Snap contains employee data as shown below.
The Categorical to Numeric Snap contains two policies that assign employees to groups based on their position. Integer Encoding maps each position into an integer ($team_numer). One Hot Encoding creates a field for each position ($team_instructional_designer and $team_technical_writer).
The Profile Snap computes the value distribution of the input data, which is required by Integer Encoding and One Hot Encoding.
As you can see, the value distribution of $position contains "technical_writer" and "instructional_designer". Integer Encoding assigns values 1 and 2 to these, while One Hot Encoding creates a field for each of them.
The preview output of Categorical to Numeric Snap is shown below. This Snap adds 3 fields to the output.
- $team_number: This is the output of the first policy, where you use Integer Encoding to convert values in the $position field to numeric values.
- $team_instructional_designer and $team_technical_writer: These two fields are created by the second Policy. The first field indicates the "instructional_designer" position, and the second field indicates the "technical_writer" position.