In the second lesson on Machine Learning (https://www.coursera.org/learn/machine-learning/lecture/olRZo/unsupervised-learning), Prof. Andrew Ng from Stanford (https://en.wikipedia.org/wiki/Andrew_Ng) mentions that Matlab/Octave is widely used in the Machine learning industry to prototype. I did quite a bit of research before settling on learning Python, as it seemed to be more applicable for real-life problems. I have used Matlab ~ 2 years back, and I am wondering if I should really go back to Matlab, because of his statement here.

However, I have also heard other arguments, that the reason why Matlab/Octave is still used in this course is because this course started in 2011, when python was not as popular or widely used in ML, as a result most of the algorithms was hard to get, or had to be handcoded in Python.

I know a lot of you work in the ML/data science industry, so I was wondering:

  1. Is Matlab/Octave that widely used in ML/data science industry?

  2. Why so, especially since numpy/pandas have a lot of matrix algaebra capabilities?

  • 4
    $\begingroup$ I read somewhere (I think it was the answer by @gappy in the thread linked below) something like this: In R, you think in terms of models. In Python, you think in terms of coding. Also, a direct quote: I believe Python will limit the way you think about data analysis. It resonated with my experience. I like thinking in terms of models, and that is indeed what you need for prototyping. I think Matlab is a lot like R, so here you go. See also the thread "Python as a statistics workbench". $\endgroup$ – Richard Hardy Oct 29 '17 at 19:43
  • 5
    $\begingroup$ Python is at much too low a level to be considered a prototyping environment--unless your ultimate aim is to implement something in Assembly language! $\endgroup$ – whuber Oct 29 '17 at 21:02
  • $\begingroup$ Thanks for your opinion and pointing me to those links. I have used a little bit of R, but because its more time consuming to learn 2 languages I decided to go the Python Route. @RichardHardy, the recent answers on that link seems to suggest Python is capable enough at this point, with other libraries such as Pandas, and other stats libraries. Have you tried these libraries? $\endgroup$ – alpha_989 Oct 30 '17 at 23:55
  • $\begingroup$ Also coming back to questions.. I realize matlab is used widely in academia. Are you guys aware of the situation in industry in ML/AI regarding usage of Matlab/Octave? Or do people just use R because of the much wider number of stats packages? $\endgroup$ – alpha_989 Oct 30 '17 at 23:56
  • 1
    $\begingroup$ @alpha_989, my experience with Python is both limited and outdated, unfortunately. $\endgroup$ – Richard Hardy Oct 31 '17 at 17:16

While Matlab certainly remains a primary tool in much of academic science and engineering, I do not see it used extensively in data science. The primary reason, as I see it, is R's (and Python-Pandas) extensive use of data frames and reference-by-name ecosystem. Matlab is designed to work with matrices, and while you can get Matlab to work with tables and group by categorical variables (e.g., varfun), it's often terribly cumbersome and less intuitive. R and Python employ a syntax that is conducive to thinking-and-coding-as-you-go, almost like writing a data story. Matlab becomes quite verbose in this context, and often requires multi-line solutions for problems R/Python can attack with a fraction of text (though perhaps double or triple the time). To Matlab's credit, that isn't its primary use case. If you want to do serious optimization and simulation, you'll age waiting for R to complete, while Matlab barely sweats. But if you want to explore and model your data in a thoughtful, principled way, R and Python are often better suited, in my opinion. To each their own, but Matlab just wasn't designed for the types of tasks data scientists face.


You'll have to make a distinction between industry/business-inspired titles such as "data scientist", "ML engineer", and "AI expert", and the actual scientists who work in laboratories and invent the tools that all the former make use of. Also you must understand the difference between "algorithm prototyping", i.e. developing and testing a low level routine from scratch and "model deployment into production", i.e. using packaged low-level routines (possibly written in Matlab, C, or Fortran) and calling them from a high level interface such as python for an engineering task.

With those things in mind, the claim of Andrew Ng that Matlab/Octave is widely used in algorithm prototyping should make more sense now. You won't find a company asking for a ML engineer who can use Matlab toolboxes and deploy models into production. The reason for that is that DS/ML job roles will never require any actual algorithm prototyping, they will only involve high level model deployment. You'll be using scikit-learn to train a SVM or Random Forest with a single line of code and you don't even need to know how it works. However, if you dig deeper and find the people who wrote scikit-learn, or the people who wrote the tools used by the people who wrote scikit-learn, you will eventually stumble into some people who prototype their algorithms in Matlab. Those Matlab programmers will usually a very academic/scientific mindset and are required to have a deep understanding of what they're doing. If this is not your chosen career path and you just want to work as a DS or ML engineer in the industry then you shouldn't worry about knowing Matlab/Octave.

To answer your questions precisely: 1. No. The DS/ML industry does not involve low level algorithm prototyping (an exception to this could be working for companies such as NASA, Airbus, or Boeing; they use Matlab in production). 2. numpy/pandas are actually based off Matlab/Octave and most DS tools such as Spyder or Pycharm try to emulate the behaviour of Matlab. When it comes to syntax and code readability, Matlab's linear algebra capabilities are incomparable. For what concerns to performance, all Matlab, R, and numpy/pandas use open source lower-level routines written in Fortran or C (such as BLAS, LAPACK, FFTW), but Matlab has accelerated for-loops, runs on top of Java, and is significantly faster.

The bottom line is that every tool has its purpose. Matlab is perfect for prototyping algorithms and designing low-level routines. R is perfect for prototyping high level stochastic processes. Python is perfect for deploying models in production.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.