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.

  • $\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_Data Jan 28 at 13:46

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.


Not the answer you're looking for? Browse other questions tagged or ask your own question.