mulan.classifier.lazy
Class MultiLabelKNN

java.lang.Object
  extended by mulan.classifier.MultiLabelLearnerBase
      extended by mulan.classifier.lazy.MultiLabelKNN
All Implemented Interfaces:
Serializable, MultiLabelLearner, TechnicalInformationHandler
Direct Known Subclasses:
BRkNN, IBLR_ML, MLkNN

public abstract class MultiLabelKNN
extends MultiLabelLearnerBase

Superclass of all KNN based multi-label algorithms

Author:
Eleftherios Spyromitros-Xioufis, Grigorios Tsoumakas
See Also:
Serialized Form

Field Summary
protected  DistanceFunction dfunc
          Implementing Euclidean distance (or similarity) function.
protected  int distanceWeighting
          Whether the neighbors should be distance-weighted.
protected  LinearNNSearch lnn
          Class implementing the brute force search algorithm for nearest neighbor search.
protected  int numOfNeighbors
          Number of neighbors used in the k-nearest neighbor algorithm
protected  Instances train
          The training instances
static int WEIGHT_INVERSE
          weight by 1/distance.
static int WEIGHT_NONE
          no weighting.
static int WEIGHT_SIMILARITY
          weight by 1-distance.
 
Fields inherited from class mulan.classifier.MultiLabelLearnerBase
featureIndices, labelIndices, numLabels
 
Constructor Summary
MultiLabelKNN()
          The default constructor
MultiLabelKNN(int numOfNeighbors)
          Initializes the number of neighbors
 
Method Summary
protected  void buildInternal(MultiLabelInstances trainSet)
          Learner specific implementation of building the model from MultiLabelInstances training data set.
 boolean isUpdatable()
          Returns value indicating if learner is updatable, so if learner is able to perform on-line learning.
 void setDfunc(DistanceFunction dfunc)
          Sets a distance function
 void setDistanceWeighting(int distanceWeighting)
           
 
Methods inherited from class mulan.classifier.MultiLabelLearnerBase
build, debug, getDebug, getTechnicalInformation, globalInfo, isModelInitialized, makeCopy, makePrediction, makePredictionInternal, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

distanceWeighting

protected int distanceWeighting
Whether the neighbors should be distance-weighted.


WEIGHT_NONE

public static final int WEIGHT_NONE
no weighting.

See Also:
Constant Field Values

WEIGHT_INVERSE

public static final int WEIGHT_INVERSE
weight by 1/distance.

See Also:
Constant Field Values

WEIGHT_SIMILARITY

public static final int WEIGHT_SIMILARITY
weight by 1-distance.

See Also:
Constant Field Values

numOfNeighbors

protected int numOfNeighbors
Number of neighbors used in the k-nearest neighbor algorithm


lnn

protected LinearNNSearch lnn
Class implementing the brute force search algorithm for nearest neighbor search. Default value is true.


dfunc

protected DistanceFunction dfunc
Implementing Euclidean distance (or similarity) function.


train

protected Instances train
The training instances

Constructor Detail

MultiLabelKNN

public MultiLabelKNN()
The default constructor


MultiLabelKNN

public MultiLabelKNN(int numOfNeighbors)
Initializes the number of neighbors

Parameters:
numOfNeighbors - the number of neighbors
Method Detail

setDfunc

public void setDfunc(DistanceFunction dfunc)
Sets a distance function

Parameters:
dfunc - the distance function

buildInternal

protected void buildInternal(MultiLabelInstances trainSet)
                      throws Exception
Description copied from class: MultiLabelLearnerBase
Learner specific implementation of building the model from MultiLabelInstances training data set. This method is called from MultiLabelLearnerBase.build(MultiLabelInstances) method, where behavior common across all learners is applied.

Specified by:
buildInternal in class MultiLabelLearnerBase
Parameters:
trainSet - the training data set
Throws:
Exception - if learner model was not created successfully

isUpdatable

public boolean isUpdatable()
Description copied from interface: MultiLabelLearner
Returns value indicating if learner is updatable, so if learner is able to perform on-line learning. The fact if learner is updatable or not influences the behavior of MultiLabelLearner.build(MultiLabelInstances) method.

When false is returned, each call of the MultiLabelLearner.build(MultiLabelInstances) will initialize the learner from the scratch, removing any potential knowledge built by previously entered training data. When true is returned, then on the first call of the MultiLabelLearner.build(MultiLabelInstances) the learner is initialized with the passed training data. All other calls contribute to the existing learner's model with new data.

Specified by:
isUpdatable in interface MultiLabelLearner
Overrides:
isUpdatable in class MultiLabelLearnerBase
Returns:
true if learner is updatable (on-line), false otherwise.

setDistanceWeighting

public void setDistanceWeighting(int distanceWeighting)
Parameters:
distanceWeighting - the distanceWeighting to set