public class DataSet extends java.lang.Object implements OptionHandler
Modifier and Type | Field and Description |
---|---|
protected Attributes |
attributes
the attributes of this data set
|
protected Examples |
examples
the examples of this data set
|
protected java.lang.String |
name
the name of this data set
|
protected java.util.Random |
random
a random number generator
|
protected long |
seed
default random seed
|
Constructor and Description |
---|
DataSet()
Default constructor.
|
DataSet(Attributes attributes)
Explicit constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(DataSet dataset)
Adds the examples of the specified data set to this data set.
|
void |
add(Example example)
Adds the specified example to this data set.
|
Attributes |
getAttributes()
Gets the attributes of this DataSet object.
|
Examples |
getExamples()
Gets the examples of this data set.
|
boolean |
getHasNominalAttributes()
Returns true if this data set has nominal attributes; returns false
otherwise.
|
boolean |
getHasNumericAttributes()
Returns true if this data set has numeric attributes; returns false
otherwise.
|
long |
getSeed()
Gets the seed for this data set.
|
void |
load(java.lang.String filename)
Loads a data set from the specified file.
|
static void |
main(java.lang.String[] args)
A main method for testing.
|
private void |
parse(java.util.Scanner scanner)
Parses a data set from the specified scanner, which consists of
parsing the data set's header, attributes, and examples.
|
void |
setOptions(java.lang.String[] options)
Sets the options for this data set.
|
void |
setSeed(long seed)
Sets the random number seed for this data set.
|
java.lang.String |
toString()
Returns a string representation of the data set in a format identical
to that of the file format.
|
protected java.lang.String name
protected Attributes attributes
protected Examples examples
protected long seed
protected java.util.Random random
public DataSet()
public DataSet(Attributes attributes) throws java.lang.Exception
attributes
- the attributes for this data setjava.lang.Exception
- if the examples can not be added because of type or memory problemspublic void add(DataSet dataset) throws java.lang.Exception
dataset
- the data set to be addedjava.lang.Exception
- if the examples can not be added because of type or memory problemspublic void add(Example example) throws java.lang.Exception
example
- the example to be addedjava.lang.Exception
- if the example can not be added because of type or memory problemspublic Attributes getAttributes()
public Examples getExamples()
public long getSeed()
public boolean getHasNominalAttributes()
public boolean getHasNumericAttributes()
public void load(java.lang.String filename) throws java.lang.Exception
filename
- the file from which to readjava.lang.Exception
- if the file is not found or if a parse error occursprivate void parse(java.util.Scanner scanner) throws java.lang.Exception
scanner
- a scanner containing the data set's tokensjava.lang.Exception
- if a parse error occurspublic void setOptions(java.lang.String[] options) throws java.lang.Exception
-s
sets the random seed for this data set.setOptions
in interface OptionHandler
options
- the argumentsjava.lang.Exception
- if an option is illegalpublic void setSeed(long seed)
seed
- the seedpublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)