Giter Site home page Giter Site logo

pitchfx-site's People

Contributors

albertlyu avatar kruser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pitchfx-site's Issues

Update the URL with filter info always to facilitate sharing

Right now you have to click the share button in the top-right corner of the site in order to generate a URL that is sharable directly to these stats.

This isn't really being a good web citizen. Instead, we should keep the URL always in sync with what the user is seeing on the screen. As part of this, let's move the AddThis functionality to the player page as a first class item.

Pitchers' player pages should load pitches as default

If player's primary position is a pitcher, load pitches (rk-pitches div) as landing page instead of atbats (rk-at-bats div).

entry.js would need to be refactored. I tested the following change to default the partial page to pitches:

    }).otherwise({
        redirectTo : '/pitches'
    });

We would need to somehow persist the playerInfo array or just the playerInfo.primary_position_txt variable itself in order to change the redirectTo parameter based on an if statement.

Pitch Heat Chart: Hit Type

For this task we want to add a heat chart based on pitch locations, with different color dots based on the hit type.

  • grounder = blue
  • popup = yellow
  • line drive = green
  • fly ball = red

All dots should be the same size and transparency

All types should be deselectable such that the user can drill into specific ones

Coefficients in wOBA calculation needs to be season-dependent

In stats.js, a function for calculating wOBA named 'calcwOBA' was written in lines 155-159 using Tom Tango's wOBA formula from The Book.

function calcWOBA(results) {
    if (results.plateAppearances) {
        results.wOBA = ((results.walks * 0.72) + (results.hitByPitch * 0.75) + (results.singles * 0.9) + (results.doubles * 1.24) + (results.triples * 1.56) + (results.homeRuns * 1.95) + (results.rboe * 0.92)) / results.plateAppearances;
    }
}

However, Tango's formula from The Book were based on standardized linear weights in order to find those wOBA coefficients. Since then, Tango has developed customized wOBA calculations based on seasonal run environments in order to more accurately assign the relative value of events. wOBA coefficients should be seasonal.

For more information, here are some links to read:
http://www.beyondtheboxscore.com/2011/1/4/1912914/custom-woba-and-linear-weights-through-2010-baseball-databank-data
https://spreadsheets.google.com/spreadsheet/pub?key=0AuazhUE5lzIsdFgzdGlpUzktN2h4Q214a1dMTzBjd3c&gid=0

If we can write a script that determines wOBA coefficients after a season has completed (and use the default wOBA coefficients in Tom Tango's The Book during the season), that can feed the calcwOBA formula more accurately. Then we wouldn't have to rely on Matt Klaassen to update his numbers from the links above.

Edit: FanGraphs has the latest wOBA coefficients on their website. http://www.fangraphs.com/guts.aspx

Allow a user to link directly to filtered pitches or atbats

We should create a permalink to a state of the app, allowing users to create a filtered view of atbats or pitches and then share a link directly to them.

This link should use a shortener like bit.ly as it will certainly contain the json filters as an angular route.

How to get a batter out

Calculate a certainty for being able to perform defensive shifts on a batter. The calculations should take into account...

  • hit angles
  • hit trajectory (grounder, liner, fly ball, popup)
  • pitch type
  • pitch speed
  • pitch location
  • pitcher handedness

Move filters to the server

Instead of loading all years of atbats for a pitchers/batter, we should only load up the last year by default.

Then when filters are changed, the entire filter set should be sent to the server, to perform the filters in the database, rather than putting that logic in the UI. It was a good effort but it is too complicated for the browser.

Use ui-bootstrap datepicker on desktops

We use an HTML5 input type=date for our start and end dates on the atbat filters.

I'm not a fan of Chrome's date picker on input type=date as it tends to scroll like crazy when you least expect it. On top of that, Firefox and IE don't support that HTML5 input type anyways, so we get poor behavior.

We should see if we can use the ui-boostrap datepicker (already in our code base) when we're not on mobile.

http://angular-ui.github.io/bootstrap/#/datepicker

When on mobile (tablets or phones), the native datepickers are more desirable.

Weight Pitch Charts Based on Frequency

These pitch charts are reality...
image

...but the value in looking at them comes more from weighting based on frequency. That is, of course each player is going to show more green in the strike zone, because they see a heavy ratio of pitches there. The same is true for whiffs.

To get over this, we need to weight the opacity of bubbles according to the percentage of pitches that were seen in that zone.

Also, for whiffs, let's increase the radius of the bubble overall. As it stands we're not seeing a lot of overlap.

Pitch Heat Chart: Hit Quality (wOBA)

For this task we want to create a heat chart for pitches and base it on wOBA values of a hit.

The value of a hit ball should reflect the size of the scatter plot dot proportionally to the wOBA value of the hit. All dots should be equally transparent.

Persist filters to local storage

When visiting a new player card, it should use the same filters that were used on the last player card.

Implementation notes:
Persist the entire filter object to local storage using the angular-cache library.

Add player's mug shot to the auto complete

Only for medium screens or bigger (aka, not mobile), we should add the players mug shot next to their name in the typeahead. This will allow users to distinguish players easier.

For example, this is what it looks like now. Notice if two players have similar names you have to guess.
image

Create a sitemap.xml

We should have a dynamically created sitemap.xml page that we can submit to google to index all player pages.

New Filter: Pitch Type

This filter should allow the user to filter atbats and pitches based on an array of pitch types. An empty array would mean they are interested in all types.

Four 'unknown' pitches for each player?

I first noticed this before I installed Modernizr made this comment #34 (comment)

From the site:
image

Before installing Modernizr:
image

To replicate potential issue, I uninstalled Modernizr with 'bower uninstall modernizr' while in pitchfx-site/app.

Actually it looks like a coincidence that Kershaw's has four 'other' balls, and showing four 'unknown' strikes without Modernizr. But wanted to open this issue in case there are unintended extra pitches. May not need too much time to spend looking into, just found it curious -- I haven't proved that there is a potential bug here, but if I find more evidence, I'll comment here.

Add a Twitter Feed Tab for each player

We'll need to add twitter handles to each player in the players DB. We should figure out how to crowdsource that data. If the twitter handle is there, we should show their feed in a tab.

Let's still show the tab if we don't have a Twitter handle. In that case the body of the tab can ask the user if they know of the twitter feed.

I'm thinking for right now we can just let the user fill out a google docs form for submission. Then one of the developers can periodically mine that info to verify accounts.

Speed up loading of pitches

The payload of a pitchers pitches for a single year can be several megabytes. We should be able to cut that in at least half by trimming out unnecessary properties.

Setup travis-ci build

This task is to setup a travis-ci build so we can tell if pull requests pass things like jshint, karma tests, etc., before pulling them in.

How to get a batter to whiff

Whiffs are not the product of a single pitch. Much more can be learned by looking at the whiffed pitches in the context of the entire at-bat, specifically the surrounding pitches.

For this feature, we should present the patterns that offer the best chance to make the batter whiff.

The patterns should take into account:

  • count
  • previous pitch position, type and speed

New Domain/Site Name

See #50 for details of the MLBAM cease & desist letter.

This task is to pick a new domain name for the site and update the site header to match.

Anybody out there want to make a logo once we have a name? I'm not a designer.

Add hit scatter charts by zone

A couple things for this one...

  1. the pitch speeds on the Pitches tab are not useful for a batter, so when we get this new chart, let's replace that chart with this new one, but only on the batter's card

  2. for pitchers, let's move the pitch speeds stacked line chart to right below the pitch types. It is the most interesting stuff for a pitcher

  3. this new chart will be a 3x3 grid, each cell with a hit scatter chart overlaid on a field. Each cell of the grid represents a portion of the strike zone. The middle cell should represent the very center of the strike zone, while each cell around it would occupy a small portion of the strike zone and all balls around it. This would allow the user to an at-a-glance view of how a batter goes with a pitch, pulls certain pitches, etc., all based around pitch position. See the mockup below

image

New Filter: Balls & Strikes

All the user to filter atbats and pitches based on balls and strikes. The user should be able to multiselect the ball and strike count, sending an array of each to the server.

Player Card Rearrange

We're losing too much space at the top of the player page. For this task we want to move the stats up and keep the player info in the leftmost columns.

image

Pitch Heat Chart: Whiffs

For this task we should add a new heat chart based on pitch positions. All dots represent a swing and a miss.

Balls in Play Result

Especially from a pitcher's perspective, it would be great to either be able to filter the Balls in Play chart by result (Out vs. Safe). Going a step further, if the batter was safe, what was the result?

I know this has the potential to make the chart very messy, but maybe the Balls in Play chart could have a link to pop out to a chart with filters?

Season-Independant Date Range Statistics & Comparison

It would be great to be able to pull season-independant data. For instance, I know that Lance Lynn has a great ERA in the first few months of the season, tapers off during the middle of the season, and then gets hot again around late-august.

I think it would also be really neat to be able to see that data side-by-side (e.g. Lance Lynn in April-May vs June-July).

This is an AWESOME project. I started doing this exact thing on my own before I realized that y'all were doing it WAY better than I was. I'll be glad to help out where I can.

New Filter: Inning

Add a filter for the user to be able to select any inning they want. Innings 1-9 should be radio buttons, and extra innings should also be a radio button.

Create a developer guide

This task is to write a developer guide markdown page. The readme.md is a little out of date and while it explains how to setup, it doesn't explain our use of...

  • AngularJS
  • yeoman angular-fullstack generators
  • jshint
  • karma tests

New FIlter: Outs

All the user to filter atbats and pitches by the number of outs

New Filter: Regular Season & Postseason

Create a filter that allows the user to pick the regular season and postseason as radio-button type filters. By default the filter should only have the regular season selected.

Add playerInfo elements to the auto complete

In addition to the mug shots added in #33 and the auto-suggest priority ordering suggested by #26, I figured we could add a little more information next to the player's name. Maybe playerInfo.primary_position_txt and/or playerInfo.bats / playerInfo.throws? Is there a way we can have a short form prefix for playerInfo.team_name as well?

So for example: [mugshotpic] P Clayton Kershaw L/L LAD

We can throw an html tag around team_name to make the text smaller. Alternatively, we could use the full team_name and allow 'Los Angeles Dodgers' to be queried.

@kruser, I figured this is a relatively easier task, so if you like this improvement issue, I can set up a branch of the project and give it a shot. I successfully set up my MEAN stack and downloaded 2010-2013 using your Perl scripts, and can now view the PITCHf/x website on my local machine. In general, I think I can make my way around your html and js code, though I don't fully understand the auto-suggest functionality and how that can be customized.

Fix up the header links on the home page

Right now the header links use anchors to navigate to sections of the home page. Angular is intercepting those anchors, causing the links not to go to the right place.

New Filter: Pitch Speed

This filter should allow the user to filter atbats and pitches on a range of pitch speeds

Clarification of pitch events and pitch results terminology

This issue is more of a discussion thread rather than an actionable issue, at least for now.

Swinging strikes vs. whiffs

This is more of the former FanGraphs writer side of me speaking, but sometimes there is confusion in the baseball stats community about what 'whiff rate' means (whiffs/pitch or whiffs/swing). Typically, a 'swinging strike' is synonymous with 'whiff,' but 'swinging strike rate' (that is, whiffs/pitch) is not synonymous with 'whiff rate' (or whiffs/swing).

Whiffs/pitch and whiffs/swing may imply different behavior. A batter who swings a lot will tend to have a higher whiffs/pitch than a batter who rarely swings. But Swing-A-Lot High-Contact Batter has a lower whiffs/swing than Rarely-Swinging Low-Contact Batter. In other words, whiffs/swing is a better indicator of contact ability, while whiffs/pitch is some combination of swing behavior and contact ability (whiffs/swing * swings/pitch = whiffs/pitch, or whiff rate * swing rate = swinging strike rate).

The pitches table is efficiently constructed via the aggregator JS object, such that all pitch event rates have the common denominator of total pitch count. I don't see any reason to mess with that. But perhaps we can add a clarification text box, or as a lower priority, a glossary of baseball event terminology.

Additional pitch event segmentation to report on plate discipline

Alternatively, I'd imagine we can also incorporate other plate discipline statistics in the future, such as out-of-zone swings/pitch, out-of-zone whiffs/swing, etc. If so, we can add pitch subset checkbox filters for the aggregated pitches table, for example, All, Swing or No Swing, Inside Zone or Outside Zone, etc.

Batted ball results

I'm of the school of thought that batted ball type purport to be categorical, but is actually ordinal. Line drives / fly balls / pop ups can be inconsistently classified, leading to terminology such as 'fliners'. Without HITf/x data available to the public, which reports on batted ball data such as speed off bat, elevation angle, and field direction (typing that makes me salivate), we cannot accurately report on such batted ball classifications. If we want a 'batted ball results' view or add additional pitch subset filter for batted balls, I suggest grouping LD/FB/PU together as 'air balls,' to distinguish from 'ground balls.'

Reference:
http://www.fangraphs.com/library/pitching/plate-discipline-o-swing-z-swing-etc/

Add coming soon feature links for Milestone 1

We'll be adding two features soon that we won't have ready for milestone1.
#15 and #16

This task is to add buttons or links for these features that explain what is coming next in the form of a tooltip or an info directive.

Place a generic logo on player hats

See #50 for details of the MLBAM cease & desist order.

Both for search and for the player profile pages, we need to put a generic logo on top of the player hats. I think we can use a css 3d transform to slide a simple baseball on top of each hat so it is slightly positioned leaning back.

image

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.