Skip to main content

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.

Comments

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.

Popular posts from this blog

Procedural music with PyAudio and NumPy

Combining two of my favorite pastimes, programming and music... This is the hacky "reduced to it's basic components" version of a library I've been working on for generating music and dealing with music theory.

Tweaking the harmonics by changing the shape of the harmonic components and ratios can produce some interesting sounds. This one only uses sine waveforms, but a square / saw generator is trivial with numpy.

It takes a second to generate, so don't turn your volume up too loud in anticipation (it may be loud).

import math
import numpy
import pyaudio
import itertools
from scipy import interpolate
from operator import itemgetter


class Note:

NOTES = ['c','c#','d','d#','e','f','f#','g','g#','a','a#','b']

def __init__(self, note, octave=4):
self.octave = octave
if isinstance(note, int):
self.index = note
self.note = Note.NOTES[note]
elif isinstance(note, st…

Build a Feed Reader in Python (Parts 7-9)

Part 07 Adding Jinja2 templates to a flask web application.

 Part 08 Adding static files so we can serve some CSS to style our app.

Part 09 Adding a background task to continuously update the articles while the application is running.

Write a Feed Reader in Python

I just started a new video tutorial series. This time it'll cover the entire process of writing an RSS feed reader in Python from start to finish using the feedparser module, flask, and SQLAlchemy. Expect to see about 3-4 new videos a week until this thing is finished!
Click to watch