de.fu_berlin.ties.classify
Class Prediction

java.lang.Object
  extended by de.fu_berlin.ties.io.BaseStorable
      extended by de.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.22 $, $Date: 2004/11/25 13:35:55 $, $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, Probability prob)
          Creates a new instance, setting the evaluation status to EvalStatus.UNKNOWN.
Prediction(String predicted, Probability prob, EvalStatus status)
          Creates a new instance.
Prediction(String predicted, String sourceID, Probability prob, EvalStatus status)
          Creates a new instance.
 
Method Summary
protected  void addProb(Probability prob, boolean atEnd)
          Adds a new probability for 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.
 Probability getProbability()
          Calculates and returns the average 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.
protected  int probCount()
          Returns the number of probabilities combined in this prediction.
protected  Probability removeProb(boolean atEnd)
          Deletes one of the probabilities used for the prediction.
 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,
                  Probability prob)
Creates a new instance, setting the evaluation status to EvalStatus.UNKNOWN.

Parameters:
predicted - the predicted type
prob - the probability of the prediction

Prediction

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

Parameters:
predicted - the predicted type
prob - the probability of the prediction
status - the evaluation status of this instance

Prediction

public Prediction(String predicted,
                  String sourceID,
                  Probability prob,
                  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
status - the evaluation status of this instance
Method Detail

addProb

protected void addProb(Probability prob,
                       boolean atEnd)
Adds a new probability for the prediction. The actual probabilities are averaged over the combined probabilities.

Parameters:
prob - the new probability; might be null if the overall probability of the extraction should not be changed
atEnd - whether to add the new probability at the end or at the start

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 and probability are ignored when checking equality, only type and source are compared.

Overrides:
equals in class Object
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

getProbability

public Probability getProbability()
Calculates and returns the average probability.

Returns:
the average 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.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object

probCount

protected int probCount()
Returns the number of probabilities combined in this prediction.

Returns:
the number of probabilities

removeProb

protected Probability removeProb(boolean atEnd)
                          throws IllegalStateException
Deletes one of the probabilities used for the prediction. At least one probability must always remain, i.e. probCount() must be 2 or more prior to calling this method.

Parameters:
atEnd - whether to delete the first or the last probability
Returns:
the removed probability
Throws:
IllegalStateException - if there is only one probability left

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.