Package weka.classifiers.lazy
Class LWLSynchroSplit
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.SingleClassifierEnhancer
-
- weka.classifiers.lazy.LWL
-
- weka.classifiers.lazy.LWLSynchroSplit
-
- All Implemented Interfaces:
Stoppable
,StoppableWithFeedback
,Serializable
,Cloneable
,weka.classifiers.Classifier
,ThreadSafeClassifier
,weka.classifiers.UpdateableClassifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
,weka.core.TechnicalInformationHandler
,weka.core.WeightedInstancesHandler
public class LWLSynchroSplit extends weka.classifiers.lazy.LWL implements ThreadSafeClassifier, StoppableWithFeedback
Locally weighted learning. Uses an instance-based algorithm to assign instance weights which are then used by a specified WeightedInstancesHandler.
Can do classification (e.g. using naive Bayes) or regression (e.g. using linear regression).
For more info, see
Eibe Frank, Mark Hall, Bernhard Pfahringer: Locally Weighted Naive Bayes. In: 19th Conference in Uncertainty in Artificial Intelligence, 249-256, 2003.
C. Atkeson, A. Moore, S. Schaal (1996). Locally weighted learning. AI Review..
This version of LWL applies two filters to the incoming training data:
- search filter: generates the data use for the neighborhood search algorithm
- train filter: generates the data to use for building the base classifierThe dataset indices determined by the search algorithm are used to compile the subset from the train filter dataset which is used for building the base classifier.
BibTeX:@inproceedings{Frank2003, author = {Eibe Frank and Mark Hall and Bernhard Pfahringer}, booktitle = {19th Conference in Uncertainty in Artificial Intelligence}, pages = {249-256}, publisher = {Morgan Kaufmann}, title = {Locally Weighted Naive Bayes}, year = {2003} } @article{Atkeson1996, author = {C. Atkeson and A. Moore and S. Schaal}, journal = {AI Review}, title = {Locally weighted learning}, year = {1996} }
Valid options are:-filter-search <filter specification> The filter to use for generating the data for the search. (default: weka.filters.AllFilter)
-filter-train <filter specification> The filter to use for generating the data for training the base classifier. (default: weka.filters.AllFilter)
-no-update Suppresses the update of the nearest neighbor search (nns) algorithm with the data that is to be classified. (default: nns gets updated).
-A The nearest neighbour search algorithm to use (default: weka.core.neighboursearch.LinearNNSearch).
-K <number of neighbours> Set the number of neighbours used to set the kernel bandwidth. (default all)
-U <number of weighting method> Set the weighting kernel shape to use. 0=Linear, 1=Epanechnikov, 2=Tricube, 3=Inverse, 4=Gaussian. (default 0 = Linear)
-W <classifier name> Full name of base classifier. (default: weka.classifiers.functions.GPD)
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Options specific to classifier weka.classifiers.functions.GPD:
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
-L <double> Level of Gaussian Noise. (default: 0.01)
-G <double> Gamma for the RBF kernel. (default: 0.01)
-N Whether to 0=normalize/1=standardize/2=neither. (default: 0=normalize)
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Note: thebuild(Instance)
needs manual syncing with the original WEKA classifier (distributionForInstance(Instance)
method).- Author:
- Len Trigg ([email protected]), Eibe Frank ([email protected]), Ashraf M. Kibriya (amk14[at-the-rate]cs[dot]waikato[dot]ac[dot]nz), Dale (dale at waikato dot ac dot nz), FracPete (fracpete at waikato dot ac dot nz)
- See Also:
LWL.distributionForInstance(Instance)
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.Instances
m_DataSearch
the data to use for the search.protected weka.core.Instances
m_DataTrain
the data to use for building the base classifier.protected weka.filters.Filter
m_FilterSearch
the filter to apply to the search data.protected weka.filters.Filter
m_FilterTrain
the filter to apply to the neighborhood data before training the base classifier.protected boolean
m_NoUpdate
whether to suppress the update of the nearest-neighbor search algorithm when making predictions.protected boolean
m_Stopped
whether the classifier was stopped.
-
Constructor Summary
Constructors Constructor Description LWLSynchroSplit()
Initializes the classifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
build(weka.core.Instance instance)
Builds the classifier.void
buildClassifier(weka.core.Instances instances)
Generates a classifier.protected String
defaultClassifierString()
Default classifier classname.double[]
distributionForInstance(weka.core.Instance instance)
Calculates the class membership probabilities for the given test instance.String
filterSearchTipText()
Returns the tip text for this property.String
filterTrainTipText()
Returns the tip text for this property.weka.filters.Filter
getFilterSearch()
Returns the filter to generate the data for the search.weka.filters.Filter
getFilterTrain()
Returns the filter to use for to generate the training data for the base classifier.boolean
getNoUpdate()
Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.String[]
getOptions()
Gets the current settings of the classifier.String
getRevision()
Returns the revision string.String
globalInfo()
Returns a string describing classifier.boolean
isStopped()
Whether the execution has been stopped.Enumeration
listOptions()
Returns an enumeration describing the available options.static void
main(String[] argv)
Main method for testing this class.String
noUpdateTipText()
Returns the tip text for this property.void
setFilterSearch(weka.filters.Filter value)
Sets filter to generate the data for the search.void
setFilterTrain(weka.filters.Filter value)
Sets filter to use for to generate the training data for the base classifier.void
setNearestNeighbourSearchAlgorithm(weka.core.neighboursearch.NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).void
setNoUpdate(boolean value)
Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.void
setOptions(String[] options)
Parses a given list of options.void
stopExecution()
Stops the execution.String
toString()
Returns a description of this classifier.-
Methods inherited from class weka.classifiers.lazy.LWL
enumerateMeasures, getCapabilities, getKNN, getMeasure, getNearestNeighbourSearchAlgorithm, getTechnicalInformation, getWeightingKernel, KNNTipText, nearestNeighbourSearchAlgorithmTipText, setKNN, setWeightingKernel, updateClassifier, weightingKernelTipText
-
Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, defaultClassifierOptions, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifier
-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
m_NoUpdate
protected boolean m_NoUpdate
whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
-
m_Stopped
protected boolean m_Stopped
whether the classifier was stopped.
-
m_FilterSearch
protected weka.filters.Filter m_FilterSearch
the filter to apply to the search data.
-
m_FilterTrain
protected weka.filters.Filter m_FilterTrain
the filter to apply to the neighborhood data before training the base classifier.
-
m_DataSearch
protected weka.core.Instances m_DataSearch
the data to use for the search.
-
m_DataTrain
protected weka.core.Instances m_DataTrain
the data to use for building the base classifier.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier.- Overrides:
globalInfo
in classweka.classifiers.lazy.LWL
- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
defaultClassifierString
protected String defaultClassifierString()
Default classifier classname.- Overrides:
defaultClassifierString
in classweka.classifiers.lazy.LWL
- Returns:
- the classname
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.lazy.LWL
- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
Parses a given list of options.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.lazy.LWL
- 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 settings of the classifier.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.lazy.LWL
- Returns:
- an array of strings suitable for passing to setOptions
-
setNearestNeighbourSearchAlgorithm
public void setNearestNeighbourSearchAlgorithm(weka.core.neighboursearch.NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).- Overrides:
setNearestNeighbourSearchAlgorithm
in classweka.classifiers.lazy.LWL
- Parameters:
nearestNeighbourSearchAlgorithm
- - The NearestNeighbourSearch class.
-
setNoUpdate
public void setNoUpdate(boolean value)
Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.- Parameters:
value
- if true then no update happens.
-
getNoUpdate
public boolean getNoUpdate()
Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.- Returns:
- true if the update is suppressed
-
noUpdateTipText
public String noUpdateTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFilterSearch
public void setFilterSearch(weka.filters.Filter value)
Sets filter to generate the data for the search.- Parameters:
value
- the filter
-
getFilterSearch
public weka.filters.Filter getFilterSearch()
Returns the filter to generate the data for the search.- Returns:
- the filter
-
filterSearchTipText
public String filterSearchTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFilterTrain
public void setFilterTrain(weka.filters.Filter value)
Sets filter to use for to generate the training data for the base classifier.- Parameters:
value
- the filter
-
getFilterTrain
public weka.filters.Filter getFilterTrain()
Returns the filter to use for to generate the training data for the base classifier.- Returns:
- the filter
-
filterTrainTipText
public String filterTrainTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
buildClassifier
public void buildClassifier(weka.core.Instances instances) throws Exception
Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Overrides:
buildClassifier
in classweka.classifiers.lazy.LWL
- Parameters:
instances
- set of instances serving as training data- Throws:
Exception
- if the classifier has not been generated successfully
-
build
protected void build(weka.core.Instance instance) throws Exception
Builds the classifier.
Note: needs manual syncing with the distributionForInstance method of the original WEKA classifier.- Parameters:
instance
- the instance to make prediction for- Throws:
Exception
- if build fails- See Also:
LWL.distributionForInstance(Instance)
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Calculates the class membership probabilities for the given test instance.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.lazy.LWL
- Parameters:
instance
- the instance to be classified- Returns:
- predicted class probability distribution
- Throws:
Exception
- if distribution can't be computed successfully
-
toString
public String toString()
Returns a description of this classifier.- Overrides:
toString
in classweka.classifiers.lazy.LWL
- Returns:
- a description of this classifier as a string.
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceStoppableWithFeedback
- Returns:
- true if stopped
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.lazy.LWL
- Returns:
- the revision
-
main
public static void main(String[] argv)
Main method for testing this class.- Parameters:
argv
- the options
-
-