E - the type of data objects.public class Dataset<E> extends java.lang.Object implements java.lang.Iterable<Datum<E>>
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Datum<E>> |
data
The data objects.
|
protected static java.lang.String |
DATASET_HAS_NO_RESPONSE |
protected java.lang.String |
description
The optional detailed description of dataset.
|
protected java.lang.String |
name
The name of dataset.
|
protected Attribute |
response
The attribute property of response variable.
|
protected static java.lang.String |
RESPONSE_NOT_NOMINAL |
protected static java.lang.String |
RESPONSE_NOT_NUMERIC |
| Constructor and Description |
|---|
Dataset()
Constructor.
|
Dataset(Attribute response)
Constructor.
|
Dataset(java.lang.String name)
Constructor.
|
Dataset(java.lang.String name,
Attribute response)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Datum<E> |
add(Datum<E> x)
Add a datum item into the dataset.
|
Datum<E> |
add(E x)
Add a datum item into the dataset.
|
Datum<E> |
add(E x,
double y)
Add a datum item into the dataset.
|
Datum<E> |
add(E x,
double y,
double weight)
Add a datum item into the dataset.
|
Datum<E> |
add(E x,
int y)
Add a datum item into the dataset.
|
Datum<E> |
add(E x,
int y,
double weight)
Add a datum item into the dataset.
|
java.util.List<Datum<E>> |
data()
Returns the data set.
|
Datum<E> |
get(int i)
Returns the element at the specified position in this dataset.
|
java.lang.String |
getDescription()
Returns the detailed dataset description.
|
java.lang.String |
getName()
Returns the dataset name.
|
java.util.Iterator<Datum<E>> |
iterator()
Returns an iterator over the elements in this dataset in proper sequence.
|
int[] |
labels()
Returns the class labels.
|
Datum<E> |
remove(int i)
Removes the element at the specified position in this dataset.
|
AttributeVector |
response()
Returns the response attribute vector.
|
Attribute |
responseAttribute()
Returns the attribute of the response variable.
|
void |
setDescription(java.lang.String description)
Sets the detailed dataset description.
|
void |
setName(java.lang.String name)
Sets the dataset name.
|
int |
size()
Returns the size of dataset.
|
double[] |
toArray(double[] a)
Returns an array containing the response variable of the elements in this
dataset in proper sequence (from first to last element).
|
E[] |
toArray(E[] a)
Returns an array containing all of the elements in this dataset in
proper sequence (from first to last element); the runtime type of the
returned array is that of the specified array.
|
int[] |
toArray(int[] a)
Returns an array containing the class labels of the elements in this
dataset in proper sequence (from first to last element).
|
java.lang.String[] |
toArray(java.lang.String[] a)
Returns an array containing the string names of the elements in this
dataset in proper sequence (from first to last element).
|
java.sql.Timestamp[] |
toArray(java.sql.Timestamp[] a)
Returns an array containing the timestamps of the elements in this
dataset in proper sequence (from first to last element).
|
double[] |
y()
Returns the response values.
|
protected static final java.lang.String DATASET_HAS_NO_RESPONSE
protected static final java.lang.String RESPONSE_NOT_NOMINAL
protected static final java.lang.String RESPONSE_NOT_NUMERIC
protected java.lang.String name
protected java.lang.String description
protected Attribute response
public Dataset()
public Dataset(java.lang.String name)
name - the name of dataset.public Dataset(Attribute response)
response - the attribute type of response variable.public Dataset(java.lang.String name,
Attribute response)
name - the name of dataset.response - the attribute type of response variable.public java.lang.String getName()
public void setName(java.lang.String name)
public void setDescription(java.lang.String description)
public java.lang.String getDescription()
public Attribute responseAttribute()
public AttributeVector response()
public int size()
public Datum<E> add(Datum<E> x)
x - a datum item.public Datum<E> add(E x)
x - a datum item.public Datum<E> add(E x, int y)
x - a datum item.y - the class label of the datum.public Datum<E> add(E x, int y, double weight)
x - a datum item.y - the class label of the datum.weight - the weight of datum. The particular meaning of weight
depends on applications and machine learning algorithms.
Although there are on explicit requirements on the weights,
in general, they should be positive.public Datum<E> add(E x, double y)
x - a datum item.y - the real-valued response for regression.public Datum<E> add(E x, double y, double weight)
x - a datum item.weight - the weight of datum. The particular meaning of weight
depends on applications and machine learning algorithms.
Although there are on explicit requirements on the weights,
in general, they should be positive.public Datum<E> remove(int i)
i - the index of the element to be removed.public Datum<E> get(int i)
i - the index of the element to be returned.public java.util.Iterator<Datum<E>> iterator()
public double[] y()
public int[] labels()
public E[] toArray(E[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to null.
a - the array into which the elements of this dataset are to be
stored, if it is big enough; otherwise, a new array of the same runtime
type is allocated for this purpose.public int[] toArray(int[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Integer.MIN_VALUE.
a - the array into which the class labels of this dataset are to be
stored, if it is big enough; otherwise, a new array is allocated for
this purpose.public double[] toArray(double[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Double.NaN.
a - the array into which the response variable of this dataset are
to be stored, if it is big enough; otherwise, a new array is allocated
for this purpose.public java.lang.String[] toArray(java.lang.String[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to null.
a - the array into which the string names of the elements in this
dataset are to be stored, if it is big enough; otherwise, a new array
is allocated for this purpose.public java.sql.Timestamp[] toArray(java.sql.Timestamp[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to null.
a - the array into which the timestamps of the elements in this
dataset are to be stored, if it is big enough; otherwise, a new array
is allocated for this purpose.