Class DataSet
- java.lang.Object
-
- DataSet
-
public class DataSet extends java.lang.ObjectImplements a class for a data set for machine-learning methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected Attributesattributesthe attributes of this data setprotected Examplesexamplesthe examples of this data setprotected java.lang.Stringnamethe name of this data setprotected java.util.Randomrandoma random-number generator
-
Constructor Summary
Constructors Constructor Description DataSet()Default constructor.DataSet(Attributes attributes)Explicit constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Example example)Adds the specified example to this data set.AttributesgetAttributes()Gets the attributes of this DataSet object.ExamplesgetExamples()Gets the examples of this data set.booleangetHasNumericAttributes()Returns true if this data set has numeric attributes; returns false otherwise.voidload(java.lang.String filename)Loads a data set from the specified file.private voidparse(java.util.Scanner scanner)Parses a data set using the tokens in the specified scanner, which consists of@dataset<identifier> <attributes> <examples>.voidsetRandom(java.util.Random random)Sets the random-number generator for this data set.java.lang.StringtoString()Returns a string representation of the data set in a format identical to that of the file format.
-
-
-
Field Detail
-
name
protected java.lang.String name
the name of this data set
-
attributes
protected Attributes attributes
the attributes of this data set
-
examples
protected Examples examples
the examples of this data set
-
random
protected java.util.Random random
a random-number generator
-
-
Constructor Detail
-
DataSet
public DataSet()
Default constructor.
-
DataSet
public DataSet(Attributes attributes)
Explicit constructor.- Parameters:
attributes- the attributes for this data set
-
-
Method Detail
-
add
public void add(Example example)
Adds the specified example to this data set.- Parameters:
example- the example to be added
-
getAttributes
public Attributes getAttributes()
Gets the attributes of this DataSet object.- Returns:
- the attributes of this data set
-
getExamples
public Examples getExamples()
Gets the examples of this data set.- Returns:
- the examples of this data set
-
getHasNumericAttributes
public boolean getHasNumericAttributes()
Returns true if this data set has numeric attributes; returns false otherwise.- Returns:
- true if this data set has numeric attributes
-
load
public void load(java.lang.String filename) throws java.lang.ExceptionLoads a data set from the specified file.- Parameters:
filename- the file from which to read- Throws:
java.lang.Exception- if the file is not found or if a parsing exception occurs
-
parse
private void parse(java.util.Scanner scanner) throws java.lang.ExceptionParses a data set using the tokens in the specified scanner, which consists of@dataset<identifier> <attributes> <examples>.- Parameters:
scanner- a scanner containing the data set's tokens- Throws:
java.lang.Exception- if a parsing exception occurs
-
setRandom
public void setRandom(java.util.Random random)
Sets the random-number generator for this data set.- Parameters:
random- the random-number generator
-
toString
public java.lang.String toString()
Returns a string representation of the data set in a format identical to that of the file format.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string containing data set
-
-