Package weka.classifiers.meta
Class AbstainLeastMedianSq
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.SingleClassifierEnhancer
-
- weka.classifiers.meta.AbstainLeastMedianSq
-
- All Implemented Interfaces:
Serializable
,Cloneable
,AbstainingClassifier
,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 AbstainLeastMedianSq extends weka.classifiers.SingleClassifierEnhancer implements weka.core.WeightedInstancesHandler, AbstainingClassifier
Finds 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)
- Version:
- $Revision$
- Author:
- Dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.classifiers.Classifier
m_bestClassifier
protected double
m_bestMedian
protected weka.classifiers.Classifier[]
m_cs
protected weka.classifiers.Classifier
m_currentClassifier
protected weka.core.Instances
m_Data
protected boolean
m_debug
protected int
m_errPct
protected int
m_instancepct
protected double
m_max
protected double
m_min
protected int
m_numreg
protected boolean
m_ok
protected Random
m_random
protected long
m_randomseed
protected double[]
m_Residuals
protected double
m_Ridge
protected double
m_scalefactor
protected double
m_SSR
protected weka.core.Instances
m_SubSample
protected double
m_variance
protected double[]
m_weight
-
Constructor Summary
Constructors Constructor Description AbstainLeastMedianSq()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Builds the classifier.boolean
canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.double
classifyInstance(weka.core.Instance inst)
Returns the prediction.String
errorTipText()
protected void
findBestRegression()
Finds the best regression generated from m_samples random samples from the training data.protected void
findResiduals()
Finds residuals (squared) for the current regression.protected void
genRegression(Random r)
Generates a LinearRegression classifier from the current m_SubSample.double
getAbstentionClassification(weka.core.Instance inst)
The prediction that made the classifier abstain.double[]
getAbstentionDistribution(weka.core.Instance inst)
The class distribution that made the classifier abstain.weka.core.Capabilities
getCapabilities()
Returns default capabilities of the base classifier.boolean
getDebug()
Returns whether or not debugging output shouild be printedint
getError()
protected void
getErrorAtPct(int pct)
finds the median residual squared for the current regression.int
getNumRegressions()
gets number of samplesString[]
getOptions()
Gets the current option settings for the OptionHandler.int
getPct()
long
getRandomSeed()
get the seed for the random number generatorString
getRevision()
Returns the revision string.double
getVariance()
String
globalInfo()
Returns a string describing classifier.Enumeration
listOptions()
Returns an enumeration describing the available options.static void
main(String[] argv)
Main method for running this class.String
numRegressionsTipText()
Returns the tip text for this propertyString
pctTipText()
String
randomSeedTipText()
Returns the tip text for this propertyprotected void
selectSubSample(weka.core.Instances data, Random r)
Produces a random sample from m_Data in m_SubSample.void
setDebug(boolean debug)
sets whether or not debugging output shouild be printedvoid
setError(int pct)
void
setNumRegressions(int samplesize)
sets number of samplesvoid
setOptions(String[] options)
Sets the OptionHandler's options using the given list.void
setPct(int pct)
void
setRandomSeed(long randomseed)
Set the seed for the random number generatorvoid
setVariance(double var)
String
toString()
Returns description of classifier.String
varianceTipText()
-
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
-
m_variance
protected double m_variance
-
m_ok
protected boolean m_ok
-
m_min
protected double m_min
-
m_max
protected double m_max
-
m_cs
protected weka.classifiers.Classifier[] m_cs
-
-
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:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in 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:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in 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:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.SingleClassifierEnhancer
- Returns:
- the list of current option settings as an array of strings
-
findResiduals
protected void findResiduals() throws Exception
Finds residuals (squared) for the current regression.- Throws:
Exception
- if an error occurs
-
getErrorAtPct
protected void getErrorAtPct(int pct) throws Exception
finds the median residual squared for the current regression.- Throws:
Exception
- if an error occurs
-
findBestRegression
protected void findBestRegression() throws Exception
Finds 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 Exception
Produces 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:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.SingleClassifierEnhancer
- Returns:
- the capabilities of the base classifier
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Builds the classifier.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Parameters:
data
- the training data- Throws:
Exception
- if something goes wrong
-
classifyInstance
public double classifyInstance(weka.core.Instance inst) throws Exception
Returns the prediction.- Specified by:
classifyInstance
in interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classweka.classifiers.AbstractClassifier
- Throws:
Exception
-
canAbstain
public boolean canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.- Specified by:
canAbstain
in interfaceAbstainingClassifier
- Returns:
- true if abstaining is possible
-
getAbstentionClassification
public double getAbstentionClassification(weka.core.Instance inst) throws Exception
The prediction that made the classifier abstain.- Specified by:
getAbstentionClassification
in interfaceAbstainingClassifier
- Parameters:
inst
- the instance to get the prediction for- Returns:
- the prediction
- Throws:
Exception
- if fails to make prediction
-
getAbstentionDistribution
public double[] getAbstentionDistribution(weka.core.Instance inst) throws Exception
The class distribution that made the classifier abstain.- Specified by:
getAbstentionDistribution
in interfaceAbstainingClassifier
- Parameters:
inst
- the instance to get the prediction for- Returns:
- the class distribution
- Throws:
Exception
- if fails to make prediction
-
toString
public String toString()
Returns description of classifier.
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.AbstractClassifier
- Returns:
- the revision
-
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
-
setVariance
public void setVariance(double var)
-
getVariance
public double getVariance()
-
varianceTipText
public String varianceTipText()
-
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:
setDebug
in classweka.classifiers.AbstractClassifier
- Parameters:
debug
- true if debugging output selected
-
getDebug
public boolean getDebug()
Returns whether or not debugging output shouild be printed- Overrides:
getDebug
in 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
-
-