Back in April, Colin’s blog on, “Moneyball – not just for baseball anymore” was a good example of describing how statistics can be used to make better decisions on and off the baseball field. New measures can be created to better understand a player’s real contribution to a team. For instance, most baseball players are familiar with the popular earned run average (ERA) measure for pitchers, but a new one that is becoming more popular is called WHIP (Walks plus Hits per Innings Pitched).
Here is how Wikipedia describes WHIP: While earned run average (ERA) measures the runs a pitcher gives up, WHIP more directly measures a pitcher’s effectiveness against the batters faced. It is calculated by adding the number of walks and hits allowed and dividing this sum by the number of innings pitched; therefore, the lower a pitcher’s WHIP, the better his performance. Listed below is the calculation for WHIP.
WHIP = (Walks + Hits)/ Innings Pitched.
Dashboards such as the following can be built demonstrating these new kinds of measures or key performance indicators (KPI) and how they can be used across a wider audience and provide more insight on teams and players.
Some of the other measures needed to accurately determine a person’s contribution to the team can only be implemented using a statistical package such as ‘R’. Typically implementing a statistical package in an organization is not a trivial task for the following reasons:
1.) Specialized domain expertise required – Statistics requires a new skill set to understand and use properly.
2.) Data Access – Import and Export must be done into the statistical package.
3.) Performance – Many of the statistical algorithms are compute intensive.
This article will demonstrate how Vertica 6 handles the first two items above and another article to soon be posted will show how Vertica 6 “Presto” has some distinct ‘R’ integration related “Performance” capabilities.
While it is true that understanding statistics can be challenging without proper training, having a group who fully understands the algorithms collaborate with the business domain experts ensures that proper implementation can be done. Implementing these new algorithms in the database allows your organization to leverage the powerful statistics in their daily business analysis and reduce the time to market because they can now be treated as any other “standard” database function. The possibility for error is also reduced because no longer are complex “Extraction, Transformation and Load (ETL)” products required to import and export the data into the statistical package. The entire process is now streamlined so that any BI tool or ETL tool in the organization can also leverage the new capability as well because they are now in the database.
So let’s put on our favorite baseball cap, in my case a Tiger cap, and take a closer look at how using ‘R’ can enhance our understanding of our favorite baseball teams and players.
As indicated before, “Moneyball” enlightened the baseball world with many new “measures” that are now almost common speak amongst baseball fans. The scenario for this example could be a team might want to ensure they are paying their pitchers appropriately based on performance, or they might be interested in finding some more talented pitchers for their team. Once these pitchers are determined, I want to group them together in “liked clusters” based on our key performance indicators (KPI). The two KPI’s I have decided to use are the WHIP calculation that we described above and another one called IPouts, which is simply the “number of outs pitched”.
Listed below is a simple query showing results for last year’s top pitchers sorted on the new measure called WHIP.
You can see very clearly why Justin Verlander was the MVP and Cy Young award winner last year. His WHIP and IPouts where the best and he was third in ERA. All of the measures provided so far can be implemented with standard SQL. The next thing I want to do is group these pitchers into clusters based on my two measures of WHIP and IPouts. To do this I used the new Vertica integration with a statistical package called ‘R’ to implement a clustering algorithm called KMeans. In my case I want 3 clusters of the 91 pitchers from 2011 that qualified. The column below called Geo.cluster was provided by the integration of ‘R’ in Vertica.
You can see that even in the top 10 we have pitchers in all of our 3 clusters. Keep in mind that lower numbers for WHIP and ERA are better and higher values for IPouts are better. Looking at the list above I now have some better insight on the players and I can focus on cluster 3 players and possibly some players from cluster 2. Listed below is an example of a histogram showing the WHIP on the X axis for all our 91 pitchers of 2011. You can include these charts and graphs in your dashboards as well.
Other database competitors can also claim ‘R’ integration, but Vertica’s implementation provides better value to your organization because of its simplicity and performance. Other vendors take an ‘R’ centric approach, which means your users have to know ‘R’ and use the ‘R’ suite of programming tools. Vertica’s implementation is a more ‘data’ centric approach that shields the users from having to know and use the ‘R’ language. Users can continue to use their favorite BI or query tool and now have access to ‘R’ capability.
This article demonstrated how statistics can be used to build new measures to provide more insight on a particular situation. This kind of analysis can also be applied in your organization to help with detecting fraud etc.
Stay tuned on future posts that will give you more detail on how the kmeans and other statistical functions like page rank were implemented in Vertica using ‘R’. Go Tigers!
For more details on how to implement R in Vertica please to the following blog http://www.vertica.com/2012/10/02/how-to-implement-r-in-vertica/