Sunday, June 25, 2017

Off Topic| Wide and Deep Learning in R

R is an excellent environment for quick and dirty data science. I am a R user and obviously a bit biased, but between Python and R, R has always had the edge for data visualization and quick hypothesis testing. If you do not find the latest and greatest methods of bleeding edge analytics somewhere available already within the strong R package ecosystem, it is more or less safe to assume it does not exist anywhere else either. And forget Python, the IDE from R Studio is perhaps the best IDE across any development platform (although the Visual Studio perhaps has a better debugging interface). But one area where R has been weak is in machine learning, especially in the deep learning area. And with the explosion of interest (and fad?) in deep learning, this has become quite a glaring gap.

But hopefully not anymore. We already have Google's TensorFlow available in R for a while. But to be honest, it did not have much feel of R in it and looked like a deprecated version of the Python release. However, very recently the R Studio folks released a R support for the excellent Keras high level API, with back-end of TensorFlow. This feels like R (with some quirk like in memory modification of objects) and works like a charm. Although it runs on top of a local python platform, the package exposes pretty much all the functionalities Keras support.

You will already find a list of examples in their site here. Here is to add a basic example of how to set up a wide and deep learning network. This involves creating two separate learning network. The wide one has only one layer (effectively a logistic regression of sort). The deep network is created separately. The output of two is combined (concatenated) in a final decision layer (this is slightly different architecture than the TensorFlow example). This is run on the usual Census Income data-set. The error rate for this set up is around 16 - comparable to other methods officially reported.

No comments:

Post a Comment