When creating artificial columns for your categorical variables there are two mainstream methods you could use:
Disclaimer: For this example, I use the following definitions of dummy variables and one-hot-encoding. I'm aware both methods can be used to either return n
or n-1
columns.
Dummy variables: each category is converted to it's own column and the value 0 or 1 indicates if that category is present for each record
one-hot-encoding: similar to dummy variables, but one column is dropped, as its value can be derived from the other columns. This is to prevent multicollinearity and the dummy variable trap.
As an arbitrary example, let's take people's favorite color: pink, blue and green. For a person who's favorite color is pink, the dummy and one-hot-encoded data would look as follows:
dummy variables
person_id | favorite_color_pink | favorite_color_blue | favorite_color_green |
---|---|---|---|
xyz | 1 | 0 | 0 |
one-hot-encoded variables
person_id | favorite_color_blue | favorite_color_green |
---|---|---|
xyz | 0 | 0 |
From a statistics point of view, I would use the one-hot encoded columns to build my model. In addition, I can infer the favorite color is pink, because I encoded the variables.
However, when I'm applying XAI to explain the prediction to someone else and they see the favorite color wasn't blue or green. I'm not so sure they will infer the favorite color was pink unless it's explicitly stated. So using dummy variables might serve explainability better, but brings other risks..
Are there any best practices on this?