Package smile.data

Class SimpleDataset<D,T>

java.lang.Object
smile.data.SimpleDataset<D,T>
Type Parameters:
D - the data type.
T - the target type.
All Implemented Interfaces:
Iterable<SampleInstance<D,T>>, Dataset<D,T>
Direct Known Subclasses:
BinarySparseDataset, BinarySparseSequenceDataset, SparseDataset

public class SimpleDataset<D,T> extends Object implements Dataset<D,T>
A simple implementation of Dataset that store data in single machine's memory.
  • Constructor Details

    • SimpleDataset

      public SimpleDataset(Collection<SampleInstance<D,T>> instances)
      Constructor
      Parameters:
      instances - The sample instances.
  • Method Details

    • size

      public int size()
      Description copied from interface: Dataset
      Returns the number of elements in this collection.
      Specified by:
      size in interface Dataset<D,T>
      Returns:
      the number of elements in this collection.
    • get

      public SampleInstance<D,T> get(int i)
      Description copied from interface: Dataset
      Returns the instance at the specified index.
      Specified by:
      get in interface Dataset<D,T>
      Parameters:
      i - the index of the instance to be returned.
      Returns:
      the i-th instance.
    • stream

      public Stream<SampleInstance<D,T>> stream()
      Description copied from interface: Dataset
      Returns a (possibly parallel) Stream with this collection as its source.
      Specified by:
      stream in interface Dataset<D,T>
      Returns:
      a (possibly parallel) Stream with this collection as its source.
    • iterator

      @Nonnull public Iterator<SampleInstance<D,T>> iterator()
      Specified by:
      iterator in interface Iterable<D>
    • toList

      public List<SampleInstance<D,T>> toList()
      Description copied from interface: Dataset
      Returns the List of data items.
      Specified by:
      toList in interface Dataset<D,T>
      Returns:
      the List of data items.