classification
Class PredictionSet

java.lang.Object
  extended by classification.PredictionSet
All Implemented Interfaces:
java.io.Serializable

public class PredictionSet
extends java.lang.Object
implements java.io.Serializable

This class represents a set of predictions for a particular dataset.

See Also:
Serialized Form

Constructor Summary
PredictionSet(java.lang.String name, int dsID, java.lang.String username)
          Creates an empty prediction set.
PredictionSet(java.lang.String name, int dsID, java.lang.String username, java.lang.String filename)
          Creates a prediction set populated with predictions from the given file.
 
Method Summary
 void add(Prediction p, boolean isData)
          Adds a prediction to this set.
 double compareToSet(PredictionSet otherSet, java.lang.String attrName, boolean forData)
          Determines the percentage of predictions in this set that are identical to those in another set.
 void generateXML(java.lang.String filename)
          Generates a predictions XML file representing the predictions in this set.
 java.lang.String generateXMLstring()
           
 java.util.List<Prediction> getDataPredictions(java.lang.String attrName)
          Retrieves all predictions for the specified attribute from the data section of the set.
 int getDatasetID()
          The ID number of the data set these predictions are for.
 java.lang.String getName()
          The name of the prediction set.
 Prediction getPrediction(int instance, java.lang.String attrName, boolean isData)
          Retrieves a prediction for the specified instance and attribute from the indicated section of the set.
 java.util.List<Prediction> getTestPredictions(java.lang.String attrName)
          Retrieves all predictions for the specified attribute from the test section of the set.
 java.lang.String getUserName()
          The name of the user who submitted the set.
 void parseXML(java.lang.String filename)
          This method parses an XML file containing prediction data, and adds the resulting Predictions to the PredictionSet.
 void setUserName(java.lang.String userName)
          Sets the name of the user who submitted the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredictionSet

public PredictionSet(java.lang.String name,
                     int dsID,
                     java.lang.String username)
Creates an empty prediction set.

Parameters:
name - The name for the prediction set
dsID - The ID number of the data set this set will contain predictions for
username - The name of the user who submitted the set

PredictionSet

public PredictionSet(java.lang.String name,
                     int dsID,
                     java.lang.String username,
                     java.lang.String filename)
              throws org.xml.sax.SAXException
Creates a prediction set populated with predictions from the given file.

Parameters:
name - The name for the prediction set
dsID - The ID number of the data set this set will contain predictions for
username - The name of the user who submitted the set
filename - The name of the file to read from (must include .xml)
Throws:
org.xml.sax.SAXException
Method Detail

add

public void add(Prediction p,
                boolean isData)
Adds a prediction to this set.

Parameters:
p - The prediction to add
isData - true if p is a Data prediction, false if it is Test prediction

getDatasetID

public int getDatasetID()
The ID number of the data set these predictions are for.

Returns:
The data set ID number

getName

public java.lang.String getName()
The name of the prediction set.

Returns:
The prediction set's name

getPrediction

public Prediction getPrediction(int instance,
                                java.lang.String attrName,
                                boolean isData)
Retrieves a prediction for the specified instance and attribute from the indicated section of the set.

Parameters:
instance - The instance number of the desired prediction
attrName - The attribute of the desired prediction
isData - Indicates whether to retrieve a Data prediction (true) or a Test prediction (false)
Returns:
The specified prediction, or null if it couldn't be found.

getDataPredictions

public java.util.List<Prediction> getDataPredictions(java.lang.String attrName)
Retrieves all predictions for the specified attribute from the data section of the set.

Parameters:
attrName - The name of the attribute to retrieve predictions for.
Returns:
A list of predictions

getTestPredictions

public java.util.List<Prediction> getTestPredictions(java.lang.String attrName)
Retrieves all predictions for the specified attribute from the test section of the set.

Parameters:
attrName - The name of the attribute to retrieve predictions for.
Returns:
A list of predictions

getUserName

public java.lang.String getUserName()
The name of the user who submitted the set.

Returns:
The user's name

setUserName

public void setUserName(java.lang.String userName)
Sets the name of the user who submitted the set.

Parameters:
userName - The user's name

compareToSet

public double compareToSet(PredictionSet otherSet,
                           java.lang.String attrName,
                           boolean forData)
                    throws java.lang.Exception
Determines the percentage of predictions in this set that are identical to those in another set.

Parameters:
otherSet - The other set to compare this set with
attrName - The data attribute to compare these sets for
Returns:
The percentage of predictions that are identical between the two sets.
Throws:
java.lang.Exception - if other set contains predictions for different data

generateXML

public void generateXML(java.lang.String filename)
                 throws java.io.IOException
Generates a predictions XML file representing the predictions in this set.

Parameters:
filename - The path and name of the desired file (.xml extension is added automatically)
Throws:
java.io.IOException

generateXMLstring

public java.lang.String generateXMLstring()

parseXML

public final void parseXML(java.lang.String filename)
                    throws org.xml.sax.SAXException
This method parses an XML file containing prediction data, and adds the resulting Predictions to the PredictionSet.

Parameters:
filename - The name/path of the XML prediction file to parse
Throws:
org.xml.sax.SAXException