Package weka.classifiers.lazy
Class LWLDatasetBuilder
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- weka.classifiers.lazy.LWLDatasetBuilder
-
- All Implemented Interfaces:
adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.SizeOfHandler,Serializable
public class LWLDatasetBuilder extends adams.core.logging.CustomLoggingLevelObjectClass for building LWL-style weighted datasets.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLWLDatasetBuilder.LWLContainerthe container with the weighted dataset, distances, indices.
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.neighboursearch.NearestNeighbourSearchm_ActualSearchThe actual nearest neighbour search algorithm to use.protected weka.core.Instancesm_ActualTrainThe actual training instances used for classification.protected weka.filters.unsupervised.attribute.AddIDm_AddIDfor adding the ID to trace the instances.protected intm_kNNThe number of neighbours used to select the kernel bandwidth.protected booleanm_NoUpdatewhether to suppress the update of the nearest-neighbor search algorithm when making predictions.protected weka.core.neighboursearch.NearestNeighbourSearchm_SearchThe nearest neighbour search algorithm to use.protected weka.core.Instancesm_TrainThe training instances used for classification.protected booleanm_UseAllKTrue if m_kNN should be set to all instances.protected intm_WeightKernelThe weighting kernel method currently selected.
-
Constructor Summary
Constructors Constructor Description LWLDatasetBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LWLDatasetBuilder.LWLContainerbuild(weka.core.Instance instance)Constructs the weighted dataset.protected StringgetIDAttributeName(weka.core.Instances data)Returns a unique attribute name for the ID attribute.intgetKNN()Gets the number of neighbours used for kernel bandwidth setting.booleangetNoUpdate()Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.weka.core.neighboursearch.NearestNeighbourSearchgetSearchAlgorithm()Returns the current nearestNeighbourSearch algorithm in use.weka.core.InstancesgetTrain()Returns the training data in use.intgetWeightingKernel()Gets the kernel weighting method to use.protected voidreset()Resets the scheme.voidsetKNN(int value)Sets the number of neighbours used for kernel bandwidth setting.voidsetNoUpdate(boolean value)Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.voidsetSearchAlgorithm(weka.core.neighboursearch.NearestNeighbourSearch value)Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).voidsetTrain(weka.core.Instances value)Sets the training data to use.voidsetWeightingKernel(int value)Sets the kernel weighting method to use.StringtoString()Returns a short string description of the setup.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Train
protected weka.core.Instances m_Train
The training instances used for classification.
-
m_ActualTrain
protected transient weka.core.Instances m_ActualTrain
The actual training instances used for classification.
-
m_kNN
protected int m_kNN
The number of neighbours used to select the kernel bandwidth.
-
m_WeightKernel
protected int m_WeightKernel
The weighting kernel method currently selected.
-
m_UseAllK
protected boolean m_UseAllK
True if m_kNN should be set to all instances.
-
m_Search
protected weka.core.neighboursearch.NearestNeighbourSearch m_Search
The nearest neighbour search algorithm to use.
-
m_ActualSearch
protected transient weka.core.neighboursearch.NearestNeighbourSearch m_ActualSearch
The actual nearest neighbour search algorithm to use.
-
m_NoUpdate
protected boolean m_NoUpdate
whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
-
m_AddID
protected transient weka.filters.unsupervised.attribute.AddID m_AddID
for adding the ID to trace the instances.
-
-
Method Detail
-
reset
protected void reset()
Resets the scheme.
-
setKNN
public void setKNN(int value)
Sets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.- Parameters:
value- the number of neighbours included inside the kernel bandwidth, or 0 to specify using all neighbors.
-
getKNN
public int getKNN()
Gets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.- Returns:
- the number of neighbours included inside the kernel bandwidth, or 0 for all neighbours
-
setWeightingKernel
public void setWeightingKernel(int value)
Sets the kernel weighting method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT, other values are ignored.- Parameters:
value- the new kernel method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
-
getWeightingKernel
public int getWeightingKernel()
Gets the kernel weighting method to use.- Returns:
- the new kernel method to use. Will be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
-
setSearchAlgorithm
public void setSearchAlgorithm(weka.core.neighboursearch.NearestNeighbourSearch value)
Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).- Parameters:
value- - The NearestNeighbourSearch class.
-
getSearchAlgorithm
public weka.core.neighboursearch.NearestNeighbourSearch getSearchAlgorithm()
Returns the current nearestNeighbourSearch algorithm in use.- Returns:
- the NearestNeighbourSearch algorithm currently in use.
-
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
-
setTrain
public void setTrain(weka.core.Instances value)
Sets the training data to use.- Parameters:
value- the data
-
getTrain
public weka.core.Instances getTrain()
Returns the training data in use.- Returns:
- the data
-
getIDAttributeName
protected String getIDAttributeName(weka.core.Instances data)
Returns a unique attribute name for the ID attribute.- Parameters:
data- the data to insert the attribute- Returns:
- the attribute name
-
build
public LWLDatasetBuilder.LWLContainer build(weka.core.Instance instance) throws Exception
Constructs the weighted dataset.- Parameters:
instance- the instance to make prediction for- Returns:
- the container with the generated for the classifier to train with
- Throws:
Exception- if build fails
-
-