Live data from Hacker News

Machine Learning in JavaScript

burakkanber.com

41–50 of 51 posts

Re: Machine Learning in JavaScript

#41
post #33

Earlier quoted context omitted.

"2) it demystifies machine learning -- you have to write your ML from scratch, without the help of all those wonderful Python libs, and I think this exercise shows you that it's not so mysterious after all." - you can demystify machine learning in any better language. JS and PHP are slow, crappy and bug prone. Sane languages (like Python, C++) have tools to make your job easier (like numpy, blas, eigen and other libr…

JS isn't particularly slow any more, thanks to the massive efforts invested in the optimization of the various competing JS engines. It is generally faster than Python 3 ( http://benchmarksgame.alioth.debian.org/u64/benchmark.php?te... ) and not just a little. Just for the hell of it I compared node and python on naive fibonacci. That is anecdotal, of course, but node is 30 times faster . I do agree with you that JS…

Let's not forget webCL. Gpu based matrix multiplication is available in javascript too.

Re: Machine Learning in JavaScript

#42
post #37
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…

Article looks really good! Look forward to longer read tonight. Minor nit: I'd stick with idiomatic JS style/formatting. Looks like you mixed in styles from some of the other languages (tab indentation, braces, etc.) This is always a religious argument, but I write a lot of different languages, and always just try to stick with the most popular idiomatic way, regardless of whether I care for it or not.

Yea, 8-space tabs is a bit ridiculous. I prefer 2 or at most 3.

Re: Machine Learning in JavaScript

#43
post #32

Earlier quoted context omitted.

> 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. This feels like begging the question. Why does that need to be the case? Why can't someone strive to learn machine learning _without_ learning a new language? Why can't they get a head start on the con…

Because the nature of the subject requires a fair amount of background. To truly understand the subject and a lot of the approaches a firm understand of statistics, data structures, and even some calculus. Usually by the time someone these subjects down enough for anything substantial in ML then they've seen enough different languages to suss out the general idea of most algorithm sample code. I'm not saying there is…

>"To truly understand the subject and a lot of the approaches a firm understand of statistics, data structures, and even some calculus. Usually by the time someone these subjects down enough for anything substantial in ML then they've seen enough different languages to suss out the general idea of most algorithm sample code."

I learned calculus and linear algebra long before learning to code.

Re: Machine Learning in JavaScript

#44
Interesting, but I wonder about this:

> … well, most of the time. There are some things you really can’t do in PHP or Javascript, but those are the more advanced algorithms that require heavy matrix math.

Leaving out javascript (in the browser), it sounds like an odd statement to make about php -- after all one of php strengths is how easy it is to link with c-libraries (or other with c ffi)? Among other things I quickly found:

http://www.php.net/manual/en/intro.lapack.php

Re: Machine Learning in JavaScript

#46
post #43

Earlier quoted context omitted.

Because the nature of the subject requires a fair amount of background. To truly understand the subject and a lot of the approaches a firm understand of statistics, data structures, and even some calculus. Usually by the time someone these subjects down enough for anything substantial in ML then they've seen enough different languages to suss out the general idea of most algorithm sample code. I'm not saying there is…

> "To truly understand the subject and a lot of the approaches a firm understand of statistics, data structures, and even some calculus. Usually by the time someone these subjects down enough for anything substantial in ML then they've seen enough different languages to suss out the general idea of most algorithm sample code." I learned calculus and linear algebra long before learning to code.

I don't mean to be snarky, but how was your data structures knowledge then?

He asked "Is there some requirement that ML _must_ be an advanced topic" and I listed a few prerequisite pieces of knowledge that make it fairly advanced. You may learn those prerequisites in a different order but they are required before you properly tackle machine learning without cargoculting through it.

Re: Machine Learning in JavaScript

#47
post #40

Earlier quoted context omitted.

Because the nature of the subject requires a fair amount of background. To truly understand the subject and a lot of the approaches a firm understand of statistics, data structures, and even some calculus. Usually by the time someone these subjects down enough for anything substantial in ML then they've seen enough different languages to suss out the general idea of most algorithm sample code. I'm not saying there is…

> Its just the language isn't the hard part of the subject. For you, sure -- but not for everyone. This series has actually been up for a little over a year now. I get emails from people who didn't know what machine learning was before they started reading the articles, and now they're building some of the most creative and beautiful projects out there. I also get emails from people who need to implement ML in JS or…

I just want to make sure that its clear that I think you are hitting that goal and your posts look great. There is nothing worse than posting something on the internet to have some snarky neckbeard from the peanut gallery put it down for some tangential reason.

Re: Machine Learning in JavaScript

#48
post #27

Cool project! Have you already tried asm.js and/or measured performances?

You cannot write asm.js by hand (in a sane way... it uses one big array for everything). It's meant to be translated from emscripten clang compiler project. So you can compile C/C++ code to asm.js.

But Javascript engines like V8 with its JIT are way faster than Python. You can even use typed arrays that give you almost native speed for such operations (e.g. matrix). I am coding a 3D game in WebGL and JS is as fast as Java when used in a modern fashion, though JS run in every browser

Re: Machine Learning in JavaScript

#49
post #32

Earlier quoted context omitted.

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…

> 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. This feels like begging the question. Why does that need to be the case? Why can't someone strive to learn machine learning _without_ learning a new language? Why can't they get a head start on the con…

When I first wrote "Introduction to open heart surgery: your housecat" people asked me "why housecats?". Because they are easy to find, and can get you real experience. No need to work up to open heart surgery, it should be available to anyone that has a sharp implement, a housecat, and a thirst for knowledge. Bloody, messy, knowledge.

Re: Machine Learning in JavaScript

#50

Earlier quoted context omitted.

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

> Node is a general purpose language that can be used for all kinds of things.

Node is a library that can be used for all kinds of things. FTFY

Post reply on HN