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?
closed as too broad by Siong Thye Goh, Toros91, Mark.F, oW_♦, Sean Owen Jan 26 at 4:25
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
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.