Live data from Hacker News

Machine Learning in JavaScript

burakkanber.com

21–30 of 51 posts

Re: Machine Learning in JavaScript

#21

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 affini…

Nodejs is for i/o, i know it has workarounds for long running tasks(threadpool) but it does not excell at that. Training your model, updating your model, validation, matrix factorization on large datasets etc, i just don't see how Javascript helps here. Maybe just taking the http request and dumping it onto a rabbitmq queue to to classify something but you still have a whole host of other stuff to deal with.

Re: Machine Learning in JavaScript

#22

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 affini…

Nodejs is for i/o, i know it has workarounds for long running tasks(threadpool) but it does not excell at that. Training your model, updating your model, validation, matrix factorization on large datasets etc, i just don't see how Javascript helps here. Maybe just taking the http request and dumping it onto a rabbitmq queue to to classify something but you still have a whole host of other stuff to deal with.

I think they are making the argument for capability rather than best of class. This is really exciting for Javascript and NodeJS devs right now because of the "Give me an inch and I'll take a foot" mentality.

Re: Machine Learning in JavaScript

#23
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.

You need the love of the data science community and they have settled on python, and when they really want to scale they use Java. I noticed Julia becoming very popular and the twitter guys use scala for their stuff.

Re: Machine Learning in JavaScript

#24
post #15
post #13

Earlier quoted context omitted.

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.

What alternatives would you recommend for someone new to programming and CS?

I guess fleeing implies that they were using other tools already, but a lot of new devs are going to JS because it just makes sense to start there (lots of flexibility, hyperactive community, education value).

Re: Machine Learning in JavaScript

#25
post #20
post #12

Earlier quoted context omitted.

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 l…

That's a good point. Of course, the problems with shared mutable state are well-documented and I'm glad that JavaScript hasn't headed down that path. But you're right that Node doesn't have good, mature solutions for that yet (short of your central data store option)

Re: Machine Learning in JavaScript

#26
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…

This is great stuff - thank you very much.

>all those wonderful Python libs

As a non-mathematician I have no understanding of how wonderful they really are, which is why this sort of thing is so valuable.

Re: Machine Learning in JavaScript

#28

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 affini…

Nodejs is for i/o, i know it has workarounds for long running tasks(threadpool) but it does not excell at that. Training your model, updating your model, validation, matrix factorization on large datasets etc, i just don't see how Javascript helps here. Maybe just taking the http request and dumping it onto a rabbitmq queue to to classify something but you still have a whole host of other stuff to deal with.

> Nodejs is for i/o

Node is a general purpose language that can be used for all kinds of things. I switched from Python to node.js about a year ago for exactly the sort of tasks you are describing and could not be happier. Right off the bat I had huge speed improvements.

Also, io is one of the biggest issues with web based data analysis, so it really should not be underestimated. I can do more with less with node than I could with Python. This is especially true with long running tasks where a 1 minute processing time vs a 20 minute processing time might mean you need 1/20th the number of servers in a cluster ($$$).

Of course, this could be a pretty good argument for something even faster/lower level, but for me, node.js struck a good balance between performance and ease of development/ecosystem. As usual, YMMV.

One last point. The language you choose cannot always be the best language for every task you need. Typically you choose a stack based on the most common/important tasks in your infrastructure, then for less common tasks you just make it work with what the chosen language provides. In this case node.js does not need to be the best solution for ML, it just needs to check the box for being possible, so that devs who needed node.js for other reasons now have the ability to add ML to their toolbox.

Re: Machine Learning in JavaScript

#29
post #18
post #17

Earlier quoted context omitted.

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.

How did you first come to get interested in JavaScript?

Re: Machine Learning in JavaScript

#30
post #24
post #15

Earlier quoted context omitted.

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.

What alternatives would you recommend for someone new to programming and CS? I guess fleeing implies that they were using other tools already, but a lot of new devs are going to JS because it just makes sense to start there (lots of flexibility, hyperactive community, education value).

If you are at the point of your CS education that you are taking a serious look at machine learning and understanding the theory then you shouldn't have a problem translating into whatever your language of choice is. I get why a teacher would just want to pick a language and say "this is what it is in" but I don't get people who need CS concepts taught in their language of choice. The hard part is the theory and not the implementation.

When I took it in university it was taught in language agnostic psuedocode and we were free to use any language from a long list for our assignments.

Post reply on HN