ryan-duve

ryan-duve

Data science and machine learning workflows in Elixir

As a data scientist at an insurtech, I primarily develop in Python but the rest of our company uses Elixir for non-DSML (data science/machine learning) things, and I’ve been trying to get into it for my own workflows. An engineer suggested I reach out here to see if either @josevalim or someone else familiar with DSML work might be able to help me bridge the gap and get productive in Elixir.

I’ve had some luck using Explorer to look at data and tinkering with Ecto to hit our databases, but not much more. I largely get stuck because the following DSML workflows don’t seem suited for the process/concurrency paradigm underneath Erlang/Elixir:

DS Workflows [data exploration]
When I’m deserializing a dataset, that’s what I need my CPU doing with all 8 cylinders. When I want to aggregate by a column and print some statistics, that’s all I need to be doing. Same with all other data exploration and discovery transformations. I haven’t been able to find a way to utilize Elixir’s process model in a way that improves upon imperative approaches with Python for tasks like A) load dataset, B) transform dataset, C) calculate number of interest.

ML Workflows [deployment/inference]
Each machine learning model runs inference in its own endpoint: data in and number out. Parallel execution for heavy loads are handled horizontally by spinning up more machines as needed on demand. Is there some obvious benefit from doing this in Elixir or do we need to go back to drawing board and rethink everything about how we deploy models within the Elixir VM?

My hope is I’m just overlooking/misunderstanding something about the benefits of working with Elixir. I want to get into it for the native, functional approach, immutable data and being able to debug processes while they’re running. I appreciate anything people here can share to help me get off the ground.

Marked As Solved

josevalim

josevalim

Creator of Elixir

Hi @ryan-duve, welcome! :wave:

You are right that the concurrency aspect of Elixir won’t help much with data exploration. In this area, we are pretty much on the same baseline as Python. The good news is that we can also delegate to C/Rust, just as Python, and that’s the goal with Explorer. It is based on the amazing Polars (which also has Python bindings) and folks report it to be consistently faster than Pandas. So my suggestion is to give Explorer a try and let us know what you are missing in the issues tracker. It is pretty much work in progress and you will hit some walls. But this feedback will help us know what to focus on next. Also, the next release of Livebook will start bringing more features guided towards data exploration.

For machine learning inference, one of the benefits of Elixir is that you can run it within your application. I cover this in the Bumblebee announcement. If this is useful or not, it will be depend on your application. For example, for data processing with Broadway or embedded devices with Nerves, that can be really useful. But for a web application, you may resort to separate services anyway, especially for larger models, just as you would in Python.

In other words, for your questions the answers are mostly “just do it as you have been doing in Python” - unless you see a benefit on deploying the model with your app. So you may be wondering where Elixir can be beneficial:

  • Using a functional programming language for writing computational models can have its benefits: Nx (Numerical Elixir) is now publicly available - Dashbit Blog

  • Nx was designed from scratch to support multiple compilers. This means that you can choose between Torch or XLA easily. Most of our focus is on XLA at the moment but this vision will become truer as we pour more work into it

  • By using Nx as a foundation, everything we build can be compiled to the GPU. For example, we are working on Scholar, which is equivalent to scikit-learn, but everything can be tensor compiled to both CPU and GPU and we get consistently faster results thanks to it

  • Finally, when it comes to distributed and federated work, then Elixir has the potential to standout. We want to explore how to coordinate work across multiple machines for both data processing and machine learning

I hope this gives you an idea of where we are and what to expect. There is a lot of work but there is a group of people who are working hard and are excited on making this vision come true. Questions, feedback, and help are all welcome!

Also Liked

linusdm

linusdm

I could imagine that a lot of the data exploration is ad-hoc, and that’s where Livebook really helps. It gives you a nice playground with the added bonus of documenting your process and sharing back and forth with your developer colleagues.

I’ve also had nice results with Flow, which allows you to define a concurrent data-crunching pipeline, within Livebook. No better feeling than setting up a pipeline that utilises all your resources just right, and being able to tinker with it in a short feedback loop.

Add to this the ability to use Ecto within Livebook, and you’re all set up to load and dump to the database at full speed.

And then, at the end of the ride, you can graph everything nicely with the kino-vegalite package to impress everyone with your colourful results.

I can’t add anything to the ML side of things, except the interop between Livebook and all the ML libraries mentioned is already great, and getting better. Welcome to the community!

Where Next?

Popular in Discussions Top

Rustixir
Hi everyone, im working on find best language/framework/system for high concurrency, high performance and stable performance after wor...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
fireproofsocks
This is more of a general question, but I’m wondering how other people in the community think about the pattern matching in function sign...
New
Qqwy
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses ...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement