weka.classifiers.misc.monotone
Class InstancesComparator

java.lang.Object
  extended by weka.classifiers.misc.monotone.InstancesComparator
All Implemented Interfaces:
java.util.Comparator, RevisionHandler

public class InstancesComparator
extends java.lang.Object
implements java.util.Comparator, RevisionHandler

Class to compare instances with respect to a given attribute, indicated by its index. The ordering of the attribute values is determined by the internal values of WEKA. There is also the possibility of reversing this order.

This implementation is part of the master's thesis: "Studie en implementatie van instantie-gebaseerde algoritmen voor gesuperviseerd rangschikken", Stijn Lievens, Ghent University, 2004.

Version:
$Revision: 1.2 $
Author:
Stijn Lievens (stijn.lievens@ugent.be)

Constructor Summary
InstancesComparator(int index)
          Construct an InstancesComparator that compares the attributes with the given index.
InstancesComparator(int index, boolean reverse)
          Construct an InstancesComparator that compares the attributes with the given index, with the possibility of reversing the order.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two objects (instances) with respect to the attribute this comparator is constructed on.
 java.lang.String getRevision()
          Returns the revision string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

InstancesComparator

public InstancesComparator(int index)
Construct an InstancesComparator that compares the attributes with the given index.

Parameters:
index - the index on which to compare instances

InstancesComparator

public InstancesComparator(int index,
                           boolean reverse)
Construct an InstancesComparator that compares the attributes with the given index, with the possibility of reversing the order.

Parameters:
index - the index on which to compare instances
reverse - if true the order is reversed, if false the order is not reversed
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two objects (instances) with respect to the attribute this comparator is constructed on.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - the first object to be compared
o2 - the second object to be compared
Returns:
-1 if o1 < o2 (wrt to the given attribute), 1 if o1 > o2 , and 0 if o1 and o2 are equal (wrt to the given attribute)

getRevision

public java.lang.String getRevision()
Returns the revision string.

Specified by:
getRevision in interface RevisionHandler
Returns:
the revision