weka.classifiers.functions
Class LeastMedSq

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.functions.LeastMedSq
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class LeastMedSq
extends Classifier
implements OptionHandler

Implements a least median sqaured linear regression utilising the existing weka LinearRegression class to form predictions. The basis of the algorithm is Robust regression and outlier detection Peter J. Rousseeuw, Annick M. Leroy. c1987

See Also:
Serialized Form

Constructor Summary
LeastMedSq()
           
 
Method Summary
 void buildClassifier(Instances data)
          Build lms regression
 double classifyInstance(Instance instance)
          Classify a given instance using the best generated LinearRegression Classifier.
static int combinations(int n, int r)
          Produces the combination nCr
 boolean getDebug()
          Returns whether or not debugging output shouild be printed
 boolean getIsRandom()
          Returns whether or not samples are selected randomly
 java.lang.String[] getOptions()
          Gets the current option settings for the OptionHandler.
 long getRandomSeed()
          get the seed for the random number generator
 int getSampleSize()
          gets number of samples
 java.util.Enumeration listOptions()
          Returns an enumeration of all the available options..
static void main(java.lang.String[] argv)
          generate a Linear regression predictor for testing
 void setDebug(boolean debug)
          sets whether or not debugging output shouild be printed
 void setIsRandom(boolean israndom)
          Sets whether sample selection is random
 void setOptions(java.lang.String[] options)
          Sets the OptionHandler's options using the given list.
 void setRandomSeed(long randomseed)
          Set the seed for the random number generator
 void setSampleSize(int samplesize)
          sets number of samples
 java.lang.String toString()
          Returns a string representing the best LinearRegression classifier found.
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeastMedSq

public LeastMedSq()
Method Detail

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Build lms regression

Specified by:
buildClassifier in class Classifier
Parameters:
data - training data
Throws:
java.lang.Exception - if an error occurs

classifyInstance

public double classifyInstance(Instance instance)
                        throws java.lang.Exception
Classify a given instance using the best generated LinearRegression Classifier.

Specified by:
classifyInstance in class Classifier
Parameters:
instance - instance to be classified
Returns:
class value
Throws:
java.lang.Exception - if an error occurs

toString

public java.lang.String toString()
Returns a string representing the best LinearRegression classifier found.

Returns:
String representing the regression

setSampleSize

public void setSampleSize(int samplesize)
sets number of samples

Parameters:
samplesize - value

getSampleSize

public int getSampleSize()
gets number of samples

Returns:
value

setIsRandom

public void setIsRandom(boolean israndom)
Sets whether sample selection is random

Parameters:
israndom - true if sample selection is random

getIsRandom

public boolean getIsRandom()
Returns whether or not samples are selected randomly

Returns:
true if sample selection is random

setRandomSeed

public void setRandomSeed(long randomseed)
Set the seed for the random number generator

Parameters:
randomseed - the seed

getRandomSeed

public long getRandomSeed()
get the seed for the random number generator

Returns:
the seed value

setDebug

public void setDebug(boolean debug)
sets whether or not debugging output shouild be printed

Parameters:
debug - true if debugging output selected

getDebug

public boolean getDebug()
Returns whether or not debugging output shouild be printed

Returns:
true if debuging output selected

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration of all the available options..

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all available options.

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Sets the OptionHandler's options using the given list. All options will be set (or reset) during this call (i.e. incremental setting of options is not possible).

Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current option settings for the OptionHandler.

Specified by:
getOptions in interface OptionHandler
Returns:
the list of current option settings as an array of strings

combinations

public static int combinations(int n,
                               int r)
                        throws java.lang.Exception
Produces the combination nCr

Parameters:
n -
Returns:
the combination
Throws:
java.lang.Exception - if r is greater than n

main

public static void main(java.lang.String[] argv)
generate a Linear regression predictor for testing

Parameters:
argv - options