com.cra.bnet.learn
Class SimpleDataSet

java.lang.Object
  |
  +--com.cra.bnet.learn.SimpleDataSet
All Implemented Interfaces:
DataSet

public class SimpleDataSet
extends Object
implements DataSet

Simple implementation of the DataSet interface. This class supports plain text data files that have the following format:

 Node1 Node2 ... NodeM
 state state ... state
 state state ... state
 .
 .
 .
 
The first line specifies the names of nodes in the Bayesian network. Each following line contains one case, which has one state for each node. Each case represents an observation of the nodes.

Although spaces are used above as the delimiting character between node names and states, any default delimiter supported by the java.util.StringTokenizer class can be used instead (currently these are " \t\n\r\f": the space character, the tab character, the newline character, the carriage-return character, and the form-feed character).


Constructor Summary
SimpleDataSet(File file, BayesianNetwork network)
          Creates a new SimpleDataSet using the data in the specified file and the specified Bayesian network.
SimpleDataSet(File file, BayesianNetwork network, String missingDataString)
          Creates a new SimpleDataSet using the data in the specified file and the specified Bayesian network.
 
Method Summary
 int getCaseCount()
          Returns the number of cases in this data set.
 Iterator getCases()
          Returns an iterator over the cases in this data set.
 String getMissingDataString()
          Retuns the string that represents a missing value in the data file.
 boolean getValuesParsed()
          Checks if any value was parsed in this object, in which case this parser is compatible with the selected data file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDataSet

public SimpleDataSet(File file,
                     BayesianNetwork network,
                     String missingDataString)
Creates a new SimpleDataSet using the data in the specified file and the specified Bayesian network. You must specify a Bayesian network that will be used when learning.

Parameters:
file - data file.
network - Bayesian network.
missingDataString - string that represents a missing value in the data file.
Throws:
IllegalArgumentException - if file or network is null.

SimpleDataSet

public SimpleDataSet(File file,
                     BayesianNetwork network)
Creates a new SimpleDataSet using the data in the specified file and the specified Bayesian network. You must specify a Bayesian network that will be used when learning. This constructor just calls this(file, network, "???");

Parameters:
file - data file.
network - Bayesian network.
Throws:
IllegalArgumentException - if file or network is null.
Method Detail

getValuesParsed

public boolean getValuesParsed()
Checks if any value was parsed in this object, in which case this parser is compatible with the selected data file.

Specified by:
getValuesParsed in interface DataSet
Returns:
true if compatible.

getCaseCount

public int getCaseCount()
Returns the number of cases in this data set.

Specified by:
getCaseCount in interface DataSet
Returns:
the number of cases in this data set.

getCases

public Iterator getCases()
Returns an iterator over the cases in this data set. Objects returned by the iterator are guaranteed to be of type Case.

Specified by:
getCases in interface DataSet
Returns:
an iterator over the cases in this data set.

getMissingDataString

public String getMissingDataString()
Retuns the string that represents a missing value in the data file. By default the string ??? is used.

Returns:
the string that represents a missing value in the data file.