News for hackers. Stuff that matters.
Re:Scikit-Learn Version 1.0 by boringg on Tuesday September 14, 2021 @09:41AM (#28524653)
Wait how many companies are actually using R in the wild? As I understand it, R is born of academia, great for statistics/analysis but breaks down on data manipulation and isn't used in production/data engineering. Maybe my understanding is dated though?
Re:Scikit-Learn Version 1.0 by baron_harkonnen on Tuesday September 14, 2021 @11:52AM (#28526646)
Of the many companies I've done data science with I can only think of a few, rare exceptions where R wasn't used as much as if not more than Python.

If you're mostly dealing with Neural Nets you won't see much R, but for anything really statistical in nature R is a much better tool than Python. For anything that ends up in a report R is much better than Python (a lot of very valuable data science work ends up being a report to non-technical people).

> breaks down on data manipulation

This is very outdated. The tidyverse eco-system has bumped R back into being first in class for data manipulation now. This becomes less true as you get further and further from having your data in a matrix/df (I can't imagine doing Spark queries in R), but if you already have a basic data frame, manipulation from there is very easy.

Even for things that end up in production, whether you're in R or Python, whatever your first pass is should always be a prototype and will have to be reworked before you get close to moving it to production.

Re:Scikit-Learn Version 1.0 by dagw on Tuesday September 14, 2021 @10:35AM (#28525468)
Wait how many companies are actually using R in the wild?

Depends on your definition. While not very often 'deployed' in 'production'. I know lots places in all kinds of industries where people reach for R as soon as they have to look at some new data.

Re:Scikit-Learn Version 1.0 by dachryn on Tuesday September 14, 2021 @10:23AM (#28525291)
R is everywhere, especially when you need to visualize stuff. It is primarily used in teams who are trying to get rid of SAS in my experience.

You are right in the sense that R is typically not used end-to-end as far as I can tell, but already tries to start with a data connection to some sort of dump or datalake, or datawarehouse.

Many people in my team use Python for modelling, but grab ggplot in whatever way to make their presentations and visuals (they all use different methods, usually something messy like mixing python and R in a notebook or so). GGPlots also has a vast library of super high quality plugins.

Python is far far behind in the viz space

Re:Scikit-Learn Version 1.0 by RobinL on Tuesday September 14, 2021 @02:54PM (#28529248)
I don't think it's correct to say Python is far behind in the viz space at all. It's just different.

I primarily use Altair within Python. ggplot is ahead of Altair in some respects, but behind in others.

For example, here is a chart which can be made in Altair:

https://altair-viz.github.io/gallery/seattle_weather_interac...

Note:

- You can brush over the date range to filter the bar chart

- You can click on weather type to filter the scatter chart

- It can be embedded in any webpage with these interactive elements in tact. Since the chart is represented by json and rendered by javascript, the spec also embeds the data within the chart itself, and allows the user to therefore change the chart however they want

You can even build something like gapminder: https://vega.github.io/vega-lite/examples/interactive_global...

More examples here: https://altair-viz.github.io/gallery/

Re:Scikit-Learn Version 1.0 by mrtranscendence on Tuesday September 14, 2021 @10:35AM (#28525465)
There are Python ports of ggplot (e.g. plotnine (https://github.com/has2k1/plotnine)), but agreed, Python is behind here. I'm not the best at data viz, but I can usually piece together a way to make ggplot do what I want it to do without that much trouble or looking at documentation.

Matplotlib, though ... that's a harder beast to internalize. I know it's possible to make high-quality matplotlib plots, but it's much harder for me. Like pandas, it's a library that I don't want to denigrate because I know people put lots of effort into it, but I can't lie -- I'm not a fan.

Re:Scikit-Learn Version 1.0 by mindv0rtex on Tuesday September 14, 2021 @11:17AM (#28526138)
Speaking of what's possible in matplotlib, I am very much looking forward to reading this book: https://github.com/rougier/scientific-visualization-book
Re:Scikit-Learn Version 1.0 by abacadaba on Tuesday September 14, 2021 @07:15PM (#28532806)
Ah SAS, the one language that makes R look good.
Re:Scikit-Learn Version 1.0 by Tarq0n on Tuesday September 14, 2021 @10:22AM (#28525274)
It's mostly the "in production" part that determines whether R is suitable for a business or not. It's much more complicated to avoid runtime errors or do proper testing in R, whereas it shines for interactive use, or generating reports.

That said having used both the DSL's for plotting and data wrangling in the R package ecosystem are vastly superior to pandas and python plotting libraries. For modeling I actually like the better namespacing of Python which helps keep things more legible when there are a ton of model options to choose from, assuming you don't need cutting edge statistics.

Re:Scikit-Learn Version 1.0 by mrtranscendence on Tuesday September 14, 2021 @10:39AM (#28525521)
> It's much more complicated to avoid runtime errors or do proper testing in R

It's not that much harder. There's no pytest, but testthat works well enough. I've developed a few packages internally in R and wouldn't say it was that much harder to ensure correctness than for the corresponding Python packages. (We used to keep them in sync, before basically moving everything to Python.)

Re:Scikit-Learn Version 1.0 by disgruntledphd2 on Tuesday September 14, 2021 @11:47AM (#28526558)
I actually quite like R's error handling. It's as good as Common Lisp's which is often held up as the epitome of this.

You also have the dump.frames option, which will save your workspace on failure, which is incredibly useful when running R stuff remotely/in a distributed fashion.

Re:Scikit-Learn Version 1.0 by nojito on Tuesday September 14, 2021 @12:23PM (#28527099)
R with data.table and collapse blow away the competition in terms of tabular data wrangling.

Both in terms of conciseness and performance

https://h2oai.github.io/db-benchmark/

Re:Scikit-Learn Version 1.0 by lysecret on Tuesday September 14, 2021 @09:49AM (#28524750)
used to work in insurance and heavily used it.
Re:Scikit-Learn Version 1.0 by disgruntledphd2 on Tuesday September 14, 2021 @10:04AM (#28524996)
> Wait how many companies are actually using R in the wild? As I understand it, R is born of academia, great for statistics/analysis but breaks down on data manipulation and isn't used in production/data engineering.

It depends, I've worked in some places where R was the core part of their data infrastructure. Data manipulation (of non text) is far, far better in R.

Integrating with other systems can be tricky though, and you don't have the wide variety of Python libraries available for core SE tasks, so it can often make sense to use Python even though it's not as good for a lot of the core work.

Additionally, R is a very, very flexible language (like Python), but without strong community lead norms (unlike Python) so it's pretty easy to make a mess with it.

Finally, when you need to hand over stuff to software engineers, they vastly tend to prefer Python, so it often ends up being used to make this stuff easier.

Like, in R there's a core tool called broom which will pull out the important features of a model and make it really easy to examine them with your data. There's nothing comparable in Python, and I miss it so so much when I use Python.

That being said, working with strings is much much nicer in Python, and pytest is the bomb, so there's tradeoffs everywhere.

Re:Scikit-Learn Version 1.0 by mrtranscendence on Tuesday September 14, 2021 @10:27AM (#28525342)
It's unrelated to your main point, but:

> Additionally, R is a very, very flexible language (like Python)

I'd argue that R is much more flexible than Python syntactically. There's a reason that every attempt at recreating dplyr in Python ends in a bit of a mess (IMO) -- Python just doesn't allow the sort of metaprogramming you'd require for a really nice port. Something as simple as a general pipe operator can't be defined in Python, to say nothing of how dplyr scopes column names within verbs.

Arguably this does allow you to go crazy in a way that ends up being detrimental to readability, but I'd say overall it's a net benefit to R over Python. I really miss this stuff and have spent an undue amount of time thinking of the best way to emulate it (only to come up with ideas that just disappoint).

> Finally, when you need to hand over stuff to software engineers, they vastly tend to prefer Python

Indeed, this is maybe 50% of the reason my organization has pushed R to the sidelines over the past few years. We used to be very heavily into R but now it has "you can use it, but don't expect support" status.

Re:Scikit-Learn Version 1.0 by mrtranscendence on Tuesday September 14, 2021 @11:00AM (#28525884)
(Replying to disgruntledphd2)

> Well that's just lazy evaluation of function arguments, which can't be done in Python.

"Just lazy evaluation"! :) It's a pretty big deal. This is three-fifths of the way to a macro system.

> But if take a look at the Python data model, it does seem super, super flexible.

Sure, you can have a lot of control over the behavior of Python objects (some techniques of which remain obscure to me even after using Python for many years). But you don't have anything like syntactic macros. You can define a pipe operator with macropy, though -- it's pretty easy. But macropy is basically dead now I think (and a total hack).

> You'll still need strings for column names in any dplyr port though, because of the function argument issue.

This is major, though, because you can't do this:

    mutate(df, x="y" + "z")
You have to do something like what dfply does, defining an object that defines addition, subtraction, etc.

    mutate(df, x=X.y + X.z)
But that hits corner cases quickly. What if you want to call a regular Python function that expects numeric arguments? This won't work:

    mutate(df, x=f(X.y))
etc. Granted, this only really works in R because it's easy to define functions that accept and return vectors. So in that sense it's kind of a leaky abstraction. But you couldn't even get that far in Python, because X.y isn't a vector ... it's a kind of promise to substitute a vector.

Give Python macros, I say! To hell with the consequences!

Re:Scikit-Learn Version 1.0 by dragonwriter on Tuesday September 14, 2021 @11:10AM (#28526036)
> Sure, you can have a lot of control over the behavior of Python objects (some techniques of which remain obscure to me even after using Python for many years). But you don't have anything like syntactic macros.

Not yet, but there’s a PEP for that:

https://www.python.org/dev/peps/pep-0638/

Re:Scikit-Learn Version 1.0 by mrtranscendence on Tuesday September 14, 2021 @11:51AM (#28526623)
Nice, I'd love for this to see the light of day. I suspect it'll see some resistance (even pattern matching caused conflict, and I thought that was terribly innocuous).

(Why can I reply at this level of nesting now, whereas before I couldn't?)

Re:Scikit-Learn Version 1.0 by disgruntledphd2 on Tuesday September 14, 2021 @11:49AM (#28526589)
I'm totally with you on these points, and it's one of the places where R's genesis as a scheme program has lead to really, really good consequences.

Fundamentally though, both DS Python and R are abstractions over well-tested Fortran linear algebra routines (I'm sortof kidding, but only sortof).

Re:Scikit-Learn Version 1.0 by disgruntledphd2 on Tuesday September 14, 2021 @10:37AM (#28525489)
> I'd argue that R is much more flexible than Python syntactically. There's a reason that every attempt at recreating dplyr in Python ends in a bit of a mess (IMO) -- Python just doesn't allow the sort of metaprogramming you'd require for a really nice port. Something as simple as a general pipe operator can't be defined in Python, to say nothing of how dplyr scopes column names within verbs.

Well that's just lazy evaluation of function arguments, which can't be done in Python. But if take a look at the Python data model, it does seem super, super flexible. You'll still need strings for column names in any dplyr port though, because of the function argument issue.

Like, both Python/R derive from the CLOS approach (Art of the Metaobject Protocol), but R retains a lot more of the lispy goodness (but Python's implementation is easier to use).