Moving from MATLAB to Python

aaeaaqaaaaaaaalraaaajde5mgixnddmlwe0zjktndm0yi1hmzgxlwnmmte3mwiynmyxyw

It all started with picking up a tool for learning and doing some Deep Learning (DL) before my intern started. After some discussion I decided to go for Theano due to its simplicity and ability to do more modification as compared to Caffe. However, this meant learning Python since Theano’s API is written for python. Actually let me back up a bit as I now recollect that I started learning Python while coding for the DL course from Stanford (http://cs231n.github.io/) (excellent course!). Contrary to my expectations, Python was easier to follow for following reasons :

  1. My tons of experience coding in MATLAB surely helped in relating things between two languages.
  2. Python has excellent libraries/modules (Numpy etc.)
  3. Most interesting part of Python is that it is an actual programming language and if you have ever done some data structures, you will know why I say so.

Now let’s fast forward to my intern few months later where one of my colleague suggested to use Python instead of MATLAB while I had some trouble finding enough MATLAB image processing toolboxes. I took it to my heart and converted all my code to Python along with using opencv. The transition was easier than expected and the speed with which Python operates did impress me.

So the purpose of this article is to list few advantages that can convince a MATLAB user (esp graduate students) to shift to Python.

  1. Python has excellent toolboxes- Numpy, Matplotlib, Scikit-learn etc that implement much more libraries than MATLAB (feel so) and give you more power.
  2. Python has excellent string handling capabilities. Parsing .csv files is easier to perform compared to MATLAB.
  3. Python lists are an excellent data structure to do tones of stuff a. Of course, there are other standard data structures such as dictionaries, tuple, sets.
  4. For starters, Python has a MATLAB-like IDE called Spyder. The entire Python environment can easily be setup with Anaconda package which is there for all platforms.
  5. Python is faster compared to MATLAB as it doesn’t load all modules akin to MATLAB.
  6. Python is FREE! Though it might not seem like a huge benefit during grad school, it is a huge plus while working at a industrial lab. Moreover, you are never limited by the available number of licenses.
  7. Python has nice saving and loading tools. The most popular being pickle, but I would suggest to use h5py which is great in handling huge amouts of data. It lets you save huge numpy arrays on disk and loading only part of them in memory with easy.
  8. Following on above, I feel Python is well suited to Big Data domain.
  9. Excellent DL libraries/API’s in Python.
  10. Easy of converting to C++ code from Python than MATLAB.
  11. A big community of open source developers who have made excellent modules for Python.

Anyways I can keep talking about the benefits but the nutshell is Python is great. This doesn’t mean you ditch MATLAB, but you can always use MATLAB to either do very small-scale testing or post-analysis of the results generated by Python. I will be happy to respond to anyone (comments or by email: karan.sikka1@gmail.com) on transitioning from MATLAB to Python. It took me some convincing but wish had done it earlier. I will be writing more about these tools in future.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s