Giter Club home page Giter Club logo

umpire-auditor's Introduction

#Umpire Auditor

###Umpire Auditor has been heavily refactored and is now maintained at https://github.com/dyep49/Angular-Umpire-Auditor

After every game, the MLB releases an incredible amount of data. In fact, every single pitch brings back nearly 30 different characteristics. Umpire Auditor uses this data to track (or audit) the performance of MLB umpires, primarily by calculating the rate at which these umpires correctly calculate balls and strikes.

At it's most basic, the application returns the worst call of the night, every night, chosen as such for being the ball, called strike, furthest from the strike zone. In addition, umpire performance statistics exist in the application for every game and cumulatively over the entire season.

This application made extensive use of the 'gameday_api' gem and 'nokogiri' to download (gameday_api gem) and parse ('nokogiri') the xml provided by the MLB's API.

Becuase the data released is so extensive, it was not practical to hit the MLB API everytime information was needed. As a result, the necessary files were downloaded by the game_day_api gem, parsed, and added to a Postgres database. Because there were so many files (500,000+ per season), it was necessary to parse the xml into a Ruby hash and convert that to csv. From there, the data was inserted into the database using Postgres. There were about one million rows inserted per season.

To ensure faster response time, some resource intensive calls were generated in a seed task, run daily, and stored in a csv file.

def strike?
    if self.width_strike? && self.height_strike?
        "Called Strike"
    else
        "Ball"
    end
end

def correct_call?
    self.strike? == self.description
end

def width_strike?
    half_plate_width = (17.5/12)/2
    self.x_location.abs < half_plate_width 
end

def height_strike?
    (self.y_location < self.sz_top) && (self.y_location > self.sz_bottom)
end

def distance_miss
    half_plate_width = (17.5/12)/2
    if self.y_location > self.sz_top
        self.distance_missed_y = (self.y_location - self.sz_top).round(2)
    elsif self.y_location < self.sz_bottom 
        self.distance_missed_y = (self.sz_bottom - self.y_location).round(2)
        else
        self.distance_missed_y = 0
    end

    if self.x_location.abs > half_plate_width
        self.distance_missed_x = (self.x_location.abs - half_plate_width).round(2)
    else
        self.distance_missed_x = 0
    end
    self.total_distance_missed = self.distance_missed_y + self.distance_missed_x
 end

umpire-auditor's People

Contributors

dyep49 avatar amortenson 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.