de.fu_berlin.ties.classify
Class Prediction

java.lang.Object
  extended byde.fu_berlin.ties.io.BaseStorable
      extended byde.fu_berlin.ties.classify.Prediction
All Implemented Interfaces:
Storable
Direct Known Subclasses:
Extraction, WinnowPrediction

public class Prediction
extends BaseStorable

A prediction, wrapping the predicted class and the probability of the prediction.

Instances of this class are not thread-safe and must be synchronized externally, if required.

Version:
$Revision: 1.13 $, $Date: 2004/03/29 15:31:31 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String KEY_PR
          Serialization key for the pR.
static String KEY_PROB
          Serialization key for the probability.
static String KEY_SOURCE
          Serialization key for the source identifier.
static String KEY_TYPE
          Serialization key for the predicted class.
 
Constructor Summary
Prediction(FieldMap fieldMap)
          Creates a new instance from a field map, fulfilling the Storable contract.
Prediction(String predicted, double prob, double pr)
          Creates a new instance, setting the evaluation status to EvalStatus.UNKNOWN.
Prediction(String predicted, double prob, double pr, EvalStatus status)
          Creates a new instance.
Prediction(String predicted, String sourceID, double prob, double pr, EvalStatus status)
          Creates a new instance.
 
Method Summary
protected  void addProb(double newProb, double newPR)
          Adds a new probability/pR of the prediction.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract.
 EvalStatus getEvalStatus()
          Returns the evaluation status of this instance.
 double getPR()
          Returns the pR of the prediction: pR = log(p / (1-p)).
 double getProbability()
          Returns the probability.
 String getSource()
          Returns the identifier of the source of this prediction (e.g., the file name).
 String getType()
          Returns the predicted type (class).
 int hashCode()
          Returns a hash code value for this object, fulfulling the Object.hashCode() contract.
 void setEvalStatus(EvalStatus newEvalStatus)
          Modifies the evaluation status of this instance.
 void setSource(String newSource)
          Sets the identifier of the source of this prediction (e.g., the file name).
 FieldMap storeFields()
          Stores all relevant fields of this object in a field map for serialization.
 
Methods inherited from class de.fu_berlin.ties.io.BaseStorable
toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_TYPE

public static final String KEY_TYPE
Serialization key for the predicted class.

See Also:
Constant Field Values

KEY_SOURCE

public static final String KEY_SOURCE
Serialization key for the source identifier.

See Also:
Constant Field Values

KEY_PROB

public static final String KEY_PROB
Serialization key for the probability.

See Also:
Constant Field Values

KEY_PR

public static final String KEY_PR
Serialization key for the pR.

See Also:
Constant Field Values
Constructor Detail

Prediction

public Prediction(FieldMap fieldMap)
Creates a new instance from a field map, fulfilling the Storable contract.

Parameters:
fieldMap - map containing the serialized fields

Prediction

public Prediction(String predicted,
                  double prob,
                  double pr)
Creates a new instance, setting the evaluation status to EvalStatus.UNKNOWN.

Parameters:
predicted - the predicted type
prob - the probability of the prediction (must be in the range from 0.0 to 1.0; or -1 if this is a confirmed prediction or an answer key)
pr - the pR of the prediction; or Double.NaN if not known

Prediction

public Prediction(String predicted,
                  double prob,
                  double pr,
                  EvalStatus status)
Creates a new instance.

Parameters:
predicted - the predicted type
prob - the probability of the prediction (must be in the range from 0.0 to 1.0; or -1 if this is a confirmed prediction or an answer key)
pr - the pR of the prediction; or Double.NaN if not known
status - the evaluation status of this instance

Prediction

public Prediction(String predicted,
                  String sourceID,
                  double prob,
                  double pr,
                  EvalStatus status)
Creates a new instance.

Parameters:
predicted - the predicted type
sourceID - an identifier of the source of this prediction (e.g., the file name), might be null
prob - the probability of the prediction (must be in the range from 0.0 to 1.0; or -1 if this is a confirmed prediction or an answer key)
pr - the pR of the prediction; or Double.NaN if not known
status - the evaluation status of this instance
Method Detail

addProb

protected void addProb(double newProb,
                       double newPR)
                throws IllegalArgumentException
Adds a new probability/pR of the prediction. The actual probabilities/pR are averaged over the combined probabilities/pRs.

Parameters:
newProb - the new probability (should be in the range from 0.0 to 1.0)
newPR - the new pR; or Double.NaN if not used
Throws:
IllegalArgumentException - if this is an answer key; if newProb is not a valid probability; or if either the old or the new pR is not-a-number, but not both

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract. Evaluation status, probability and pR are ignored when checking equality, only type and source are compared.

Parameters:
obj - the reference object with which to compare
Returns:
true iff the specified object is a Prediction equal to this instance

getEvalStatus

public EvalStatus getEvalStatus()
Returns the evaluation status of this instance.

Returns:
the value of the attribute

getPR

public double getPR()
Returns the pR of the prediction: pR = log(p / (1-p)). The pR is useful to decide between predictions whose probabilities are very similar (e.g. ~1.0), because it is less sensitive to rounding issues.

Returns:
the pR; or Double.NaN if not known

getProbability

public double getProbability()
Returns the probability. The returned value will be in the range from 0 to 1; or -1 if this is a confirmed prediction or an answer key.

Returns:
the probability

getSource

public String getSource()
Returns the identifier of the source of this prediction (e.g., the file name).

Returns:
the value of the attribute; or null if none specified

getType

public String getType()
Returns the predicted type (class).

Returns:
the predicted type (class)

hashCode

public int hashCode()
Returns a hash code value for this object, fulfulling the Object.hashCode() contract.

Returns:
a hash code value for this object

setEvalStatus

public void setEvalStatus(EvalStatus newEvalStatus)
Modifies the evaluation status of this instance.

Parameters:
newEvalStatus - the new value of the attribute

setSource

public void setSource(String newSource)
Sets the identifier of the source of this prediction (e.g., the file name).

Parameters:
newSource - the new value of the attribute; or null to delete the current value

storeFields

public FieldMap storeFields()
Stores all relevant fields of this object in a field map for serialization. An equivalent object can be created by calling FieldMap.createObject(Class) on the created field map.

Returns:
the created field map


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