mulan.classifier.meta
Class HierarchyBuilder

java.lang.Object
  extended by mulan.classifier.meta.HierarchyBuilder
All Implemented Interfaces:
Serializable

public class HierarchyBuilder
extends Object
implements Serializable

Class that builds a hierarchy on flat lables of given mulltilabel data. The hierarchy may be built with three methods.

Version:
0.1
Author:
George Saridis, Grigorios Tsoumakas
See Also:
Serialized Form

Nested Class Summary
static class HierarchyBuilder.Method
          The different types of distributing labels to children nodes
 
Constructor Summary
HierarchyBuilder(int partitions, HierarchyBuilder.Method method)
          Constructs a new istance based on given number of partitions and method
 
Method Summary
 MultiLabelInstances buildHierarchy(MultiLabelInstances mlData)
          Builds a hierarhical multi-label dataset.
 MultiLabelInstances buildHierarchyAndSaveFiles(MultiLabelInstances mlData, String arffName, String xmlName)
          Builds the hierarchy and constructs auxiliary files
 LabelsMetaData buildLabelHierarchy(MultiLabelInstances mlData)
          Builds a hierarhy of labels on top of the labels of a flat multi-label dataset, by recursively partitioning the labels into a specified number of partitions.
static MultiLabelInstances createHierarchicalDataset(MultiLabelInstances mlData, LabelsMetaData metaData)
          Creates the hierarchical dataset according to the original multilabel instances object and the constructed label hierarchy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchyBuilder

public HierarchyBuilder(int partitions,
                        HierarchyBuilder.Method method)
Constructs a new istance based on given number of partitions and method

Parameters:
partitions - the number of partitions
method - the partitioning method
Method Detail

buildHierarchy

public MultiLabelInstances buildHierarchy(MultiLabelInstances mlData)
                                   throws Exception
Builds a hierarhical multi-label dataset. Firstly a random hierarchy is built on top of the labels of a flat multi-label dataset, by recursively randomly partitioning the labels into a specified number of clusters. Then the values for the new "meta-labels" are properly set, so that the hierarchy is respected.

Parameters:
mlData - the multiLabel data on which the new hierarchy will be built
Returns:
the new multiLabel data
Throws:
Exception

buildLabelHierarchy

public LabelsMetaData buildLabelHierarchy(MultiLabelInstances mlData)
                                   throws Exception
Builds a hierarhy of labels on top of the labels of a flat multi-label dataset, by recursively partitioning the labels into a specified number of partitions.

Parameters:
mlData - the multiLabel data on with the new hierarchy will be built
Returns:
a hierarchy of labels
Throws:
Exception

buildHierarchyAndSaveFiles

public MultiLabelInstances buildHierarchyAndSaveFiles(MultiLabelInstances mlData,
                                                      String arffName,
                                                      String xmlName)
                                               throws Exception
Builds the hierarchy and constructs auxiliary files

Parameters:
mlData - the flat training data
arffName - the name of the hierachical data
xmlName - the filename for the hirearchy
Returns:
the hierarchical data
Throws:
Exception

createHierarchicalDataset

public static MultiLabelInstances createHierarchicalDataset(MultiLabelInstances mlData,
                                                            LabelsMetaData metaData)
                                                     throws InvalidDataFormatException
Creates the hierarchical dataset according to the original multilabel instances object and the constructed label hierarchy

Parameters:
mlData - the original multilabel instances
metaData - the metadata of the constructed label hierarchy
Returns:
the produced dataset
Throws:
InvalidDataFormatException