public class DataSet extends Object implements Iterable<DataObject>
DataObject
s. Internally it uses an ArrayList<DataObject>
so it is recommended to use with care. For speedy operations
after the data is collected use getFeaturesAsArray()
. When access speed is not a factor
the iterator can be used to go through the data with a foreach
loop.getFeaturesAsArray()
Constructor and Description |
---|
DataSet(DataObject newData)
Creates a Set with only the given object.
|
DataSet(int nrOfDimensions)
Creates an empty set.
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(DataObject newData)
Adds a
DataObject to the set. |
void |
addObject(DataSet dataSet)
Adds all objects in the given data set
|
void |
clear() |
DataObject[] |
getDataObjectArray()
Returns an array of all the
DataObject s in the set. |
DataSet[] |
getDataSetsPerClass()
Separates the objects in this data set according to their class label
|
double[][] |
getFeaturesAsArray()
Returns an array with all the features of all the objects in the set.
|
int |
getNrOfClasses()
Counts the number of classes that are present in the data set.
|
int |
getNrOfDimensions()
Return the dimension of the objects in the
DataSet . |
DataObject |
getObject(int index)
Returns the
DataObject at the given position. |
double[] |
getVariances()
Calculates the variance of this data set for each dimension
|
Iterator<DataObject> |
iterator()
An iterator for the set.
|
void |
manipulateIds()
resets the ids, so that the set contains ids from 0 to noOfObjects-1
|
int |
size()
Returns the size of the set.
|
String |
toString()
Returns a
String representation of all the DataObject s in the code as a list of
the representation implemented for these. |
public DataSet(int nrOfDimensions)
nrOfDimensions
- The dimension the DataObject
s should have.praktikum.framework.data.InconsistentDimensionException
DataObject
public DataSet(DataObject newData)
DataSet
is
given by the given DataObject
.newData
- The first DataObject
added to the set.praktikum.framework.data.InconsistentDimensionException
DataObject
public void addObject(DataObject newData)
DataObject
to the set.newData
- The DataObject
to be added.praktikum.framework.data.InconsistentDimensionException
- This Exception
is thrown
when the dimension of the object to be added does not fit the rest.praktikum.framework.data.InconsistentDimensionException
DataObject
public void addObject(DataSet dataSet) throws Exception
dataSet
- InconsistentDimensionException
Exception
addObject(DataObject newData)
public DataObject getObject(int index)
DataObject
at the given position. Use with care.
For speedy operations after the data is collected use getFeaturesAsArray()
.index
- The index position that is to be returned.DataObeject
at the given position.DataObject
public int size()
public int getNrOfDimensions()
DataSet
. The DataSet
makes sure all objects have the same dimension.DataObjects
in the DataSet
.DataObject
public int getNrOfClasses()
public double[][] getFeaturesAsArray()
DataObject
s.double[][]
with the features. The first dimension is the feature
number, the second the values in the feature.DataObject
public DataObject[] getDataObjectArray()
DataObject
s in the set. Use for speedy access when the labels
and/or the ids are also needed.DataObject
s in the set.DataObject
public DataSet[] getDataSetsPerClass() throws Exception
Exception
public double[] getVariances()
public Iterator<DataObject> iterator()
foreach
loop over the DataObject
s.
This is a nice way of going through the data, but when the access speed is relevant its use
is not recommended.iterator
in interface Iterable<DataObject>
DataObject
public String toString()
String
representation of all the DataObject
s in the code as a list of
the representation implemented for these.toString
in class Object
String
representation of all the elements in the set.DataObject
public void manipulateIds()
public void clear()
Copyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.