mulan.classifier.transformation
Class MultiLabelStacking

java.lang.Object
  extended by mulan.classifier.MultiLabelLearnerBase
      extended by mulan.classifier.transformation.TransformationBasedMultiLabelLearner
          extended by mulan.classifier.transformation.MultiLabelStacking
All Implemented Interfaces:
Serializable, MultiLabelLearner, TechnicalInformationHandler

public class MultiLabelStacking
extends TransformationBasedMultiLabelLearner
implements Serializable

This class is an implementation of the (BR)^2 or Multi-Label stacking method.

For more information, see

Grigorios Tsoumakas, Anastasios Dimou, Eleftherios Spyromitros, Vasileios Mezaris, Ioannis Kompatsiaris, Ioannis Vlahavas: Correlation-Based Pruning of Stacked Binary Relevance Models for Multi-Label Learning. In: Proc. ECML/PKDD 2009 Workshop on Learning from Multi-Label Data (MLD'09), 101-116, 2009.

BibTeX:

 @inproceedings{GrigoriosTsoumakas2009,
    author = {Grigorios Tsoumakas, Anastasios Dimou, Eleftherios Spyromitros, Vasileios Mezaris, Ioannis Kompatsiaris, Ioannis Vlahavas},
    booktitle = {Proc. ECML/PKDD 2009 Workshop on Learning from Multi-Label Data (MLD'09)},
    pages = {101-116},
    title = {Correlation-Based Pruning of Stacked Binary Relevance Models for Multi-Label Learning},
    year = {2009},
    location = {Bled, Slovenia}
 }
 

Version:
2012.02.07
Author:
Eleftherios Spyromitros-Xioufis (espyromi@csd.auth.gr)
See Also:
Serialized Form

Field Summary
protected  Instances train
          the training instances
 
Fields inherited from class mulan.classifier.transformation.TransformationBasedMultiLabelLearner
baseClassifier
 
Fields inherited from class mulan.classifier.MultiLabelLearnerBase
featureIndices, labelIndices, numLabels
 
Constructor Summary
MultiLabelStacking()
          An empty constructor
MultiLabelStacking(Classifier baseClassifier, Classifier metaClassifier)
          A constructor with 2 arguments
 
Method Summary
protected  Instances attachIndexes(Instances original)
          Attaches an index attribute at the beginning of each instance
 void buildBaseLevel(MultiLabelInstances trainingSet)
          Builds the base-level classifiers.
 void buildBaseLevelKNN(MultiLabelInstances trainingSet)
          Used only in case of a kNN base classifier.
protected  void buildInternal(MultiLabelInstances dataSet)
          Learner specific implementation of building the model from MultiLabelInstances training data set.
 void buildMetaLevel()
          Builds the ensemble of meta-level classifiers.
protected  Instances detachIndexes(Instances original)
          Detaches the index attribute from the beginning of each instance
 TechnicalInformation getTechnicalInformation()
          Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
 int getTopkCorrelated()
          Returns top k correlated labels
 String globalInfo()
          Returns a string describing the classifier.
 void initializeMetaLevel(MultiLabelInstances dataSet, Classifier metaClassifier, boolean includeAttrs, double metaPercentage, ASEvaluation eval)
          Initializes all the parameters used in the meta-level.
protected  MultiLabelOutput makePredictionInternal(Instance instance)
          Learner specific implementation for predicting on specified data based on trained model.
 void saveObject(String filename)
          Saves a MultiLabelStacking object in a file
 void setEval(ASEvaluation eval)
          Sets the attribute selection evaluation class
 void setIncludeAttrs(boolean includeAttrs)
          Sets the value of includeAttrs
 void setMetaAlgorithm(Classifier metaClassifier)
          Sets the type of the meta classifier and initializes the ensemble
 void setMetaPercentage(double metaPercentage)
          Sets the value of metaPercentage
 void setNormalize(boolean normalize)
          Sets the value of normalize
 void setPartialBuild(boolean partialBuild)
          sets the value for partialBuild
 
Methods inherited from class mulan.classifier.transformation.TransformationBasedMultiLabelLearner
getBaseClassifier
 
Methods inherited from class mulan.classifier.MultiLabelLearnerBase
build, debug, getDebug, isModelInitialized, isUpdatable, makeCopy, makePrediction, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

train

protected Instances train
the training instances

Constructor Detail

MultiLabelStacking

public MultiLabelStacking()
An empty constructor


MultiLabelStacking

public MultiLabelStacking(Classifier baseClassifier,
                          Classifier metaClassifier)
A constructor with 2 arguments

Parameters:
baseClassifier - the classifier used in the base-level
metaClassifier - the classifier used in the meta-level
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the classifier.

Overrides:
globalInfo in class TransformationBasedMultiLabelLearner
Returns:
a string description of the classifier

getTechnicalInformation

public TechnicalInformation getTechnicalInformation()
Description copied from class: TransformationBasedMultiLabelLearner
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.

Specified by:
getTechnicalInformation in interface TechnicalInformationHandler
Overrides:
getTechnicalInformation in class TransformationBasedMultiLabelLearner
Returns:
the technical information about this class

buildInternal

protected void buildInternal(MultiLabelInstances dataSet)
                      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:
dataSet - the training data set
Throws:
Exception - if learner model was not created successfully

initializeMetaLevel

public void initializeMetaLevel(MultiLabelInstances dataSet,
                                Classifier metaClassifier,
                                boolean includeAttrs,
                                double metaPercentage,
                                ASEvaluation eval)
                         throws Exception
Initializes all the parameters used in the meta-level. Calculates the correlated labels if meta-level pruning is applied.

Parameters:
dataSet -
metaClassifier -
includeAttrs -
metaPercentage -
eval -
Throws:
Exception

buildBaseLevel

public void buildBaseLevel(MultiLabelInstances trainingSet)
                    throws Exception
Builds the base-level classifiers. Their predictions are gathered in the baseLevelPredictions member

Parameters:
trainingSet -
Throws:
Exception

buildMetaLevel

public void buildMetaLevel()
                    throws Exception
Builds the ensemble of meta-level classifiers.

Throws:
Exception

buildBaseLevelKNN

public void buildBaseLevelKNN(MultiLabelInstances trainingSet)
                       throws Exception
Used only in case of a kNN base classifier.

Parameters:
trainingSet -
Throws:
Exception

makePredictionInternal

protected MultiLabelOutput makePredictionInternal(Instance instance)
                                           throws Exception
Description copied from class: MultiLabelLearnerBase
Learner specific implementation for predicting on specified data based on trained model. This method is called from MultiLabelLearnerBase.makePrediction(weka.core.Instance) which guards for model initialization and apply common handling/behavior.

Specified by:
makePredictionInternal in class MultiLabelLearnerBase
Parameters:
instance - the data instance to predict on
Returns:
the output of the learner for the given instance
Throws:
Exception - if an error occurs while making the prediction.
InvalidDataException - if specified instance data is invalid and can not be processed by the learner

attachIndexes

protected Instances attachIndexes(Instances original)
Attaches an index attribute at the beginning of each instance

Parameters:
original -
Returns:
the modified instances

detachIndexes

protected Instances detachIndexes(Instances original)
                           throws Exception
Detaches the index attribute from the beginning of each instance

Parameters:
original -
Returns:
the modified instances
Throws:
Exception

saveObject

public void saveObject(String filename)
Saves a MultiLabelStacking object in a file

Parameters:
filename -

setNormalize

public void setNormalize(boolean normalize)
Sets the value of normalize

Parameters:
normalize -

setIncludeAttrs

public void setIncludeAttrs(boolean includeAttrs)
Sets the value of includeAttrs

Parameters:
includeAttrs -

setMetaPercentage

public void setMetaPercentage(double metaPercentage)
Sets the value of metaPercentage

Parameters:
metaPercentage -

setEval

public void setEval(ASEvaluation eval)
Sets the attribute selection evaluation class

Parameters:
eval -

setMetaAlgorithm

public void setMetaAlgorithm(Classifier metaClassifier)
                      throws Exception
Sets the type of the meta classifier and initializes the ensemble

Parameters:
metaClassifier -
Throws:
Exception

setPartialBuild

public void setPartialBuild(boolean partialBuild)
sets the value for partialBuild

Parameters:
partialBuild -

getTopkCorrelated

public int getTopkCorrelated()
Returns top k correlated labels

Returns:
top k correlated labels