Giter Site home page Giter Site logo

ryanrouleau / baseball-fun Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 10.26 MB

Adjusting MLB player's SLG stats by park factor and dominant hand

Home Page: https://ryanrouleau.com/baseball

Jupyter Notebook 45.78% HTML 5.62% CSS 2.92% JavaScript 45.67%

baseball-fun's Introduction

Adjusted Slugging Percentage (ASLG)

Repo Contents

Explanation

Slugging Percentage, or SLG, is a relatively simple calculation designed to measure the batting productivity of a hitter. The calculation is as follows: (1 * Single + 2 * Double + 3 * Triple + 4 * Home Run) / # total at bats. What makes SLG special is that it takes into account the quality of hits and not just if the batter made a hit or not such as in Batting Average (BA).

The problem with this statistic is that it does not account for differences in ball parks. For example, a batter who plays most frequently at Coors Stadium (a mile high) will have a higher SLG than a similarly skilled player the plays more often at Marlin's stadium (sea level) (it is significantly easier to make higher scoring hits such as home runs at Coors).

As a result of this, if players are compared to each other across an entire season to determine who are good hitters, it will be unfairly skewed to those who play most often at stadiums that are good for hitting.

Luckily, people have also seen this issue and have created Park Factors for different stadiums for different stats - in this case, SLG. The resource we use in this project is: https://swishanalytics.com/mlb/mlb-park-factors.

Looking around online, it doesn't appear that anyone has actually applied park factors on a large number of batters across entire seasons - this is what this project accomplishes.

Using data from Statcast, we can calculate individual player's SLG scores as well as adjust this with individual Park Factors for SLG. We do this by breaking down the data by each game, calculating the total bases hit by each player and their number of at bats for that game and multiply their total bases for that game by the respective Park Factor. We then combine these scores across all games for each season (2016, 2017, 2018) to get a final Adjusted SLG (ASLG) for each player for each season.

This calculation for each player is as follows:

(Park Factor for Game n * Total bases for game n + ...) / (total at bats for season)

It's important to note that we also take into account left and right handed hitters and adjust the park factor applied as needed since for many stadiums, the park factor for SLG heavily depends on which way the ball flies.

The development of ASLG will be very useful for anyone trying to directly compare player's hitting abilities across a season in a fair fashion.

baseball-fun's People

Contributors

ryanrouleau avatar

Watchers

James Cloos avatar  avatar

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.