Live data from Hacker News

Machine Learning in JavaScript

burakkanber.com

11–20 of 51 posts

Re: Machine Learning in JavaScript

#12

I still view JS as a UI-oriented language, and I really don't know why would you want to implement processor-heavy algorithms in a browser environment, which need a lot of data and don't use the networking. I would still stick to python. Or java. Or anything else which has a clear syntax and can run at a useful speed (I'm not mentioning C++ because of the coding overhead and dirty tricks which makes it a bit unfriend…

Clarity of syntax is a matter of opinion (personally, I agree that Python is clearer than JS... Java, not so much.)

Implying that JavaScript can't "run at a useful speed" is wrong, using modern implementations. This is especially true for code that runs through lots of repetition as the just-in-time compilers in the JS engines do a remarkable job.

Not to mention that viewing JS as a UI-oriented language seems a bit out of date given the 40k or so packages for Node.js that are in npm.

JavaScript of today is pretty different than JS of 2007, and there are more changes coming with generators, iterators, destructuring, class syntax, arrow functions, promises, etc.

Re: Machine Learning in JavaScript

#14
post #4

That's great, keep up the good work. For some reason it's somewhat hard to find C-style science code examples in some disciplines. Python feels a bit like a plague in this respect. Everytime I have to wrap my head around while converting code to C-like language (C, C++, PHP, JS).

The distance to convert math to python is so much shorter than math to C or math to javascript. You need something like numpy to make working in javasctipt easier before there will be a proliferation of of ML in JS. I really love JS for its distribution and some of the visualizations are amazing. But the low level, numerically stable, matrix math primitives are sorely lacking.

I feel the people doing heavy work with graphics APIs and 3D work with robots too will push this back into the javascript language given some time.

Re: Machine Learning in JavaScript

#15
post #13
post #11

X in JavaScript..... ugh if all you have is a hammer, everything looks like a nail

Have you read the article? I make it pretty apparent that JS is used primarily for its educational value :)

To be honest i didn't initially. I just read it.

I think it is a noble thing to explain this in JS. But i don't think "because every body uses js" is a good reason to choose js.

However your specific use case makes sense. But in a broader sense I see more and more people fleeing to JS because its what they know.

Re: Machine Learning in JavaScript

#16
To those wondering why someone would want ML in JS, there are loads of reasons.

For starters, node.js, which makes most of the arguments regarding server/client moot.

Secondly, there are many client side applications for these types of algorithms as well. K-means clustering, for example, is already used by many mapping libraries to group together large numbers of points[1].

I personally use neural networks and affinity propagation in many of my applications for predictive analysis. This does not have to only be educational, or of a 'toy' nature.

[1] http://danzel.github.io/Leaflet.markercluster/example/marker...

Re: Machine Learning in JavaScript

#17
post #10

Author here -- thanks for submitting, xd! Let me know if you have any questions. I do intend to keep up with this series, although my pace is pretty slow at about one article every three months or so. There are already a couple of comments about running ML in JS and how JS and the browser environment isn't terribly suited for heavy calculations. First: you're totally correct; second, I chose JS because it's 1) access…

No no, thank you!

I've been building a data management platform for the last 8 years and we are now at the stage where we want to provide tools to help our customers get more from their data than just statistics. As my programming experience is mainly in PHP and JS this set of articles is helping me grasp ML rather than trying to wrap my head around a new language. I'm currently working on k-means clustering and re-implementing everything in PHP to get the best possible understanding I can .. my aim after that is to see how well I can implement things at an SQL level.

Re: Machine Learning in JavaScript

#18
post #17
post #10

Author here -- thanks for submitting, xd! Let me know if you have any questions. I do intend to keep up with this series, although my pace is pretty slow at about one article every three months or so. There are already a couple of comments about running ML in JS and how JS and the browser environment isn't terribly suited for heavy calculations. First: you're totally correct; second, I chose JS because it's 1) access…

No no, thank you! I've been building a data management platform for the last 8 years and we are now at the stage where we want to provide tools to help our customers get more from their data than just statistics. As my programming experience is mainly in PHP and JS this set of articles is helping me grasp ML rather than trying to wrap my head around a new language. I'm currently working on k-means clustering and re-i…

Excellent, I'm glad to hear it! If you ever want to reach out, feel free -- email in my profile.

Re: Machine Learning in JavaScript

#19

Earlier quoted context omitted.

The distance to convert math to python is so much shorter than math to C or math to javascript. You need something like numpy to make working in javasctipt easier before there will be a proliferation of of ML in JS. I really love JS for its distribution and some of the visualizations are amazing. But the low level, numerically stable, matrix math primitives are sorely lacking.

I feel the people doing heavy work with graphics APIs and 3D work with robots too will push this back into the javascript language given some time.

I work with robots. The leading middleware is ROS. It is multi language, but does not support JS out the box (unlike LISP, Java, C++ and Python), though there is movement there http://brandonalexander.com/rosnodejs/

I can see JS useful for a UI to a robot, but I can't see it replacing Python for math, or C++ for speed, or LISP for planning systems.

That said, I can imagine node.js being a better async message router than the current C++ one.

ROS is glued together with XML-RPC, which I think was a mistake (why not JSON???)

Re: Machine Learning in JavaScript

#20
post #12

I still view JS as a UI-oriented language, and I really don't know why would you want to implement processor-heavy algorithms in a browser environment, which need a lot of data and don't use the networking. I would still stick to python. Or java. Or anything else which has a clear syntax and can run at a useful speed (I'm not mentioning C++ because of the coding overhead and dirty tricks which makes it a bit unfriend…

Clarity of syntax is a matter of opinion (personally, I agree that Python is clearer than JS... Java, not so much.) Implying that JavaScript can't "run at a useful speed" is wrong, using modern implementations. This is especially true for code that runs through lots of repetition as the just-in-time compilers in the JS engines do a remarkable job. Not to mention that viewing JS as a UI-oriented language seems a bit o…

While I disagree with the comment you're responding to, and agree with yours, there are some interesting problems doing resource heavy operations in ML/NLP in an environment like Node that's inherently single threaded.

I'm actually adding multi-threading to classifier training in node-natural as we speak [0] so it's something I'm recently familiar with. Multi-threading in JS isn't new or particularly exciting (even less so is multithreading in ML/NLP applications) but the marriage of the two has led to a few interesting problems in JS's asynchronous/event based view of the world!

[0]: https://github.com/NaturalNode/natural/issues/124

--

Edited for clarity

Post reply on HN