de.fu_berlin.ties.classify
Class PredictionComparator

java.lang.Object
  extended by de.fu_berlin.ties.classify.PredictionComparator
All Implemented Interfaces:
Comparator<Prediction>

public class PredictionComparator
extends Object
implements Comparator<Prediction>

A comparison function that compares Predictions based on their probabilities.

Version:
$Revision: 1.6 $, $Date: 2004/11/19 14:04:19 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
PredictionComparator()
          Creates a new instance.
 
Method Summary
 int compare(Prediction pred1, Prediction pred2)
          Compares two Predictions.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

PredictionComparator

public PredictionComparator()
Creates a new instance.

Method Detail

compare

public int compare(Prediction pred1,
                   Prediction pred2)
            throws ClassCastException
Compares two Predictions. This method checks whether the pR values of both predictions are given and compares them if they are. Otherwise the probabilities are compared. In case of a tie the raw scores are compared if both are WinnowPredictions. Otherwise the types are compared lexicographically (but in inverted order, so in case of a tie the alphabetically first prediction "wins").

Specified by:
compare in interface Comparator<Prediction>
Parameters:
pred1 - the first prediction to be compared
pred2 - the second prediction to be compared
Returns:
a negative integer, zero, or a positive integer if the first argument is less than, equal to, or greater than of the second
Throws:
ClassCastException - if either of the arguments is not a Prediction

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.