Game Log MLB Stats - R Shiny dataset Analyse

Posted on Aug 11, 2019

Project GitHub | LinkedIn:   Niki   Moritz   Hao-Wei   Matthew   Oren

The skills we demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

The dataset that I chose for this project was a game log of almost every game in MLB history, since 1910. Baseball has become the most analytical professional sport.  The extent of analytics in baseball has gone so far that some teams even use analytics to tell a player whether or not he should swing at a particular pitch.  While this particular set of data doesn’t give any pitch-by-pitch stats, it just goes to show how easily this game can be broken down into numbers, with each pitch being the base case for all other statistics involved. 


One of the challenges of this project was organizing the game log data in a way that would be meaningful, in regards to the league as a whole as well as for individual players.  With over 100 years, over 35 different teams, and the stats of each game being organized by home team and away team, this made deriving some of the stats challenging. 

For this particular project, I decided to visualize a couple parts of the game that have been discussed among commentators and baseball broadcasters over the last few years.  The first part of the game that I’m referring to is the rise of dominant pitching.  A lot of this talk began in 2014 and 2015 when there were clusters of games where pitchers didn’t give up any hits (also known as a no-hitter). 


There was also a noticeable increase in the size of the contracts for pitchers, which stirred the conversation as well.  Given game logs that dated back to 1910, I wanted to visualize pitching stats in a way that portrays the evolution of the game.  So, the first graph shown is the average number of strikeouts per game, for one team.  Meaning, if you doubled these numbers, you would get the average total number of strikeouts in a game, but I found the smaller number to be more intuitive for people who know baseball. 

The second graph I did was for season totals of no hitters.  I chose to look at these numbers as part of the rise of dominant pitching.  As you can see, there were a few recent years with a high total number of no hitters but overall, no hitters are too rare for there to be a noticeable steady increase as there is for strikeouts.

Of course, when it comes to looking at sports statistics, one of the common modes of visualization is through a player index.  The set of data I was working with did not give any particular individual player statistics but I was able to derive the number of wins for particular pitchers.  I would have loved to be able to recreate a classic player index with all of their stats but unfortunately the game log did not support it. 

Final Part

The final part of the project was to look at how the rise of pitching has affected the hitting aspect of the game.  If you know the game of baseball, you understand that each time a batter strikes out, the runners on base are unable to advance.  A common ground ball out still leaves the possibility of a runner advancing and getting closer to scoring a run.  On the other hand, a homerun will score a run no matter what. 

So, I decided to take a look and see if there is a correlation between the strikeouts and the ratio of homeruns per runs scored, which is the final visualization.  I also derived the league average for this statistic so teams could be compared to the league average. 

To view the app: 

About Author

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI