# How to handle One Hot Encoded columns with changing categories in supervised ML Problem?

Scenario:

I have the following game data about participants, game and the winner in the following format:

id  game        player  winner
-----------------------------------
1   Monopoly    Paul    Paul
1   Monopoly    Frank   Paul
1   Monopoly    Sandra  Paul
2   Monopoly    Peter   Katie
2   Monopoly    Paul    Katie
2   Monopoly    Erwin   Katie
2   Monopoly    Katie   Katie


So the table above shows information about two sessions of monopoly that have been played, the first one with Frank, Paul (Winner) and Sandra; The second one with Peter, Paul, Erwin and Katie (Winner).

My question is: If I want to predict the Winner of a game, how would I transform the data so that each row corresponds to one session?

Idea 1

My initial idea is of course to one hot encode the "player" feature:

id  game        Paul    Frank   Sandra  Peter   Erwin   Katie   winner
-------------------------------------------------------------------------------
1   Monopoly    1       1       1       0       0       0       Paul
2   Monopoly    1       0       0       1       1       1       Katie


That way, it would be easy to predict the target with a simple model.

However, if I want to predict a winner of a new monopoly session with players Sandra, Erwin, Katie and Tim (New Player), the transformed (i.e. one hot encoded) data would have one more column. This column is unknown to the model and thus cannot be processed.

Idea 2

Take Idea 1, add a "new player" binary dummy column (the new player name does not contain any useful information anyway), store the winner, retrain the model with the new (additional) information. However, if I play with multiple new players, this would not work (unless I add multiple dummy columns, which would be quite inflexible).

Idea 3

Monopoly can be played with 2 to 8 players, so I could change the table structure to the following:

id  game        Pl_0    Pl_1    Pl_2    Pl_3    Pl_4    Pl_5    Pl_6    Pl_7    winner
---------------------------------------------------------------------------------------
1   Monopoly    Paul    Frank   Sandra  None    None    None    None    None    Paul
2   Monopoly    Peter   Paul    Erwin   Katie   None    None    None    None    Katie


However, the problem with this approach is of course the structure assumes that the is a semantic meaning behind which player takes which "seat": In game 1, Paul was Player 0 (i.e. the value of Pl_0 is "Paul") but in game 2, Paul was Player 1 (i.e. the value of Pl_1 is "Paul"). In this structure, the model cannot know that it makes no (semantic) difference, whether Paul is Player 1 or 2. Furthermore, a game that can be played with 10 players cannot be mapped like that. So rejected that idea pretty quickly. Or is there any way to overcome this problem?

Final Question

How would I be able to predict the winner of a game, such that

• the model can handle new (unseen) players
• the model can handle multiple games with different numbers of players