I am trying to predict soccer scores using past results. The dataset I have only consists of the home team, the away team, goals scored by the home team and goals scored by the away team in each match. How can I use the limited data on my dataset to model this using a random forest algorithm and the naive bayes algorithm?
-
$\begingroup$ Why are you limiting yourself to those two models? There are plenty of more models you can use, particularly around soccer. In some cases, you may not need a model at all, per-se, when some applied statistics can get you to a pretty good answer too. $\endgroup$– I_Play_With_DataJan 28, 2019 at 13:46
2 Answers
You have two categorical features (team names) and two continuous features (goals scored). The continuous features will probably remain bounded at a lower value since soccer isn't typically a high scoring game, so no normalization will be necessary.
You may need dummy variables for the team names, as the text names will likely not play well as a feature for most classification libraries. Research the sklearn Ordinal Encoder for this task.
Look at the sklearn classification algorithms that are available and try implementing a few of those.
Your response variables will be the two predicted scores. One for home and one for away. Or you may decide that the response variable could simply be one 'spread ' feature for the expected spread of the score.
Steven's answer is correct but it leaves you with challenging decisions when choosing what data to use in the past. Recent data is more predictive of future games than data from years ago.
I better solution may be to use something like the elo ratings system that assumes each team has some sort of skill level that varies from game to game. Each teams elo rating is then updated after each game win or lose based on the winners and losers. Nate Silver is popular for using elo in his sports forecasts.