weka.core.converters
Class HierarchicalCostMatrix

java.lang.Object
  extended byweka.core.converters.HierarchicalCostMatrix

public class HierarchicalCostMatrix
extends java.lang.Object

This is a stand-alone class within the WEKA-framework to provide a hierarchical cost matrix for a given hierarchy of classes. It is a first attempt to do so. The idea was not further developed. The architecture of this class is not weka-like, perhaps it should be adapted once.

Author:
Arthur Zimek

Field Summary
private  double[][] costMatrix
          Keeps the cost matrix.
static double DEFAULT_WEIGHT
          The default weight of classes.
private  double multiplier
          Default multiplier to increase penalty for a wrong class per differing branch in a hierarchy.
 
Constructor Summary
HierarchicalCostMatrix(Attribute nominalClasses, ClassHierarchy hierarchy)
          Creates a hierarchical cost matrix using default multiplier.
HierarchicalCostMatrix(Attribute nominalClasses, ClassHierarchy hierarchy, double multiplier)
          Creates a hierarchical cost matrix using given multiplier.
 
Method Summary
protected  void adjust(Attribute nominalClasses, ClassHierarchy hierarchy)
          Adjusts the costMatrix for the given classes, and hierarchy, using the currently set multiplier.
protected  void init(Attribute nominalClasses, ClassHierarchy hierarchy)
          Inits the fields according to the given classes and hierarchy.
static void main(java.lang.String[] args)
          Method to use the class as stand-alone tool.
 java.lang.String toString()
          Returns a String representation of the cost matrix suitable for usage mit cost dependend classifiers.
static java.lang.String usage()
          Describes the proper usage of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight of classes.

See Also:
Constant Field Values

costMatrix

private double[][] costMatrix
Keeps the cost matrix.


multiplier

private double multiplier
Default multiplier to increase penalty for a wrong class per differing branch in a hierarchy.

Constructor Detail

HierarchicalCostMatrix

public HierarchicalCostMatrix(Attribute nominalClasses,
                              ClassHierarchy hierarchy)
Creates a hierarchical cost matrix using default multiplier.

Parameters:
nominalClasses - the classes to create cost matrix for
hierarchy - the hierarchy defining the costs

HierarchicalCostMatrix

public HierarchicalCostMatrix(Attribute nominalClasses,
                              ClassHierarchy hierarchy,
                              double multiplier)
Creates a hierarchical cost matrix using given multiplier.

Parameters:
nominalClasses - the classes to create cost matrix for
hierarchy - the hierarchy defining the costs
multiplier - multiplier to enhance costs for wrong branches per level
Method Detail

init

protected void init(Attribute nominalClasses,
                    ClassHierarchy hierarchy)
Inits the fields according to the given classes and hierarchy.

Parameters:
nominalClasses - the classes to create cost matrix for
hierarchy - the hierarchy defining the costs

adjust

protected void adjust(Attribute nominalClasses,
                      ClassHierarchy hierarchy)
Adjusts the costMatrix for the given classes, and hierarchy, using the currently set multiplier.

Parameters:
nominalClasses - the classes to create cost matrix for
hierarchy - the hierarchy defining the costs

toString

public java.lang.String toString()
Returns a String representation of the cost matrix suitable for usage mit cost dependend classifiers.

See Also:
Object.toString()

usage

public static java.lang.String usage()
Describes the proper usage of this class.

Returns:
String String describing the proper usage of the class

main

public static void main(java.lang.String[] args)
Method to use the class as stand-alone tool. Causes system.exit in case of invalid usage. Prints out a cost matrix for the given parameters.

Parameters:
args - expects the arguments:
  • -a
  • -i [optional - default: last]
  • -h
  • -o [optional - default: STDOUT]
  • -m [optional - default: 1]