3 ms·
It's strange how many managers and project owners have asked me in the past whether to go for R or Python in their environment, as if the choice for a programmi
by Macuyiko 7y ago
It's strange how many managers and project owners have asked me in the past whether to go for R or Python in their environment, as if the choice for a programming language will break or make your data science initiative. (Even more fun: it's not uncommon to find organizations where IT has finally accepted to provide Python, but without any access to a package repository, with some people being surprised that Python alone is not enough).
In any case, I've worked extensively in both environments and I don't think the author has considered every aspect. Below or my two cents.
- Elegance: slightly disagree. R might look more concise, but the language comes with many strange aspects (quoting, non standard evaluation) that can put a wig between novice and experienced team members. Python is more verbose, perhaps, but cleaner overall
- Learning curve: disagree. Even when working in R, modern practice would ask you to learn the tidyverse or data.table first instead of sticking with base R. Good tutorials are available for both
- Libraries: depends, the notion of "libraries" is too broad anyway, better to split it up according to the subcategories below. Both come with lots of packages, so I'd agree with it being a tie
- Statistics: agree with R. R is still the statisticians language, and many implementations of some more obscure techniques are only available in R. This being said, most ML shops today would be more interested in e.g. a good GBM implementation or deep learning rather than some robust statistics package. In R: think regression, ANOVA, significance tests, time series and niche subfields like bioengineering. In Python: think RF, GBM, t-SNE, deep learning
- Parallel computation: I'd say both are lacking, and you'd need to look more towards tooling such as Spark anyway. I'd also say out of memory computing becomes your first concern more often. Dask and Pandas on Ray are very nice on Python
- Foreign interface: kind of disagree. I think Python has matured better here
- Object oriented programming: disagree. The problem with R is in fact that is has about 4 (or more) OOP ways
- Interop: agree that you should avoid it, at the moment, it will only make deployment more cumbersome
Some other concerns I'd consider.
- Pipeline approach to ML ("model dev / model run"): better in Python. E.g. the clear approach of scikit learn to consider both preprocessing as the model itself as part of the fit-transform-predict pipeline with clear methods is way better than R. I've seen many novice R users fall into the trap of preprocessing a data set before splitting in train/test, for example. This has been one of the biggest drivers to push me towards Python coming from R. Most established libraries in Python commit to a shared, best-practice way of thinking whereas every package in R seems to come with its own ideas in terms of pipeline and usage
- Deployment: also a win for Python. Better package management / reproducibility, though it is possible in R as well
- Data exploration: I find this easier in R. Packages like dplyr help a lot here. Pandas' API is somewhat cumbersome
- Charts / visualizations: ggplot2 in R is still a champion, though good dashboarding tools exist for Python as well. Still, I find this easier to use in R
- Spatial analysis: both come with very solid libraries, though I find whipping up a quick visualization easier in R
- Deep learning: clear win for Python. Tensorflow, PyTorch and even Keras are not fun to use in R
- Reports authoring: possible in both, though R's markdown functionality combined with RStudio is fantastic. Nevertheless, Jupyter notebooks can be made to act as a reporting tool for both languages
- patrick5415 7y ago> Data exploration: I find this easier in R. Packages like dplyr help a lot here. Pandas' API is somewhat cumbersome I can’t claim to have tried everything out there, but so far it’s been my experience that matlab beats the socks off everything else when it comes to data exploration. I’m mostly looking at time series like data (but mostly not statistics). The ability to do things like click on a datapoint and export it and it’s index back to your workspace sound trivial. But in practice it’s a huge convenience and I’ve been unable to find a plotting package for python or Julia etc that can do things like this.
- Tazinho 7y agoI like your comparison. So it sounds that one may draw the conclusion that it doesn‘t matter that much which language one chooses. In the end both languages provide typically required functionalities for data science and it’s probably better to find out for yourself which language feels more intuitive/effective to use than listen to an overheated discussion on this topic.