com.cra.bnet.learn
Class ComplexDataSet

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

public class ComplexDataSet
extends Object
implements DataSet

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

 Node1 Node2 ... NodeM
 [state1=value1,state2=value2,stateM=valueM] [state1=value1,state2=value2,stateM=valueM] [state1=value1,state2=value2,stateM=valueM]
 [state1=value1,state2=value2,stateM=valueM] [state1=value1,state2=value2,stateM=valueM] [state1=value1,state2=value2,stateM=valueM]
 .
 .
 .
 
where stateM is a combination of upper or lower-case letters, with optionally a number at the end, and valueM is a digit(s)-point-digit(s) format. Valid state names that will be picked up: Yes, s1, s356, FALSE, t4, no. For the values, each number before and after the decimal point might have any number of digits, , where the point and any number before it are optional. Example of valid numbers: .5 1 3.4 345 234.5676 .789 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
ComplexDataSet(File file, BayesianNetwork network)
          Creates a new ComplexDataSet 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.
 boolean getValuesParsed()
          Checks if any value was parsed in this object, in which case this parser is compatible with the selected data file.
 boolean isNetworkCompatible(BayesianNetwork network)
          Whenever a new BayesianNetwork is to be used with this data set, check to see if the nodes are compatible.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComplexDataSet

public ComplexDataSet(File file,
                      BayesianNetwork network)
Creates a new ComplexDataSet using the data in the specified file and the specified Bayesian network. You must specify a Bayesian network so that Evidence objects can be created.

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.

isNetworkCompatible

public boolean isNetworkCompatible(BayesianNetwork network)
Whenever a new BayesianNetwork is to be used with this data set, check to see if the nodes are compatible.

Parameters:
network -
Returns:
true if files are 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.

toString

public String toString()
Overrides:
toString in class Object