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.
|
DataSet(java.lang.String[] options)
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 |
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(java.lang.String[] options)
options
- the options for this data setpublic DataSet(Attributes attributes)
attributes
- the attributes for this data setpublic void add(DataSet dataset)
dataset
- the data set to be addedpublic void add(Example example)
example
- the example to be addedpublic Attributes getAttributes()
public Examples getExamples()
public long getSeed()
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 parsing exception occursprivate void parse(java.util.Scanner scanner) throws java.lang.Exception
scanner
- a scanner containing the data set's tokensjava.lang.Exception
- if a parsing exception occurspublic void setOptions(java.lang.String[] options)
-s
sets the random seed for this data set.setOptions
in interface OptionHandler
options
- the argumentspublic 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)
args
- command-line arguments