In this report we will take a look at baseball stats starting from its inception in 1861. We will explore visually how statistics like Runs, Hits and Home Runs correlate to wins. We will also look at how which school you come from affects your average salary, at which teams you would want to play for based on historical wins, and how MLB player salary has changed over the years.
The data in this report is compiled by the open source tool RapidMiner, and displayed using python packages pandas, numpy, and seaborn in a jupyter notebook from an anaconda distribution.
Starting with the columns from left to right, we see that the stat most strongly related to the sum(HR) column (the sum of home runs over a players career) is RBI's, followed by Runs and At Bat's. This lines up with our expectations that the more Runs and RBI's ( Runs Batted In ) you have, the more home runs you will hit.
The salary statistic's most significant correlation is Homeruns, which again lines up with our expectation of the more home runs you hit, the higher your salary. Next most significant is runs batted in, which has been traditionally cited as the statistic most responsible for wins by baseball afficiandos.
Our next group of stats, Runs, Hits, Doubles and Triples, are all closely correlated, as we can see clearly in the heat map below ( created using seaborn heat map against pandas correlation matrix ).
** This heatmap applied to our correlation matrix allows us to see at a glance each statistic's most highly correlated stats.
In the this section, we asked the question, "Does school choice matter if you are trying to make it into Major League Baseball?"
First, let us take a look at the schools producing the most MLB players since the year 2000. This data was created by joining the Master table to the Salary table by outer joining on playerId, and then joined to a grouped College table aggregated by counting the schoolId of each player for players whose debut was past 2000.
In the bar graph above we can see that Stanford is tied for the number one spot with California State at Fullerton for producing the most MLB players since the year 2000. In fact, California produced the most MLB players in the last 15 years taking 7 out of the top 15 schools to generate MLB players, or more generally, 47% of MLB players in the last 15 years went to schools in California.
Next let's take a look at the average salary for the year 2000s, as grouped by the schools they went to.
We see a different picture when sorting by salary of players that have entered major leagues since the year 2000. We see Missouri has the highest Average salary with 1.6 million dollars a year, and is quite a bit higher than the rest of the schools, which quickly levels out to ~$900K a year.
Still present are many California based schools, which we will see below, is contrary to the long termer picture of average salary of MLB players based on there choice of College. University of Texas at Arlington holds the number one spot of the school producing the highest average salary for baseball players of all time.
In the chart below, we see the chart of the top 15 most winningest franchises in MLB history sorted by number of wins ( of which, many had several different teams names throughout the years ). This data was created by grouping on the franchiseId and aggregating each teams wins by summing them and sorting by those wins, in the process named teams_by_wins.
The first table in this section lists players, sorted by the average salary over the span of their career, and the sum of the positions played throughout there MLB career. The motivating question behind this section is , "Do certain positions, on average, get paid more than others?"
This data was created by aggregating the Appearances table and summing the total positions of each player which was then inner joined to the Master table on playerId, which was joined once more to an aggregated Salaries table with another inner join against the grouped and joined Appearances+Master table.
As we see above, the top 15 highest average salaries, grouped by how often they played a position , are as follows:
In this last section we will explore how the average salary has changed over the years since 1985, the first year we have data for. We can see a sharp and steady increase starting in 1990, with only a few small dips and a solid increase for most years ( except for 1993 and 2004 when the average salary actually decreased ). In the first section of this report we did a correlation matrix, but left out the year because it was largely irrelevant. If we had left it in however, we would see that the second most contributing feature of salary ( behind home runs ) was in fact the year in which they played. This data was created by aggregating the Salary table.
In the last graph of this report, I thought it would be fun to show the average disparity in salaries over time. We can see in this graph , that the Standard Deviation of salary ( in red ) , outpaces the growth in Average Salary ( in green ) by quite a lot. This tells us that though the average salary grew over the years, the difference between the highest paid player and the lowest paid player also grew.
In this report we have explored the data in the Baseball data set, containing baseball statistics from 1871 to 2015, which was spread across 27 different tables. We were able to visualize the data by first joining, filtering, grouping and aggregating with RapidMiner, then using pandas, numpy , and seaborn to further manipulate the data and finally display it.
We looked at correlations between offensive statistics. We studied which schools were producing the most MLB players along with average salaries out of each school. We took a look at franchise wins, and which positions paid the most. And finally we finished the report with a look at how average MLB salaries changed over the years.