edu.udo.cs.miningmart.compiler.wrapper
Class SVM_Wrapper

java.lang.Object
  extended byedu.udo.cs.miningmart.compiler.wrapper.SVM_Wrapper
Direct Known Subclasses:
DB_SVM, edu.udo.cs.miningmart.compiler.wrapper.SupportVectorMachine

public abstract class SVM_Wrapper
extends java.lang.Object

Abstract superclass for the wrappers for the Support Vector Machine algorithms mySVM and mySVM/db.

Version:
$Id: SVM_Wrapper.java,v 1.4 2006/04/11 14:10:17 euler Exp $
Author:
Timm Euler

Field Summary
protected  double b
           
static long DEFAULTSAMPLESIZE
           
protected  boolean forClassification
           
protected  java.lang.String inputTableName
           
protected  java.lang.String lossNeg
           
protected  java.lang.String lossPos
           
protected  long myStepId
           
protected  int noSV
           
protected static java.lang.String SAMPLE_TABLE_PREFIX
           
protected  long sampleSize
           
protected  java.lang.String schema
           
protected  java.lang.String targetColSQLDefinition
           
protected  java.lang.String targetPositive
           
protected static java.lang.String TEMP_TABLE_PREFIX
           
protected  edu.udo.cs.miningmart.compiler.wrapper.ColumnInfo[] theColumnInfos
           
protected  boolean useOracle
           
protected  boolean usePostgres
           
protected  double xiAlphaEstimation
           
 
Constructor Summary
SVM_Wrapper(CompilerDatabaseService databaseObj, Print printObj, java.lang.String nameForDatabaseUse, java.lang.String nameOfDatabaseSchema, long stepId)
          Constructor.
 
Method Summary
abstract  void callSVM(Columnset inputColumnset, Column targetColumn, long conceptId, java.lang.String c, java.lang.String kernelType, java.lang.String epsilon, java.util.Vector thePredictingColumns)
          This abstract method defines how to call the external mySVM algorithm for training with the specified parameters.
protected abstract  void checkColSetType(java.lang.String type)
           
protected  java.lang.String checkDouble(java.lang.String test)
           
protected  void checkForConversion(Columnset inputCS, java.util.Vector predictingColumns, Column targetColumn)
           
protected abstract  void checkKernel(java.lang.String kern)
           
protected  java.lang.String createBody(java.lang.String kernelType)
           
protected  void createDecisionFunctionAsSQL_Function(java.lang.String kernelType)
           
protected  java.lang.String createDecisionFunctionTemplate()
           
protected  java.lang.String createDeclaration(java.lang.String kernelType)
           
protected abstract  void extractNumberSV()
          Must be implemented by subclasses.
protected abstract  void extractXiAlpha()
          Must be implemented by subclasses.
protected abstract  java.util.Vector getColNamesInput()
           
protected  java.lang.String getCompleteSelectString()
           
protected  CompilerDatabaseService getDatabaseObj()
          Gets the databaseObj.
protected  java.lang.String getDBMS_Datatype(java.lang.String m4ColumnDatatype, java.lang.String columnName)
           
 java.lang.String getDecisionFunctionName()
          Returns the name of the model function that the SVM installed in the database (business schema).
protected  java.lang.String getDecisionFunctionNameWithArgumentTypes()
          Returns the name of the decision function that the SVM installed in the database (business schema) together with the function's argument types.
 java.lang.String getDecisionFunctionNameWithSchema()
          Returns the name of the decision function that the SVM installed in the database (business schema), prefixed by the name of the schema in which it is installed.
protected  java.lang.String getInputViewName()
           
protected  java.util.Vector getKernelParams(java.lang.String kern)
           
protected  java.lang.String getLogTableName()
           
protected  java.lang.String getModelTableName()
           
protected abstract  java.lang.String getModelTablePlusCondition()
           
 int getNumberOfSupportVectors()
          This method returns the number of support vectors computed by the SVM algorithm during training.
protected  java.lang.String getOutputViewName()
           
protected  java.lang.String getParTableName()
           
protected  java.lang.String getPositiveTargetValue()
           
protected  Print getPrint()
           
protected  java.lang.String getSampleRatio(long maxSample, java.lang.String tableName)
           
 double getXiAlphaEstimation()
          This method returns the XiAlpha-Estimation that was computed by the SVM algorithm during training.
protected  void insertFunctionIntoDB(java.lang.String theFunction)
           
protected  java.lang.String replace(java.lang.String theString, java.lang.String searchFor, java.lang.String replaceBy)
           
protected  void setPositiveTargetValue(java.lang.String posValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULTSAMPLESIZE

public static final long DEFAULTSAMPLESIZE
See Also:
Constant Field Values

SAMPLE_TABLE_PREFIX

protected static final java.lang.String SAMPLE_TABLE_PREFIX
See Also:
Constant Field Values

TEMP_TABLE_PREFIX

protected static final java.lang.String TEMP_TABLE_PREFIX
See Also:
Constant Field Values

sampleSize

protected long sampleSize

useOracle

protected final boolean useOracle

usePostgres

protected final boolean usePostgres

lossPos

protected java.lang.String lossPos

lossNeg

protected java.lang.String lossNeg

theColumnInfos

protected edu.udo.cs.miningmart.compiler.wrapper.ColumnInfo[] theColumnInfos

targetColSQLDefinition

protected java.lang.String targetColSQLDefinition

schema

protected java.lang.String schema

inputTableName

protected java.lang.String inputTableName

myStepId

protected long myStepId

targetPositive

protected java.lang.String targetPositive

forClassification

protected boolean forClassification

b

protected double b

xiAlphaEstimation

protected double xiAlphaEstimation

noSV

protected int noSV
Constructor Detail

SVM_Wrapper

public SVM_Wrapper(CompilerDatabaseService databaseObj,
                   Print printObj,
                   java.lang.String nameForDatabaseUse,
                   java.lang.String nameOfDatabaseSchema,
                   long stepId)
            throws M4CompilerError
Constructor. The connections to the databases are needed because the SVMs need to read metadata as well as data and create an intermediate table in the database.

Parameters:
databaseObj - the DB object to be used for database connections
printObj - the Print object to be used for log messages
nameForDatabaseUse - Prefix for all functions, view and tables that this wrapper creates in the database
nameOfDatabaseSchema - Name of the database schema that holds the business views and tables
stepId - Id of the step where this wrapper is executed
Throws:
M4CompilerError - A simple exception object with an error message.
Method Detail

callSVM

public abstract void callSVM(Columnset inputColumnset,
                             Column targetColumn,
                             long conceptId,
                             java.lang.String c,
                             java.lang.String kernelType,
                             java.lang.String epsilon,
                             java.util.Vector thePredictingColumns)
                      throws M4CompilerError
This abstract method defines how to call the external mySVM algorithm for training with the specified parameters. After successful execution, an SQL-Function exists in the database that implements the learned SVM model.

Parameters:
inputColumnset - The ColumnSet in the database that belongs to the input Concept of the operator that uses this wrapper. The Columns that the SVM learns from belong to this ColumnSet.
targetColumn - the Column in the database that belongs to the target attribute of the operator that uses this wrapper.
conceptId - Unique M4 Id of the input Concept of the operator that uses this wrapper.
c - The parameter C for the support vector machine.
kernelType - One of a few possible kernel types, depending on the actual SVM algorithm used.
epsilon - The parameter epsilon for the support vector machine.
thePredictingColumns - A Vector containing the Columns in the database that the support vector machine will use as learning attributes.
Throws:
M4CompilerError - A simple exception object with an error message.

getXiAlphaEstimation

public double getXiAlphaEstimation()
This method returns the XiAlpha-Estimation that was computed by the SVM algorithm during training. Should not be called before calling callSVM().

Returns:
the XiAlpha value

getNumberOfSupportVectors

public int getNumberOfSupportVectors()
This method returns the number of support vectors computed by the SVM algorithm during training. Should not be called before calling callSVM().

Returns:
the number of support vectors

extractXiAlpha

protected abstract void extractXiAlpha()
                                throws M4CompilerError
Must be implemented by subclasses. Extracts the XiAlpha estimation from the output of the SVM algorithm so that the public method getXiAlphaEstimation() can return the right value.

Throws:
M4CompilerError

extractNumberSV

protected abstract void extractNumberSV()
                                 throws M4CompilerError
Must be implemented by subclasses. Extracts the number of support vectors from the output of the SVM algorithm so that the public method getNumberOfSupportVectors() can return the right value.

Throws:
M4CompilerError

checkForConversion

protected void checkForConversion(Columnset inputCS,
                                  java.util.Vector predictingColumns,
                                  Column targetColumn)
                           throws M4CompilerError
Throws:
M4CompilerError

getCompleteSelectString

protected java.lang.String getCompleteSelectString()

getDBMS_Datatype

protected java.lang.String getDBMS_Datatype(java.lang.String m4ColumnDatatype,
                                            java.lang.String columnName)
                                     throws M4CompilerError
Throws:
M4CompilerError

getSampleRatio

protected java.lang.String getSampleRatio(long maxSample,
                                          java.lang.String tableName)
                                   throws M4CompilerError
Throws:
M4CompilerError

createDecisionFunctionAsSQL_Function

protected void createDecisionFunctionAsSQL_Function(java.lang.String kernelType)
                                             throws M4CompilerError
Throws:
M4CompilerError

createDeclaration

protected java.lang.String createDeclaration(java.lang.String kernelType)
                                      throws M4CompilerError
Throws:
M4CompilerError

createBody

protected java.lang.String createBody(java.lang.String kernelType)
                               throws M4CompilerError
Throws:
M4CompilerError

insertFunctionIntoDB

protected void insertFunctionIntoDB(java.lang.String theFunction)
                             throws M4CompilerError
Throws:
M4CompilerError

replace

protected java.lang.String replace(java.lang.String theString,
                                   java.lang.String searchFor,
                                   java.lang.String replaceBy)

createDecisionFunctionTemplate

protected java.lang.String createDecisionFunctionTemplate()
                                                   throws M4CompilerError
Throws:
M4CompilerError

checkDouble

protected java.lang.String checkDouble(java.lang.String test)
                                throws M4CompilerError
Throws:
M4CompilerError

setPositiveTargetValue

protected void setPositiveTargetValue(java.lang.String posValue)

getPositiveTargetValue

protected java.lang.String getPositiveTargetValue()

checkKernel

protected abstract void checkKernel(java.lang.String kern)
                             throws M4CompilerError
Throws:
M4CompilerError

getModelTablePlusCondition

protected abstract java.lang.String getModelTablePlusCondition()
                                                        throws M4CompilerError
Throws:
M4CompilerError

getColNamesInput

protected abstract java.util.Vector getColNamesInput()

checkColSetType

protected abstract void checkColSetType(java.lang.String type)
                                 throws M4CompilerError
Throws:
M4CompilerError

getDatabaseObj

protected CompilerDatabaseService getDatabaseObj()
Gets the databaseObj.

Returns:
Returns a DB

getParTableName

protected java.lang.String getParTableName()

getLogTableName

protected java.lang.String getLogTableName()

getOutputViewName

protected java.lang.String getOutputViewName()

getInputViewName

protected java.lang.String getInputViewName()

getModelTableName

protected java.lang.String getModelTableName()

getDecisionFunctionName

public java.lang.String getDecisionFunctionName()
Returns the name of the model function that the SVM installed in the database (business schema).

Returns:
name of the SVM function

getDecisionFunctionNameWithArgumentTypes

protected java.lang.String getDecisionFunctionNameWithArgumentTypes()
Returns the name of the decision function that the SVM installed in the database (business schema) together with the function's argument types. This is needed for the entry in the trash table for postgres.

Returns:
name(type1, type2, ..., typeN)

getDecisionFunctionNameWithSchema

public java.lang.String getDecisionFunctionNameWithSchema()
                                                   throws M4CompilerError
Returns the name of the decision function that the SVM installed in the database (business schema), prefixed by the name of the schema in which it is installed.

Returns:
schema.name
Throws:
M4CompilerError

getPrint

protected Print getPrint()

getKernelParams

protected java.util.Vector getKernelParams(java.lang.String kern)


Copyright © 2001-2005