kruser / pitchfx-site Goto Github PK
View Code? Open in Web Editor NEWA webapp for searching PitchFX data
License: Apache License 2.0
A webapp for searching PitchFX data
License: Apache License 2.0
change the priority of the auto-suggest to be something like number of at bats or innings pitches in recent years. more active players are more likely what people are searching for.
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.
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.
MLBAM sent a cease and desist letter today for PitchFX.org. I'm putting it up here for discussion.
https://drive.google.com/file/d/0B9ERgAQ83pATZ1dObTY0c1kxb0JFZGhPS2NWT0I2REstaUJn/edit?usp=sharing
For this task we want to add a heat chart based on pitch locations, with different color dots based on the hit type.
All dots should be the same size and transparency
All types should be deselectable such that the user can drill into specific ones
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
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.
Calculate a certainty for being able to perform defensive shifts on a batter. The calculations should take into account...
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.
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.
These pitch charts are reality...
...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.
Create a histogram of pitch speeds to show near all other charts
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.
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.
We should have a dynamically created sitemap.xml page that we can submit to google to index all player pages.
As the title says, it isn't clear when you're showing the batter's own stats versus the stats for the opposing hitters.
For this issue we should make that clear and also provide the ability to toggle between pitching and batting stats.
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.
Reproduction scenario
The fix
I first noticed this before I installed Modernizr made this comment #34 (comment)
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.
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.
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.
Add a search box in the header of the player page so the user doesn't have to go back to the home page to do a new search.
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.
A FanGraph's user has suggested it would be interesting to see a breakdown of left/center/right percentages for Line Drives.
http://www.fangraphs.com/qa/2766/how-do-you-find-ld%25-to-different-fields?show=2782#a2782
To accomplish this in PitchFX.org we can put this information on the tooltip of the pie chart on the atbat page.
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:
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.
A couple things for this one...
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
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
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
offer insight to pitch patterns describing the most common ways a batter strikes out
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.
For this task we should add a new heat chart based on pitch positions. All dots represent a swing and a miss.
See #50 for details of the MLBAM cease & desist order. This task is to remove the background image from each player's page.
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?
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.
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.
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...
If the batter is a switch hitter we should show the batterHand filter in order to show their splits accordingly.
When you change a filter it should be obvious to the user that something is happening. I suggest a little 'fa fa-spin fa-spinner' on the active tab next to the title of the tab.
All the user to filter atbats and pitches by the number of outs
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.
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.
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.
This filter should allow the user to filter atbats and pitches on a range of pitch speeds
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/
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.