4
$\begingroup$

R supports a wide range of OOP designs like s3,s4,RC and others via packages,and it's a bit overwhelming to decide on which to use and a more basic question that I have is when and where do you use OOP while doing machine learning or data analytics ,can someone answer this from a data scientist/ML practitioner point of view .

I'm aware of how OOP works in R at a superficial level ,but

should I invest time in learning OOP in R ? how practical is it from a data science point of view ?

$\endgroup$
3
$\begingroup$

I have used S3, S4 and R6 (you forgot that one in your overview ;)). I would agree with Hadley Wickham that S3 is sufficient for most tasks. However, this is only required if you start building advanced functions that operate on objects. Say for example you build a model with one function and you want to create a summary and print function for the object returned by your model building function. For general Data Science purposes I would say that it helps to know the systems but none of them are very good examples of real OOP. For that I would recommend to work in Python, Ruby or Java. All have been build with OOP in mind.

In regards to knowing OOP, I think it is vital for someone involved in ML. Not when you are prototyping in R or Python but definitely when you start working on production code. I think this Quora thread gives a good run down on when OOP becomes important in ML.

If your focus is more on statistics in R it may be of less importance.

$\endgroup$
  • 1
    $\begingroup$ I feel like S3 is the weirdest implementation of OOP.especially coming from java ,it feels very different, to say the least,and for the most part, I've never come across some code that uses OOP while working on some dataset. $\endgroup$ – ultron Nov 15 '16 at 10:06
  • $\begingroup$ Totally agree, I am not even sure how S3 came to be called OOP, however within R it is used a lot since that is how functions such as summary and print know which function to dispatch. $\endgroup$ – Stereo Nov 15 '16 at 10:17
  • $\begingroup$ For some context, R is an open source clone of another language called S, hence, S3 and S4 types. If you want to understand their design I'd look into that language instead. $\endgroup$ – DaveRGP Apr 29 '19 at 9:11

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.