Saturday, November 17, 2012

NumericJS Logistic Regression Classifier

The other day I posted about numericjs and provided a simple PCA implementation using it. Today I rewrote my logistic regression classifer using numericjs. Below is the commented sourcecode and demo in jsFiddle.

For the demo, you click on the large square (in the "Result" panel) to add a point. The dropdown box labeled "group" allows you to select the color of point to add. You can change the learning rate (alpha) and the regularization parameter (lambda) to see how it changes the classification.

In case you're using a feed reader and can't see the box below, click here.


Soumen Madan said...

What are your thoughts on using Javascript for Machine Learning vs using python or octave?

Wybiral said...

Javascript has come a long way. But Python and Octave will walk circles around it when it comes to raw performance (allowing you to run more robust algorithms and train on larger datasets).

If you need to do some serious number crunching on large datasets, use Python or Octave.

With that being said, neither of those two are available in the web browser.

Wybiral said...

I should note that I mean "Python, assuming it's with NumPy". Plain old interpreted Python probably wouldn't perform much better if at all.

But everyone uses NumPy when they do serious computing in Python so it's just assumed.