Package weka.classifiers.meta
Class LeastMedianSq
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.SingleClassifierEnhancer
-
- weka.classifiers.meta.LeastMedianSq
-
- All Implemented Interfaces:
Serializable,Cloneable,weka.classifiers.Classifier,weka.core.BatchPredictor,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler,weka.core.WeightedInstancesHandler
public class LeastMedianSq extends weka.classifiers.SingleClassifierEnhancer implements weka.core.WeightedInstancesHandlerFinds the base classifier with the best least median squared error.
Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the console
-S <sint> Number of regressions (default: 10)
-P <int> Percent sample size (default: 60)
-E <int> Percent Error at (default: 50)
-G <seed> Set the seed used to generate samples (default: 0)
- Author:
- Dale?
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.classifiers.Classifierm_bestClassifierprotected doublem_bestMedianprotected weka.classifiers.Classifierm_currentClassifierprotected weka.core.Instancesm_Dataprotected booleanm_debugprotected intm_errPctprotected intm_instancepctprotected intm_numregprotected Randomm_randomprotected longm_randomseedprotected double[]m_Residualsprotected doublem_Ridgeprotected doublem_scalefactorprotected doublem_SSRprotected weka.core.Instancesm_SubSampleprotected double[]m_weight
-
Constructor Summary
Constructors Constructor Description LeastMedianSq()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(weka.core.Instances data)Builds the classifier.doubleclassifyInstance(weka.core.Instance inst)Returns the prediction.StringerrorTipText()protected voidfindBestRegression()Finds the best regression generated from m_samples random samples from the training data.protected voidfindResiduals()Finds residuals (squared) for the current regression.protected voidgenRegression(Random r)Generates a LinearRegression classifier from the current m_SubSample.weka.core.CapabilitiesgetCapabilities()Returns default capabilities of the base classifier.booleangetDebug()Returns whether or not debugging output shouild be printedintgetError()protected voidgetErrorAtPct(int pct)finds the median residual squared for the current regression.intgetNumRegressions()gets number of samplesString[]getOptions()Gets the current option settings for the OptionHandler.intgetPct()longgetRandomSeed()get the seed for the random number generatorStringgetRevision()StringglobalInfo()Returns a string describing classifier.EnumerationlistOptions()Returns an enumeration describing the available options.static voidmain(String[] argv)Main method for running this class.StringnumRegressionsTipText()Returns the tip text for this propertyStringpctTipText()StringrandomSeedTipText()Returns the tip text for this propertyprotected voidselectSubSample(weka.core.Instances data, Random r)Produces a random sample from m_Data in m_SubSample.voidsetDebug(boolean debug)sets whether or not debugging output shouild be printedvoidsetError(int pct)voidsetNumRegressions(int samplesize)sets number of samplesvoidsetOptions(String[] options)Sets the OptionHandler's options using the given list.voidsetPct(int pct)voidsetRandomSeed(long randomseed)Set the seed for the random number generatorStringtoString()Returns description of classifier.-
Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, defaultClassifierOptions, defaultClassifierString, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifier
-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
m_Residuals
protected double[] m_Residuals
-
m_weight
protected double[] m_weight
-
m_SSR
protected double m_SSR
-
m_scalefactor
protected double m_scalefactor
-
m_bestMedian
protected double m_bestMedian
-
m_Ridge
protected double m_Ridge
-
m_currentClassifier
protected weka.classifiers.Classifier m_currentClassifier
-
m_bestClassifier
protected weka.classifiers.Classifier m_bestClassifier
-
m_Data
protected weka.core.Instances m_Data
-
m_SubSample
protected weka.core.Instances m_SubSample
-
m_numreg
protected int m_numreg
-
m_instancepct
protected int m_instancepct
-
m_errPct
protected int m_errPct
-
m_debug
protected boolean m_debug
-
m_random
protected Random m_random
-
m_randomseed
protected long m_randomseed
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier.- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.classifiers.SingleClassifierEnhancer- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws 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). Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the console
-S <sint> Number of regressions (default: 10)
-P <int> Percent sample size (default: 60)
-E <int> Percent Error at (default: 50)
-G <seed> Set the seed used to generate samples (default: 0)
- Specified by:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classweka.classifiers.SingleClassifierEnhancer- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
public String[] getOptions()
Gets the current option settings for the OptionHandler.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.classifiers.SingleClassifierEnhancer- Returns:
- the list of current option settings as an array of strings
-
findResiduals
protected void findResiduals() throws ExceptionFinds residuals (squared) for the current regression.- Throws:
Exception- if an error occurs
-
getErrorAtPct
protected void getErrorAtPct(int pct) throws Exceptionfinds the median residual squared for the current regression.- Throws:
Exception- if an error occurs
-
findBestRegression
protected void findBestRegression() throws ExceptionFinds the best regression generated from m_samples random samples from the training data.- Throws:
Exception- if an error occurs
-
selectSubSample
protected void selectSubSample(weka.core.Instances data, Random r) throws ExceptionProduces a random sample from m_Data in m_SubSample.- Parameters:
data- data from which to take sample- Throws:
Exception- if an error occurs
-
genRegression
protected void genRegression(Random r) throws Exception
Generates a LinearRegression classifier from the current m_SubSample.- Throws:
Exception- if an error occurs
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns default capabilities of the base classifier.- Specified by:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Specified by:
getCapabilitiesin interfaceweka.classifiers.Classifier- Overrides:
getCapabilitiesin classweka.classifiers.SingleClassifierEnhancer- Returns:
- the capabilities of the base classifier
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws ExceptionBuilds the classifier.- Specified by:
buildClassifierin interfaceweka.classifiers.Classifier- Parameters:
data- the training data- Throws:
Exception- if something goes wrong
-
classifyInstance
public double classifyInstance(weka.core.Instance inst) throws ExceptionReturns the prediction.- Specified by:
classifyInstancein interfaceweka.classifiers.Classifier- Overrides:
classifyInstancein classweka.classifiers.AbstractClassifier- Throws:
Exception
-
toString
public String toString()
Returns description of classifier.
-
getRevision
public String getRevision()
- Specified by:
getRevisionin interfaceweka.core.RevisionHandler- Overrides:
getRevisionin classweka.classifiers.AbstractClassifier
-
numRegressionsTipText
public String numRegressionsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setPct
public void setPct(int pct)
-
getPct
public int getPct()
-
pctTipText
public String pctTipText()
-
setError
public void setError(int pct)
-
getError
public int getError()
-
errorTipText
public String errorTipText()
-
setNumRegressions
public void setNumRegressions(int samplesize)
sets number of samples- Parameters:
samplesize- value
-
getNumRegressions
public int getNumRegressions()
gets number of samples- Returns:
- value
-
randomSeedTipText
public String randomSeedTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
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- Overrides:
setDebugin classweka.classifiers.AbstractClassifier- Parameters:
debug- true if debugging output selected
-
getDebug
public boolean getDebug()
Returns whether or not debugging output shouild be printed- Overrides:
getDebugin classweka.classifiers.AbstractClassifier- Returns:
- true if debuging output selected
-
main
public static void main(String[] argv)
Main method for running this class.- Parameters:
argv- the options
-
-