The NumPy for Elm

336 views
Skip to first unread message

Francisco Ramos

unread,
Oct 31, 2017, 8:32:06 AM10/31/17
to Elm Discuss
Today I'm releasing NumElm, another small contribution to the Open Source, Frontend and Elm community. NumElm is inspired by NumPy, the fundamental package for scientific computing with Python. NumElm is the first step in this ambitious idea of mine of building a Machine Learning package for Elm. Still a long way to go, but I'm full of enthusiasm. I'm convinced about the potential of both worlds together, Elm language and Machine Learning.


Please, any feedback would be highly appreciated.

Fran

Peter Damoc

unread,
Oct 31, 2017, 8:42:07 AM10/31/17
to Elm Discuss
Hi Fran, 

I would be interested in seeing performance benchmarks agains NumPy. 
I'm expecting NumElm to be worse but I'm curious how much worse it is. :) 

In any case, congrats for creating this! 



--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

Francisco Ramos

unread,
Oct 31, 2017, 8:52:45 AM10/31/17
to elm-d...@googlegroups.com
Hi Peter,

Thanks for the feedback. Yes, that's in my list of TO-DOs. I'm guessing the difference will be quite significant, but I'm planning to use hardward-accelerated code as a next step. I'll create though some benchmarks gainst NumPy.

Thanks again,
Fran



On Tue, Oct 31, 2017 at 1:42 PM Peter Damoc <pda...@gmail.com> wrote:
Hi Fran, 

I would be interested in seeing performance benchmarks agains NumPy. 
I'm expecting NumElm to be worse but I'm curious how much worse it is. :) 

In any case, congrats for creating this! 


On Tue, Oct 31, 2017 at 2:32 PM, Francisco Ramos <jscrip...@gmail.com> wrote:
Today I'm releasing NumElm, another small contribution to the Open Source, Frontend and Elm community. NumElm is inspired by NumPy, the fundamental package for scientific computing with Python. NumElm is the first step in this ambitious idea of mine of building a Machine Learning package for Elm. Still a long way to go, but I'm full of enthusiasm. I'm convinced about the potential of both worlds together, Elm language and Machine Learning.


Please, any feedback would be highly appreciated.

Fran

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.

Rupert Smith

unread,
Oct 31, 2017, 10:19:11 AM10/31/17
to Elm Discuss
On Tuesday, October 31, 2017 at 12:42:07 PM UTC, Peter Damoc wrote:
Hi Fran, 

I would be interested in seeing performance benchmarks agains NumPy. 
I'm expecting NumElm to be worse but I'm curious how much worse it is. :) 

In any case, congrats for creating this!

I'm expecting the Elm version to be faster. C'mon Elm! 

Rupert Smith

unread,
Nov 1, 2017, 4:38:48 PM11/1/17
to Elm Discuss
On Tuesday, October 31, 2017 at 12:32:06 PM UTC, Francisco Ramos wrote:

Please, any feedback would be highly appreciated.

So, I have a project at work where we are using NumPy running on AWS. I have been looking into how to write AWS Lambda functions using Elm, and found this excellent project:


One cool thing about how it is implemented, is that it uses a wrapper around the Elm program to establish a new type of 'Program'. As such it doesn't have ports or hacked any kernel code - yet it is definitely stretching Elm well outside of it comfort zone as a client side only language. I think that is pretty neat, because my instincts would have been either to use ports or do some kernel hacking and ended up with code that I could not then share on package.elm-lang.org. I somehow automatically assume that doing anything with elm that is not TEA is going to involve native code in such a way that a non-shareable package is created and the back-door that is elm-github-install will be used.

My work project involves running an algorithm in NumPy against 10s or 100s of days of data points and doing some curve fitting to then make an estimate of when some equipment is going to exceeed its specified operating parameters (I'm being vague because I signed an NDA).

So once I get my Elm Lambda functions experiment working nicely, I can try out converting the NumPy algorithms into NumElm. All the NumPy algorithms I have are quite short, its fairly simple stuff we are doing. Even if NumElm turns out a bit slow, its only a few hundred data points at most so I think it will be ok. I also think fetching the data from the database (Athena) will tend to dominate rather than the CPU work.

How would I write a curve fitting alrogithm with this? So I have a 3rd order polynomial:

y = a + b.x + c.x^2 + d.x^3

and some linear algebra on 100 data points will yield values for a, b, c and d. I'll post up the python code tomorrow, it seems to use an in-built fit_curve() function.

Rupert

 

Rupert Smith

unread,
Nov 2, 2017, 10:41:39 AM11/2/17
to Elm Discuss
On Wednesday, November 1, 2017 at 8:38:48 PM UTC, Rupert Smith wrote:
How would I write a curve fitting alrogithm with this? So I have a 3rd order polynomial:

y = a + b.x + c.x^2 + d.x^3

and some linear algebra on 100 data points will yield values for a, b, c and d. I'll post up the python code tomorrow, it seems to use an in-built fit_curve() function.

Here is the NumPy code that I would like to convert to NumElm: 

import time
import numpy as nm

def get_curve(measurements, timestamps):
  y
= measurements
  x
= timestamps
  z
= nm.polyfit(x, y, 3)
  f
= nm.poly1d(z)


 
return f


but polyfit and poly1d have not been ported to NumElm. I will take a look into how to port them.

Rupert

Francisco Ramos

unread,
Nov 2, 2017, 1:28:15 PM11/2/17
to elm-d...@googlegroups.com

Hey Rupert,

Let me have a look when I have a little bit of time and I'll get back to you.

Fran


Matthieu Pizenberg

unread,
Nov 2, 2017, 2:31:47 PM11/2/17
to Elm Discuss
Hi Francisco, that's awesome what you aim for. I'm also looking forward for more scientific programming stuff in elm.
Inspiration from numpy is a great choice considering almost all learning frameworks are usable in python. As a sidenote though you might want to have a look at the xtensor project (also inspired by numpy). I've not used it yet but I've seen their introduction video at PyData and the approach looks great! I think it could give you some ideas if you want to create a generic package for machine learning in elm.

Cheers,
Matthieu

Francisco Ramos

unread,
Nov 2, 2017, 2:41:15 PM11/2/17
to elm-d...@googlegroups.com

That's great. Thanks for the links. I read about PyData. Sounds promising... I'm algo checking out ML packages in Haskell. I'd like to see other more functional approaches.

Fran

Rupert Smith

unread,
Nov 3, 2017, 5:39:55 AM11/3/17
to Elm Discuss
On Thursday, November 2, 2017 at 5:28:15 PM UTC, Francisco Ramos wrote:

Hey Rupert,

Let me have a look when I have a little bit of time and I'll get back to you.

Fran


I will also have a go at implementing the polynomial stuff in my own Plynomials.elm built on top of what NumElm already has. If I make some good progress with it, then we can look at pulling it into NumElm.

Rupert 

Francisco Ramos

unread,
Nov 3, 2017, 6:06:49 AM11/3/17
to elm-d...@googlegroups.com

Sounds good. Remember, I built NumElm with Machine Learning algorithms in mind. So I added mostly the functionality used in such algorithms. 


I created this gist for you. Just now, and without testing, so I'm not sure if it works, but it looks like what you're looking for. Please give it a try and let me know:

https://gist.github.com/jscriptcoder/3be0e4186bc8098d1310e6e7fb3bf441


Fran


--

Rupert Smith

unread,
Nov 3, 2017, 7:30:51 PM11/3/17
to Elm Discuss
On Friday, November 3, 2017 at 10:06:49 AM UTC, Francisco Ramos wrote:

Sounds good. Remember, I built NumElm with Machine Learning algorithms in mind. So I added mostly the functionality used in such algorithms. 


I suppose polynomial fitting is a kind of machine learning. I am a little bemused by how much ML currently seems to be focused on neural networks, I always thought kernel methods would overtake the neural approach. Kernel methods map non-linear problems back into linear ones with higher dimensionality, just like how this polynomial curve fitting turns a polynomial into a linear fitting problem with as many dimensions as the degree of the polynomial.

I created this gist for you. Just now, and without testing, so I'm not sure if it works, but it looks like what you're looking for. Please give it a try and let me know:

https://gist.github.com/jscriptcoder/3be0e4186bc8098d1310e6e7fb3bf441


Thanks.
Reply all
Reply to author
Forward
0 new messages