Despite the fact that this problem is probably overdone and heavily researched, I want to use machine learning to solve problems related to basketball (predicting which team will win the game, will a certain shot go in, etc.). To do that, I want to encode information about the line-ups, because ultimately the starting line-up for both teams will have a huge impact on a team's performance and ultimately their ability to win a game (eg. Cavs' chance of winning a game is significantly lower without Lebron, and much higher if Kevin Durant is not playing).
Given the player name (or some unique id to identify the player) is a categorical variable, how do I encode this to fit the appropriate format for prediction tasks? Ideally, I do not want to create a ton of binary variables for each player in the NBA (which represents whether the given player will play or not). I was thinking of tackling this problem with Python/sci-kit learn, which I usually feed in numpy arrays. Is it possible to modify my data to still use numpy/sci-kit for the prediction task?
Similarly, another variable would be the opponent team (LAL, GSW, BOS, etc). There are significantly fewer choices than the number of players of course, but still 29 which is a considerable amount. While I could create 30 binary variables, is there another option? If I match each team to a number, is that legitimate (If so, are there any downsides? If not, can you expand on why? I am somewhat reluctant because it is unclear what these numbers would actually represent.)
I have read a few articles about encoding categorical variables, and it seems like a fuzzy area. I did not see any clear/obvious answers and could always use the guidance and expertise. If you have any ideas, suggestions, or relevant videos/blogs/papers, please let me know.
feature hashing
(implemented in sklearn) which will lead to some 'collisions' between players. If you think about using neural nets, you can read about theEmbedding
layer (e.g. in Keras). This will transform your out to a fixed length vector. Players with 'similar' performances or whatever will be closer in that vector space. $\endgroup$