org.knime.base.node.mine.svm
Class Svm

java.lang.Object
  extended by org.knime.base.node.mine.svm.Svm

public class Svm
extends Object

This class represents a (binary) support vector machine. It works by remembering the support vectors and the corresponding alpha values.

Author:
Stefan, University of Konstanz, cebron, University of Konstanz

Constructor Summary
Svm(DoubleVector[] supportVectors, double[] alpha, String positive, double b, Kernel kernel)
          Constructor.
Svm(ModelContentRO predParams, String id)
          Loads a binary SVM from a ModelContent object.
 
Method Summary
 double distance(DoubleVector vector)
          Computes the distance from the hyperplane in the kernel induced hyperspace.
 double[] getAlphas()
           
 double getMargin()
          The margin of a SVM is the minimum distance from all support vectors to the decision hyperplane.
 String getPositive()
           
 DoubleVector[] getSupportVectors()
           
 double getThreshold()
           
 double predict(DoubleVector vector)
          Computes the predicted value of a vector by using the current SVM.
 void saveToPredictorParams(ModelContentWO predParams, String id)
          Save the Support Vector Machine for later use.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Svm

public Svm(DoubleVector[] supportVectors,
           double[] alpha,
           String positive,
           double b,
           Kernel kernel)
Constructor.

Parameters:
supportVectors - the support vectors that define the SVM
alpha - the corresponding Lagrange coefficients
positive - the class for which SVM should yield 1
b - the threshold
kernel - the kernel to use

Svm

public Svm(ModelContentRO predParams,
           String id)
    throws InvalidSettingsException
Loads a binary SVM from a ModelContent object.

Parameters:
predParams - the object to read the SVM configuration from.
id - the unique identifier
Throws:
InvalidSettingsException - if the required keys are not present
Method Detail

distance

public double distance(DoubleVector vector)
Computes the distance from the hyperplane in the kernel induced hyperspace.

Parameters:
vector - the vector to predict
Returns:
the distance from the hyperplane

predict

public double predict(DoubleVector vector)
Computes the predicted value of a vector by using the current SVM.

Parameters:
vector - the vector for which to predict the class
Returns:
the predicted value (-1 or 1)

getMargin

public double getMargin()
The margin of a SVM is the minimum distance from all support vectors to the decision hyperplane.

Returns:
margin value of SVM.

saveToPredictorParams

public void saveToPredictorParams(ModelContentWO predParams,
                                  String id)
Save the Support Vector Machine for later use.

Parameters:
predParams - where the SVM will be saved.
id - unique identifier for this SVM.

toString

public String toString()

Overrides:
toString in class Object

getPositive

public String getPositive()
Returns:
the "positive" class value.

getSupportVectors

public DoubleVector[] getSupportVectors()
Returns:
the supportVectors

getAlphas

public double[] getAlphas()
Returns:
the alpha coefficients of the SVM.

getThreshold

public double getThreshold()
Returns:
the threshold value b of the SVM.s


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.