npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

soccer-predictor

v0.0.2

Published

A JS library that predicts soccer match outcomes using basic mathematics

Downloads

6

Readme

Soccer Predictor

Latest npm version Build Status Dependency Status devDependency Status Test Coverage

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'

// Some basic example data
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 to map match data to soccer-predictor data
function getMatchDetails (match) {
  return {
    homeTeamName: match.homeTeam,
    awayTeamName: match.awayTeam,
    homeGoals: match.homeGoals,
    awayGoals: match.awayGoals
  }
}

// Parse results into an array of teams with calculated stats
const teams = analyseResults(results, getMatchDetails)

// Use calculateProbabilities to calculate the chance of
// various outcomes of a match between two teams
const probabilities = calculateProbabilities(teams[0], teams[1])

console.log(probabilities.result) // Probability of a home win, away win or draw
// {
//   home: 0.657541673613264,
//   draw: 0.252533180170396,
//   away: 0.089924594462736
// }

console.log(probabilities.scores[1][0]) // Probability of a 1-0 result
// 0.2300324502673927

console.log(probabilities.over['2.5']) // Probability of over 2.5 goals
// 0.2895346409101279

console.log(probabilities.btts.yes) // Probability of both teams to score
// 0.2429353553660894

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:

  • https://plus.maths.org/content/understanding-uncertainty-football-crazy
  • http://opisthokonta.net/?p=296
  • https://www.sbo.net/strategy/football-prediction-model-poisson-distribution/

Isn’t it called football?

Yes, but football-predictor seems too ambigious. Everyone knows what soccer is.