public class DataSet
extends java.lang.Object
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
|
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(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.
|
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 |
setRandom(java.util.Random random)
Sets the random-number generator 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 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(Example example)
example
- the example to be addedpublic Attributes getAttributes()
public Examples getExamples()
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 setRandom(java.util.Random random)
random
- the random-number generatorpublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
args
- command-line arguments