GithubHelp home page GithubHelp logo

postmatch's Introduction

Using data to evaluate soccer games

This repository contains my python work for scraping, analyzing, and understanding soccer matches. It draws data from understat with the match id where uses it to output a number of visualizations and simulate the different possible match outcomes.

These analyses rely on expected goals, or xG. In layman's term, xG is the probability that a shot will result in a goal based on the characteristics of that shot. Such characteristics include things like the shot location, body part of the shot (left foot, right foot, head), the incoming pass, etc. The xG values, by their probabilistic nature can range from 0 - 1, where an xG of 0 is a certain miss, while an xG of 1 is one the model thinks is a certain goal. An xG of 0.5 would indicate that if identical shots were attempted 10 times, 5 would be expected to result in a goal.

Features

  • Distributions of players who shoot and their total xG for a match
  • Cumulative xG plots for the game flow
  • Shot maps (can be drawn for either team individually or both on the same pitch)
  • Game result calculator, which uses the two teams' xG to determine probabilities of win/draw/loss for each
  • Heatmap show possible game outcomes from their xG
  • Histogram of the two teams' potential scores from their xG

Use

Scripts

  • The probability_wdl.py script contains all of the functions for doing the calculations
  • The soccer_scraper.py script contains the separate function for scraping the understat data
  • The postmatch_analyzer.ipynb notebook is set up and ready to run out of the box. The user can enter the understat match id as an input interactively or by assigning the variable to a string. Then, running through the whole notebook will perform the calculations and output the results.

The Road Ahead

  • Clean this shit up
  • Scrape the event data
  • Passing networks and territory maps
  • Build my own xG model so I don't need to rely on understat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.