Soccer Predictor

A JS library that predicts soccer match outcomes using basic mathematics.
Installation
Use yarn or npm to install.
yarn add soccer-predictor # yarn
npm install soccer-predictor --save # npm
Install locally
git clone https://github.com/CookPete/soccer-predictor.git
cd soccer-predictor
yarn # or npm install
npm run build
Testing locally
npm test # Run tests
Usage
import { analyseResults, calculateProbabilities } from 'soccer-predictor'
const results = [
{ homeTeam: 'Team A', awayTeam: 'Team B', homeGoals: 1, awayGoals: 0 },
{ homeTeam: 'Team B', awayTeam: 'Team C', homeGoals: 2, awayGoals: 1 },
{ homeTeam: 'Team C', awayTeam: 'Team A', homeGoals: 1, awayGoals: 3 }
]
function getMatchDetails (match) {
return {
homeTeamName: match.homeTeam,
awayTeamName: match.awayTeam,
homeGoals: match.homeGoals,
awayGoals: match.awayGoals
}
}
const teams = analyseResults(results, getMatchDetails)
const probabilities = calculateProbabilities(teams[0], teams[1])
console.log(probabilities.result)
console.log(probabilities.scores[1][0])
console.log(probabilities.over['2.5'])
console.log(probabilities.btts.yes)
For more examples, see examples
.
FAQ
How does it work?
There are plenty of articles available that go into depth about basic poisson prediction. Essentially the library parses a series of match results and provides functions to return a rough percentage likelyhood of various outcomes of a match between two teams.
Further reading:
Yes, but football-predictor
seems too ambigious. Everyone knows what soccer is.