public class DataSet extends Object implements Iterable<DataObject>
DataObjects. 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
DataObjects 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 DataObjects in the code as a list of
the representation implemented for these. |
public DataSet(int nrOfDimensions)
nrOfDimensions - The dimension the DataObjects should have.praktikum.framework.data.InconsistentDimensionExceptionDataObjectpublic DataSet(DataObject newData)
DataSet is
given by the given DataObject.newData - The first DataObject added to the set.praktikum.framework.data.InconsistentDimensionExceptionDataObjectpublic 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.InconsistentDimensionExceptionDataObjectpublic void addObject(DataSet dataSet) throws Exception
dataSet - InconsistentDimensionExceptionExceptionaddObject(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.DataObjectpublic int size()
public int getNrOfDimensions()
DataSet. The DataSet
makes sure all objects have the same dimension.DataObjects in the DataSet.DataObjectpublic int getNrOfClasses()
public double[][] getFeaturesAsArray()
DataObjects.double[][] with the features. The first dimension is the feature
number, the second the values in the feature.DataObjectpublic DataObject[] getDataObjectArray()
DataObjects in the set. Use for speedy access when the labels
and/or the ids are also needed.DataObjects in the set.DataObjectpublic DataSet[] getDataSetsPerClass() throws Exception
Exceptionpublic double[] getVariances()
public Iterator<DataObject> iterator()
foreach loop over the DataObjects.
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>DataObjectpublic String toString()
String representation of all the DataObjects in the code as a list of
the representation implemented for these.toString in class ObjectString representation of all the elements in the set.DataObjectpublic void manipulateIds()
public void clear()
Copyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.