Lecture 33 - Classification and a Binary Classifier Zoo

in which Scott tries to fit about 60% of a machine learning course into 50 minutes

Announcements:

Goals:

Import basic packages and data-munging tools:

Make three synthetic, 2D binary classification data sets:

Plot the datasets:

What exactly are we trying to do here?

See written notes:

Linear Regression, But For Classification?

The simplest regression model we could come up with was linear regression, which assumes that $y$ is a linear function of the input vector $\mathbf{x}$.

What's the corresponding model for classification?

Multiple possible choices for $h$:

Multiple variants of linear classifiers exist with the same modeling assumptions. Their variations derive from on how you find the linear weights $\mathbf{w}$.

But how do we actually find $\mathbf{w}$?

Cheeky answer: Math.

Less cheeky answer: Start with a random $\mathbf{w}$ and wiggle it in a direction that makes your model perform better until wiggling it doesn't make it better.

This applies to linear regression, linear classifiers, and the vast majority all of machine learning models in use today.

A nice visualization of what this looks like (albeit with a more complicated model) is here. Try replacing the block of layer_defs with the following:

layer_defs = [];
layer_defs.push({type:'input', out_sx:1, out_sy:1, out_depth:2});
layer_defs.push({type:'softmax', num_classes:2});

How do you do multilabel classification?

Some classifiers handle this naturally by outputting a score or probability for each class.

Other classifiers don't; you can adapt them to multiclass classifiers using a one-vs-rest strategy:

Classifier Zoo

Meet the classifiers:

Some matplotlib drudgery to plot the results of running a classifier on one of the above datasets:

This function trains a single classifier from the zoo above on each of the datasets and uses plot_clf_results to show the results.

A whirlwind tour of the zoo