Table of Contents

Module: SVM Bio/Tools/Classification/SVM.py

This provides code for working with support vector machines.

Support vector machine (SVM) is a supervised machine learning algorithm that has been shown to work well on a variety of classification problems.

XXX describe kernel_fn, C, epsilon

For more information, see: http://svm.first.gmd.de/ http://svm.research.bell-labs.com/

Classes: SVM Holds data for a Support Vector Machine. SMOTrainer Trains an SVM using Sequential Minimal Optimization (SMO). KeerthiTrainer Trains an SVM using Keerthi's extensions to SMO. TransductiveTrainer Trains a transductive SVM.

LinearKernel PolynomialKernel RadialBasisFunctionKernel HyperbolicTangentKernel

Functions: train Train a Support Vector Machine on some training data. trans_transductive classify Use a Support Vector Machine to classify some data.

Usage: The train function is provided as a user-friendly interface module. Use this function if all you want is a plain-vanilla SVM classifier. However, if you're concerned about details such as the training algorithm, you will need to use some of the classes provided.

Functions   
_dot
_sign
_sparse_dot
_sparse_subtract
_subtract
classify
train
train_transductive
  _dot 
_dot ( x,  y )

_dot(x, y) -> x*y

Return the dot product of x and y, where x and y are lists of numbers.

Exceptions   
ValueError, "vectors must be same length"
  _sign 
_sign ( x )

_sign(x) -> 1 or -1

Return 1/-1 depending on the sign of x.

  _sparse_dot 
_sparse_dot ( x,  y )

  _sparse_subtract 
_sparse_subtract ( x,  y )

  _subtract 
_subtract ( x,  y )

_subtract(x, y) -> x-y

Return x subtract y, where x and y are lists of numbers.

Exceptions   
ValueError, "vectors must be same length"
  classify 
classify ( svm,  x )

classify(svm, x) -> score

Classify x based on an SVM object.

  train 
train (
        training_set,
        results,
        kernel_fn=LinearKernel(),
        C=1.0,
        epsilon=1E-3,
        update_fn=None,
        )

train(training_set, results, kernel_fn=LinearKernel(), C=1.0, epsilon=1E-3, update_fn=None) -> SVM

Train a new support vector machine. training_set is a list containing a list of numbers, each which is a vector in the training set. results is a parallel list that contains either 1 or -1, which describes the class that the training vector belongs to.

kernel_fn, C, and epsilon are optional parameters used to tune the support vector machine.

update_fn is an optional callback function that called at the end of every round of training. It should take 2 parameters: update_fn(num_changed, svm)

  train_transductive 
train_transductive (
        training_set,
        results,
        test_set,
        num_pos,
        kernel_fn=LinearKernel(),
        C=1.0,
        C_test=0.5,
        epsilon=1E-3,
        update_fn=None,
        )

train_transductive(training_set, results, test_set, num_pos, kernel_fn=LinearKernel(), C=1.0, C_test=0.5, epsilon=1E-3, update_fn=None) -> SVM

XXX document this

Classes   
HyperbolicTangentKernel

tanh(x*y*kappa - delta)

KeerthiTrainer

Sequential Minimal Optimization Trainer

LinearKernel

k(x, y) = x*y

PolynomialKernel

k(x, y) = (x*y+1)**p

RadialBasisFunctionKernel

-(x-y)**2

SMOTrainer

Sequential Minimal Optimization Trainer

SVM

Holds information for a non-linear Support Vector Machine.

SparseLinearKernel

k(x, y) = x*y

SparsePolynomialKernel

k(x, y) = (x*y+1)**p

SparseRadialBasisFunctionKernel

-(x-y)**2

TransductiveTrainer

Transductive Support Vector Machine Trainer


Table of Contents

This document was automatically generated on Sat Jul 7 09:50:16 2001 by HappyDoc version r1_5