Giter Club home page Giter Club logo

pitching-analysis's Introduction

Expected FIP

The model:

This is a Generalized Additive Model (GAM) using random effects and restricted maximum likelihood to rate MLB pitcher stuff and translate it to predicted FIP based on stuff. It uses a series of these models grouped by pitch type and batter side that regresses HR rates and swinging strike rates based on the expected outcomes given the models below. Expected swing and miss rate is then fit to strikeout percentage. Walk rates are given from actual game data and then Expected FIP is fit from expected swinging strike rates, expected home run rates and actual walk rates. This model uses 2020 MLB season as training data. '21 season data will be used as test set and GAM will be tuned once I've got some test data.

The point:

Determine how good a pitcher's stuff is and how it should translate to performance. See who has the best pitches in baseball. See which pitchers are optimizing their arsenal. Is a pitcher throwing his best pitches most often?

The fun stuff:

MLB Leaders
Blue Jays
Giants
Mariners
Pirates

The scripts:
  • Download and clean Statcast data (h/t to Ethan Moore and Bill Petti. This is mostly their code.)
  • Feature selection testing PCA and ultimately using VIF to test multicollinearity of predictors
  • Fastball/Sinker models include pitch velo, release point, batter side, spin rate, spin direction, break and plate location
  • Breaking ball models include pitch velo, release point, batter side, spin rate, spin direction, break, plate location, and relative horizontal break and velo compared to fastball
  • Changeup models include pitch velo, release point, batter side, spin rate, spin direction, break, plate location, and relative horizontal break and velo, vert break and spin direction compared to fastball
  • Home run models are currently based on the above factors but with home run as the dependent variable instead of swinging strikes. This model will eventually be rebuilt with different variables.
  • There is some calculation of FIP and some summary analysis.
Code Example - Fastball Whiff Rate Model
train_select %>%
  filter(pitch_type %in% c("FF","SI")) %>% 
  group_by(pitch_type,p_throws,stand) %>%
  do(fit = gam(whiff ~ release_speed+release_pos_x+release_pos_z+release_extension
                 release_spin_rate+release_spin_direction+pfx_x+pfx_z
                 +plate_x+plate_z, data = .,family=binomial,method="REML",bs="re"))

pitching-analysis's People

Contributors

joshorenstein avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pitching-analysis's Issues

Update HR models

update HR models with predicted HR rather than actual as the Y variable or possibly rebuild using other data points like flyball rate or HR/FB

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.