Thursday, April 25, 2013

Visualization tools, Python, Ruby, Web Frameworks and more

Today I came across a tweet mentioning about Rega. Rega is an experimental project of Ruby wrapper for Vega.  Vega is a Visualization Grammar.  You can read more on Vega in this documentation.  Vega is strongly influenced by Protovis and d3.  By the way, d3 is the successor of Protovis - developed by Mike Bobstock et. al.

d3 is a javascript library for Visualization.  Some examples exhibiting the capabilities of d3 are in this Github Gallery I worked a little in d3.  Working with d3 is fun and the visualization that can be created are very cool.

Coming back to Vega, which is a Visualization Grammar - other similar grammars are Grammar of Graphics, ggplot2, Tableau's VizQL.  Tableau is a proprietary visualization software. Also there is Google Chart Tools.  You can play with these charts in Google Code's  Code Playground.  Google Chart is offered as R package googleVis which can be directly integrated from R programming language.

Recently, I had a chance to try Python.  Though, I have been a regular in Pycon talks in Chennai, I never used it much.  Perl has been my favorite for many years.  Now, I have started liking Python.  Also, I tried a few things in django, a web framework in Python - it is very powerful.  There are other web development frameworks available - Pylons (more a content management system), BottlePy, CherryPy, WebPy. Complete list here

And, there is a way you can bring in the power of d3 visualization from the django framework itself. You can explore the django-nvd3 package (which is still in beta).  D3, Vega, GoogleVis etc are relatively very new technologies.  

Also, had a chance to look into Ruby and Ruby-on-Rails.  It can one-on-one be compared to Python and Django.  There are some interesting discussions in StackOverflow discussing the pros-and-cons.  See here for a comprehensive list of Ruby web frameworks. 

Ruby (1995) interestingly is inspired by Perl, Lisp, Python etc. I am yet to try something in Ruby. The designer of Ruby Yukhiro Matsumoto works with Heroku (a PaaS - Platform as a Service company).  Probably, since Pe(a)rl was already there, some discussion went on naming the new programming language Coral or Ruby, and finally settled on Ruby. Interesting! 

Ruby site is generated by a site-generator called Jekyll, the author of Jekyll talks more about it here.

In exploring all these, came across something called CoffeeScript, which is a ease-to-program script which is compiled into a javascript. See this left to right translations of CoffeeScript and JavaScript code to see the simplicity of CoffeeScript.
With indentation for the control, iteration and function blocks, instead of the traditional braces, this looks very similar to Python. An additional info: Dropbox which initially had JavaScript code now uses CoffeeScript.

Thursday, April 11, 2013

Margin of Wins in IPL

Just got curious how the winning margins were in the all 5 editions of IPL combined (from 2008 to 2012).  So, I drew the frequency pattern (statistically speaking - histogram) for the margins in terms of both runs and wickets.  This is how it looks like:


As people expect and want, most of the matches are close contests - with the teams winning by 1-20 runs. 
In this analysis - I have not taken the tied matches into account.  And, in the chasing wins, most do so comfortably by 4 to 7 wickets to spare.

Interesting to look these completely different distributions!