All Packages Class Hierarchy This Package Previous Next Index WEKA's home
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.DistributionClassifier
|
+----weka.classifiers.lazy.IBk
Aha, D., and D. Kibler (1991) "Instance-based learning algorithms", Machine Learning, vol.6, pp. 37-66.
Valid options are:
-K num
Set the number of nearest neighbours to use in prediction
(default 1)
-W num
Set a fixed window size for incremental train/testing. As
new training instances are added, oldest instances are removed
to maintain the number of training instances at this size.
(default no window)
-D
Neighbours will be weighted by the inverse of their distance
when voting. (default equal weighting)
-F
Neighbours will be weighted by their similarity when voting.
(default equal weighting)
-X
Selects the number of neighbours to use by hold-one-out cross
validation, with an upper limit given by the -K option.
-S
When k is selected by cross-validation for numeric class attributes,
minimize mean-squared error. (default mean absolute error)
-N
Turns off normalization.
-E
-K num
-W num
-D
-F
-X
-S
KDTrees class and its options (can only use the same distance function
as XMeans).
buildClassifier(Instances)
distributionForInstance(Instance)
getAttributeMax(int)
getAttributeMin(int)
getCrossValidate()
getDebug()
getDistanceWeighting()
getKDTree()
getKNN()
getMeanSquared()
getNoNormalization()
getNumTraining()
getOptions()
getWindowSize()
listOptions()
main(String[])
setCrossValidate(boolean)
setDebug(boolean)
setDistanceWeighting(SelectedTag)
setKDTree(KDTree)
setKNN(int)
setMeanSquared(boolean)
setNoNormalization(boolean)
setOptions(String[])
setWindowSize(int)
toString()
updateClassifier(Instance)
WEIGHT_NONE
public static final int WEIGHT_NONE
WEIGHT_INVERSE
public static final int WEIGHT_INVERSE
WEIGHT_SIMILARITY
public static final int WEIGHT_SIMILARITY
TAGS_WEIGHTING
public static final Tag[] TAGS_WEIGHTING
IBk
public IBk(int k)
IBk classifier. Simple instance-based learner that uses the class
of the nearest k training instances for the class of the test
instances.
k - the number of nearest neighbours to use for prediction
IBk
public IBk()
IB1 classifer. Instance-based learner. Predicts the class of the
single nearest training instance for each test instance.
getDebug
public boolean getDebug()
Get the value of Debug.
setDebug
public void setDebug(boolean newDebug)
Set the value of Debug.
newDebug - Value to assign to Debug.
setKDTree
public void setKDTree(KDTree k)
Sets the KDTree class.
k - a KDTree object with all options set
getKDTree
public KDTree getKDTree()
Gets the KDTree class.
setKNN
public void setKNN(int k)
Set the number of neighbours the learner is to use.
k - the number of neighbours.
getKNN
public int getKNN()
Gets the number of neighbours the learner will use.
getWindowSize
public int getWindowSize()
Gets the maximum number of instances allowed in the training
pool. The addition of new instances above this value will result
in old instances being removed. A value of 0 signifies no limit
to the number of training instances.
setWindowSize
public void setWindowSize(int newWindowSize)
Sets the maximum number of instances allowed in the training
pool. The addition of new instances above this value will result
in old instances being removed. A value of 0 signifies no limit
to the number of training instances.
newWindowSize - Value to assign to WindowSize.
getDistanceWeighting
public SelectedTag getDistanceWeighting()
Gets the distance weighting method used. Will be one of
WEIGHT_NONE, WEIGHT_INVERSE, or WEIGHT_SIMILARITY
setDistanceWeighting
public void setDistanceWeighting(SelectedTag newMethod)
Sets the distance weighting method used. Values other than
WEIGHT_NONE, WEIGHT_INVERSE, or WEIGHT_SIMILARITY will be ignored.
newDistanceWeighting - the distance weighting method to use
getMeanSquared
public boolean getMeanSquared()
Gets whether the mean squared error is used rather than mean
absolute error when doing cross-validation.
setMeanSquared
public void setMeanSquared(boolean newMeanSquared)
Sets whether the mean squared error is used rather than mean
absolute error when doing cross-validation.
newMeanSquared - true if so.
getCrossValidate
public boolean getCrossValidate()
Gets whether hold-one-out cross-validation will be used
to select the best k value
setCrossValidate
public void setCrossValidate(boolean newCrossValidate)
Sets whether hold-one-out cross-validation will be used
to select the best k value
newCrossValidate - true if cross-validation should be used.
getNumTraining
public int getNumTraining()
Get the number of training instances the classifier is currently using
getAttributeMin
public double getAttributeMin(int index) throws java.lang.Exception
Get an attributes minimum observed value
getAttributeMax
public double getAttributeMax(int index) throws java.lang.Exception
Get an attributes maximum observed value
getNoNormalization
public boolean getNoNormalization()
Gets whether normalization is turned off.
setNoNormalization
public void setNoNormalization(boolean v)
Set whether normalization is turned off.
v - Value to assign to DontNormalize.
buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
Generates the classifier.
instances - set of instances serving as training data
updateClassifier
public void updateClassifier(Instance instance) throws java.lang.Exception
Adds the supplied instance to the training set
instance - the instance to add
distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
Calculates the class membership probabilities for the given test instance.
instance - the instance to be classified
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.
setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
Parses a given list of options. Valid options are:
Set the number of nearest neighbours to use in prediction
(default 1)
Set a fixed window size for incremental train/testing. As
new training instances are added, oldest instances are removed
to maintain the number of training instances at this size.
(default no window)
Neighbours will be weighted by the inverse of their distance
when voting. (default equal weighting)
Neighbours will be weighted by their similarity when voting.
(default equal weighting)
Select the number of neighbours to use by hold-one-out cross
validation, with an upper limit given by the -K option.
When k is selected by cross-validation for numeric class attributes,
minimize mean-squared error. (default mean absolute error)
options - the list of options as an array of strings
getOptions
public java.lang.String[] getOptions()
Gets the current settings of IBk.
toString
public java.lang.String toString()
Returns a description of this classifier.
main
public static void main(java.lang.String argv[])
Main method for testing this class.
argv - should contain command line options (see setOptions)
All Packages Class Hierarchy This Package Previous Next Index WEKA's home