Live data from Hacker News

Machine Learning in JavaScript

burakkanber.com

31–40 of 51 posts

Re: Machine Learning in JavaScript

#31
post #6

For neural networks, you can use BrainJS https://github.com/harthur/brain

So the input/output pairs are a linked list of objects? Which then contain vectors comprised of linked lists? I am not very into JavaScript, but that right there must preclude this from doing anything significant in a reasonable amount of time?

Re: Machine Learning in JavaScript

#32
post #24

Earlier quoted context omitted.

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…

> 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 concepts early in their career? Is there some requirement that ML _must_ be an advanced topic, only accessible to polyglots that I haven't heard about?

Re: Machine Learning in JavaScript

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

"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 libraries). They provide fast and reliable math routines so you don't have to worry about some eigenvalue decomposition, matrix multiplication and other problems.

Re: Machine Learning in JavaScript

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

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 isn't room for the easier to understand and easier to read guides to ML. More the better, Mitchell was a beast to read through. Its just the language isn't the hard part of the subject. You are the author of the link, correct? I read through some of it, and its approaches the theory and subject matter in a gentle way which is what matters. The sample code is easy to read. I've written maybe 100 lines of js in my life and avoid all web dev like the plague. Your guide is well written and useful. I am not dogging it at all and please don't take it that way. I think its great!

What I'm saying is if someone is saying to themselves "I would be able to learn machine learning if only their was a guide in X" then they are probably mistaken. The code is easy, the math and theory is what is hard.

Re: Machine Learning in JavaScript

#35
post #33
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…

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

I'm not sure I understand the point you're trying to make. Are you telling me I should not have written this series? That it's somehow not valuable because you don't like JS? That I can't effectively teach basic machine learning concepts to interested people without forcing linear algebra onto them? That, as a teacher, I can't try to use any and all tools and techniques available to the group I'm trying to teach?

I've even explicitly mentioned that I'm staying away from algorithms that rely on linear algebra, because I'm trying to bring these concepts to people who may not have a CS or mathematical background.

Re: Machine Learning in JavaScript

#36
For those who aren't familiar Andrej Karpathy has done a lot of cool stuff with ML in JS. Particularly he has a CNN library -- deep learning comes to JS!

http://cs.stanford.edu/people/karpathy/convnetjs/

http://cs.stanford.edu/people/karpathy/svmjs/demo/

Heather Arthur (npm libraries brain, classifier) has also done a bunch of cool stuff!

https://github.com/harthur

Re: Machine Learning in JavaScript

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

Re: Machine Learning in JavaScript

#39
post #33
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…

"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 has horrid, bug-prone semantics, but it's impressively well optimized.

I also agree that other languages offer better tools. For instance, Python has Numpy. However, that's written in C++, not in Python. You can write plugins for Node in C++ too, so nothing would stop someone from writing a Numpy equivalent for JS. You might even be able to run it in some browsers through something like Emscripten with a performance overhead of 2-3x (I think?)

Re: Machine Learning in JavaScript

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

> 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 C-like languages but have had trouble seeing the algorithms in full relief when translating from Python, for instance.

The point is, your experience is not everyone's experience. My goal is purely one of accessibility of education. There are smart, talented people who never played with ML simply because they didn't want to dive into a different language, different platform, and different environment just to muck around. There are people who hadn't heard of ML before, but tried it out because JS was right there for them. There are people who stayed away from ML because they thought higher math and a CS education were requirements. Those are facts. This series serves all those people, and it serves them well.

Post reply on HN