Package smile.data
Interface Dataset<D,T>
- Type Parameters:
D
- the data type.T
- the target type.
- All Superinterfaces:
Iterable<SampleInstance<D,
T>>
- All Known Subinterfaces:
BinarySparseDataset<T>
,SparseDataset<T>
An immutable collection of data objects.
-
Method Summary
Modifier and TypeMethodDescriptiondefault SampleInstance
<D, T> apply
(int i) Returns the index at the specified index.default Iterator
<List<SampleInstance<D, T>>> batch
(int size) Returns an iterator of mini-batches.static <D,
T> Collector <SampleInstance<D, T>, List<SampleInstance<D, T>>, Dataset<D, T>> Returns a stream collector that accumulates elements into a Dataset.get
(int i) Returns the instance at the specified index.default boolean
isEmpty()
Returns true if the dataset is empty.of
(D[] data, double[] target) Returns a default implementation of Dataset from a collection.of
(D[] data, float[] target) Returns a default implementation of Dataset from a collection.of
(D[] data, int[] target) Returns a default implementation of Dataset from a collection.static <D,
T> Dataset <D, T> of
(D[] data, T[] target) Returns a default implementation of Dataset from a collection.static <D,
T> Dataset <D, T> of
(Collection<SampleInstance<D, T>> instances) Returns a default implementation of Dataset from a collection.static <D,
T> Dataset <D, T> Returns a default implementation of Dataset from a collection.int
size()
Returns the number of elements in this collection.stream()
Returns a (possibly parallel) Stream with this collection as its source.default List
<SampleInstance<D, T>> toList()
Returns theList
of data items.default String
toString
(int numRows) Returns the string representation of the dataset.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Returns the number of elements in this collection.- Returns:
- the number of elements in this collection.
-
isEmpty
default boolean isEmpty()Returns true if the dataset is empty.- Returns:
- true if the dataset is empty.
-
get
Returns the instance at the specified index.- Parameters:
i
- the index of the instance to be returned.- Returns:
- the i-th instance.
-
apply
Returns the index at the specified index. For Scala's convenience.- Parameters:
i
- the index of the instance to be returned.- Returns:
- the i-th instance.
-
stream
Stream<SampleInstance<D,T>> stream()Returns a (possibly parallel) Stream with this collection as its source.- Returns:
- a (possibly parallel) Stream with this collection as its source.
-
batch
Returns an iterator of mini-batches.- Parameters:
size
- the batch size.- Returns:
- an iterator of mini-batches.
-
toList
Returns theList
of data items.- Returns:
- the
List
of data items.
-
toString
Returns the string representation of the dataset.- Parameters:
numRows
- the number of rows to show.- Returns:
- the string representation of the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.T
- the target type.- Parameters:
instances
- the sample instances.- Returns:
- the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.T
- the target type.- Parameters:
data
- the sample data.target
- the sample targets.- Returns:
- the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.T
- the target type.- Parameters:
data
- the sample data.target
- the sample targets.- Returns:
- the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.- Parameters:
data
- the sample data.target
- the sample targets.- Returns:
- the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.- Parameters:
data
- the sample data.target
- the sample targets.- Returns:
- the dataset.
-
of
Returns a default implementation of Dataset from a collection.- Type Parameters:
D
- the data type.- Parameters:
data
- the sample data.target
- the sample targets.- Returns:
- the dataset.
-
collector
Returns a stream collector that accumulates elements into a Dataset.- Type Parameters:
D
- the data type.T
- the target type.- Returns:
- the stream collector.
-