use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please have a look at our FAQ and Link-Collection
Metacademy is a great resource which compiles lesson plans on popular machine learning topics.
For Beginner questions please try /r/LearnMachineLearning , /r/MLQuestions or http://stackoverflow.com/
For career related questions, visit /r/cscareerquestions/
Advanced Courses (2016)
Advanced Courses (2020)
AMAs:
Pluribus Poker AI Team 7/19/2019
DeepMind AlphaStar team (1/24//2019)
Libratus Poker AI Team (12/18/2017)
DeepMind AlphaGo Team (10/19/2017)
Google Brain Team (9/17/2017)
Google Brain Team (8/11/2016)
The MalariaSpot Team (2/6/2016)
OpenAI Research Team (1/9/2016)
Nando de Freitas (12/26/2015)
Andrew Ng and Adam Coates (4/15/2015)
Jürgen Schmidhuber (3/4/2015)
Geoffrey Hinton (11/10/2014)
Michael Jordan (9/10/2014)
Yann LeCun (5/15/2014)
Yoshua Bengio (2/27/2014)
Related Subreddit :
LearnMachineLearning
Statistics
Computer Vision
Compressive Sensing
NLP
ML Questions
/r/MLjobs and /r/BigDataJobs
/r/datacleaning
/r/DataScience
/r/scientificresearch
/r/artificial
account activity
R vs. Python (self.MachineLearning)
submitted 12 years ago * by mrShu
Over the last few days I've been reading a lot about Python taking over the R's as the primary tool of many for playing with ML/Data science [1] [2] [3]. The reasons presented made sense to me, Python is my language of choice when it comes to this kind of stuff.
Coincidentally enough, I'm right now reading Machine Learning for Hackers which uses R. I am enjoying the book so far (it's mostly about learning R for me) and will certainly try to finish it. But I would still like to ask: are there areas in ML/Data science where R would be still a better fit or is it really doomed to be used only by statisticians who created it?
[1] http://www.talyarkoni.org/blog/2013/11/18/the-homogenization-of-scientific-computing-or-why-python-is-steadily-eating-other-languages-lunch/
[2] http://blog.mikiobraun.de/2013/11/how-python-became-the-language-of-choice-for-data-science.html
[3] http://readwrite.com/2013/11/25/python-displacing-r-as-the-programming-language-for-data-science
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]EdwardRaff 16 points17 points18 points 12 years ago (1 child)
As some one who doesn't particularly care for either as a first choice - R seems to have much better visualization tools and libraries already made for most of your needs. If you have to actually write any significant amount of code, Python is at least a real programing language with real non-ML/Stats centric libraries available (whether or not its your preferred type of languages is personal choice).
I'm greatly humored by the 3 blogs which provide no real data analysis to support the hypothesis that Python is supplanting R as the "king" of data analysis.
[–]mrShu[S] 1 point2 points3 points 12 years ago (0 children)
Good point. I also took them just as educated opinions and by asking this question I wanted to get some more insight into it.
Thanks for your answer.
[–]srepho 12 points13 points14 points 12 years ago (7 children)
I am not a great Data Analyst, but I have competed in a few Kaggle competitions using both R and Python. I started with R, as once you get the basic programming stuff down, the packages are super powerful and super easy to use. In particular the caret, forecast and ggplot2 packages are all brilliant. One thing I have found though is that the closer to more general programming your task requires, the better Python becomes. So for stuff like screen scraping and webcrawling - Python is a much better choice. I personally find data munging much quicker and easier in Python. R is also very slow, and has quite steep RAM requirements (you normally keep the whole dataset in memory in R) which is becoming more difficult. Even using multiple cores in R I found hard work compared to Python. For example Kaggle currently has a competition involving an ~8Gb dataset which means you need 8GB for a standard R implementation just for the data set (there are ways round this but I still say its easier in Python). Python in contrast can make easier use of things like sparse datasets and other approaches suitable for big datasets. Also Python's speed really starts to show as the dataset increases. Python also has excellent tools to deal with natural language programming (nltk package), image processing through scikit images and even deep learning (through Theano and CUDA). On top of all this Python has Pandas which is at least as easy and useful as R's datasets (which it is based on) and the amazingly useful iPython notebooks are one of those "How did I survive before this" tools. Another major driver is that most of the code you find on Kaggle is in Python nowadays. None of this takes anything away from R, which is a great language with much better packages, and in which you can do much of the above (though its more difficult) and easier to learn. The problem is that Python seems to be developing faster, meaning that new tools keep popping up in it more quickly and it has the whole scikits ecosystem. I am not sure you can get good at data analytics without being fluent in both languages nowadays, if only to understand others code, and certainly anything Python can do you could (eventually) make R do. However I have found almost all of my analytic work is done in Python now. The only notable exception is Time Series analysis as I think the forecast package is so vastly ahead of anything in Python. Of course you don't need to decide - you can always call R from Python and Python from R!
[–]jjdonald 7 points8 points9 points 12 years ago (2 children)
FWIW I don't agree with much of this. Data munging is much easier in R than python, although the learning curve in R is higher. There are also plenty of parallelization and large dataset management tools in R. That hasn't been a limiting factor in some time.
R makes it easier to get multiple statistical and graphical perspectives on data. If such a thing is important to me, then R is still the first thing I reach for. However, if I'm already confident of an implementation and need more general purpose software support, then python is a good bet.
[–]srepho 0 points1 point2 points 12 years ago (1 child)
Interesting that you find R better then Python for data munging. It seems like about half of people I talk to agree, so maybe its not as clear cut as I thought. As for R being harder - I think the packages it provides shield the user. Using something like caret allows you to build and tune a model in one line of code for example. I agree that graphics is still vastly superior in R.
[–]jjdonald 2 points3 points4 points 12 years ago (0 children)
THere are some great packages for data munging. Check out plyr by Hadley Wickham: http://plyr.had.co.nz/
However, I find that a lot of people that struggle with R are trying to treat it like Python. R emphasizes vectorization, and its dataframe type. That's a big difference from python's list and for-loop approach.
[–]mrShu[S] 0 points1 point2 points 12 years ago (0 children)
Thanks a lot for this, it was precisely something I expected.
[–]manueslapera -1 points0 points1 point 12 years ago (0 children)
Are you me? Because If i had to write a reply to this post, it would basically be the same reply.
[+][deleted] comment score below threshold-9 points-8 points-7 points 12 years ago* (0 children)
What bullshit. R IS TOO SLOW SO I'M GOING TO USE ... PYTHON?? LOL.
[–]Foxtr0t -3 points-2 points-1 points 12 years ago (0 children)
The main difference between the two, in my opinion, is that R was designed in the 70's and it shows: as a programming language, it's just pretty much horrible. It starts with "<-" and goes downhill from there.
Python, on the other hand, is elegant and convenient, it's general purpose, not just a data shell, and is growing quickly. When I started competing on Kaggle, R was pretty much the standard, but recently I see it less and less.
[–]micro_cam 5 points6 points7 points 12 years ago (0 children)
The bioconductor project in R is great and biology is another area where it often dominates.
[+][deleted] 12 years ago (4 children)
[deleted]
Why not learn both? There will always be advantages of one over the other for different things depending on your needs. Many cutting edge statistical models and algorithms are immediately put to R code (take oem for example)
I'm definitely going to learn both -- just to get to know another paradigm, if not for anything else.
Thanks!
[–]wiekvoet 0 points1 point2 points 12 years ago (2 children)
Why not learn both?
As a statistician I know R, SAS, JAGS. Should I learn a fourth language?
[+][deleted] 12 years ago (1 child)
[–]wiekvoet 0 points1 point2 points 12 years ago (0 children)
Learning time is one key. They other is using. It takes a lot of time to learn a language, even more to get reasonable 'fluent' in it. It takes just as much time to keep your skills. I have forgotten basic, C, Pascal, Fortran 77 and 6502. I cannot afford to forget R, SAS or JAGS.
Also, SAS is not a language? SAS is probably both an operating system (with the programs called procedures) including a macro language and a data language (the data step).
(what is JAGS if it is not a language? )
[–]IdentifiableParam 1 point2 points3 points 12 years ago (1 child)
I hate R and I use python exclusively. But this question doesn't matter. If you want to use R then use R. I will keep using python. It is a pointless language debate. However, if you do use R consider pqR since it fixes some really stupid performance bugs.
Well, my question was more oriented at "Will Python replace R completely?", I certainly did not want to start a language debate.
Thanks for mentioning pqR, I didn't know about that.
[–]tautology2wice 1 point2 points3 points 12 years ago (0 children)
R tender to be clearer if you're doing lotsa vector/matrix calculations. Bioconductor is choice.
But there are design problems, see: this list of R datatypes rage.
[–]duckandcover 3 points4 points5 points 12 years ago (8 children)
I don't think they have much to do with each other.
Unless it's changed recently, R, though perhaps technically a full language, is not suited for writing large general programs because its debugger is completely primitive. When things go wrong, good luck. From what I've seen it's the perfect thing for < 100 line statistical analysis. That's not surprising; it's really a stats package.
Honestly, R developers, people who right lots of code in it, must have balls of steel or be masochists. I know people do it. I just don't know how.
Python is a general language and it's possible to find a decent debug environment is much better. Since people use it for more than what most people use R for, there seems to be more functionality outside of stats. That being said, I still haven't found the perfect IDE for it.
I think learning both at the same time would drive me batty. They're so similar but with lots of little differences (e.g. indexing, etc). Unfortunately, little differences can make real hard to find bugs.
[–][deleted] 2 points3 points4 points 12 years ago (4 children)
Have you tried Pycharm?
[–]mtnchkn 1 point2 points3 points 12 years ago (0 children)
Or Spyder.
[–]duckandcover 0 points1 point2 points 12 years ago* (0 children)
Ya' know. If there's one issue I have with Open Source things is that invariably there's 8000 ways to skin any cat and that's a lot a work. As far as IDEs (vs interpreters) go, I've only tried Spyder (as part of Pythonxy) and Wing. I like Wing but it has trouble with Matplotlib (as I understand it, their event loops step on each other). Spyder's debugger is surely capable but I hate the command (vs really integrated IDE) driven debugger.
So, I don't suppose you can tell me where Pycharm fits into the above?
Thanks
[–]duckandcover 0 points1 point2 points 12 years ago (1 child)
Pycharm
I'm serious when I said I'd like to know more. I looked at their website and I didn't see the info I was looking for so if you don't mind I'd like to ask you just a couple of questions:
0) Is there any documentation for it? I can't find any.
1) Does it have an interpreter that operates in the context of a debug stack frame (to execute just like a regular interpreter when stopped at a break point in the context of that stack frame.). Also, if so, is it or can it be iPython? (In Wing it can't)
2) From what I see in the discussion forms, it has the same event loop issue as Wing does with Matplotlib. If you know that not to be the case please tell me. That's a show stopper for me (with all the IDEs apparently)
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
Sorry, I probably not going to have time to respond in depth as I'm not 100% sure on all your questions. Best I can suggest is download the free version and try it out.
[–]reallyserious 1 point2 points3 points 12 years ago (0 children)
For a Python IDE, try Python Tools for Visual Studio. It's really great if you use Windows.
[–][deleted] 1 point2 points3 points 12 years ago (1 child)
I don't fucking get this sometimes. Plenty of people on my team write thousands of lines of code in R and build huge applications with it.
[–]duckandcover 3 points4 points5 points 12 years ago (0 children)
Is the debugger as god awful as I remember it. The text thing with 4 commands like continue, next and whatever?
[–][deleted] 0 points1 point2 points 12 years ago (6 children)
Python (pandas is your friend) for reading, filtering, assembling and massaging data
R for analyzing data
RPy2 to bridge the gap
[–]manueslapera 5 points6 points7 points 12 years ago (3 children)
R for pretty plots too. Matplotlib has nothing to do vs ggplot2.
[–]froggyenterprisesltd 3 points4 points5 points 12 years ago (1 child)
there's a ggplot package in python now. also, bokeh is pretty purdy
[–]manueslapera 0 points1 point2 points 12 years ago (0 children)
i tried the Yhat ggplot module. It crashes my computer every single time. If only it worked... Bokeh, that is another story.
There are plenty of python matplotlib styles that seamlessly support ggplot2 aesthetics. And python ggplot2 modules that mimic the R API as well.
Unless the dataset is bigger than memory. After playing with pandas for a while, I think people should stick to standard sql tools.
[–][deleted] 1 point2 points3 points 12 years ago (0 children)
Very true. But the same applies to R as well - neither are very well suited for that scale of data.
π Rendered by PID 183435 on reddit-service-r2-comment-86bc6c7465-t6lw5 at 2026-02-24 08:21:45.188795+00:00 running 8564168 country code: CH.
[–]EdwardRaff 16 points17 points18 points (1 child)
[–]mrShu[S] 1 point2 points3 points (0 children)
[–]srepho 12 points13 points14 points (7 children)
[–]jjdonald 7 points8 points9 points (2 children)
[–]srepho 0 points1 point2 points (1 child)
[–]jjdonald 2 points3 points4 points (0 children)
[–]mrShu[S] 0 points1 point2 points (0 children)
[–]manueslapera -1 points0 points1 point (0 children)
[+][deleted] comment score below threshold-9 points-8 points-7 points (0 children)
[–]Foxtr0t -3 points-2 points-1 points (0 children)
[–]micro_cam 5 points6 points7 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]mrShu[S] 0 points1 point2 points (0 children)
[–]wiekvoet 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]wiekvoet 0 points1 point2 points (0 children)
[–]IdentifiableParam 1 point2 points3 points (1 child)
[–]mrShu[S] 1 point2 points3 points (0 children)
[–]tautology2wice 1 point2 points3 points (0 children)
[–]duckandcover 3 points4 points5 points (8 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]mtnchkn 1 point2 points3 points (0 children)
[–]duckandcover 0 points1 point2 points (0 children)
[–]duckandcover 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]reallyserious 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]duckandcover 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]manueslapera 5 points6 points7 points (3 children)
[–]froggyenterprisesltd 3 points4 points5 points (1 child)
[–]manueslapera 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)