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>

public interface Dataset<D,T> extends Iterable<SampleInstance<D,T>>
An immutable collection of data objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    default SampleInstance<D,T>
    apply(int i)
    Returns the index at the specified index.
    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
    Returns true if the dataset is empty.
    static <D> Dataset<D,Double>
    of(D[] data, double[] target)
    Returns a default implementation of Dataset from a collection.
    static <D> Dataset<D,Float>
    of(D[] data, float[] target)
    Returns a default implementation of Dataset from a collection.
    static <D> Dataset<D,Integer>
    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>
    of(List<D> data, List<T> target)
    Returns a default implementation of Dataset from a collection.
    int
    Returns the number of elements in this collection.
    Returns a (possibly parallel) Stream with this collection as its source.
    Returns the List 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

      SampleInstance<D,T> get(int i)
      Returns the instance at the specified index.
      Parameters:
      i - the index of the instance to be returned.
      Returns:
      the i-th instance.
    • apply

      default SampleInstance<D,T> apply(int i)
      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

      default Iterator<List<SampleInstance<D,T>>> batch(int size)
      Returns an iterator of mini-batches.
      Parameters:
      size - the batch size.
      Returns:
      an iterator of mini-batches.
    • toList

      default List<SampleInstance<D,T>> toList()
      Returns the List of data items.
      Returns:
      the List of data items.
    • toString

      default String toString(int numRows)
      Returns the string representation of the dataset.
      Parameters:
      numRows - the number of rows to show.
      Returns:
      the string representation of the dataset.
    • of

      static <D, T> Dataset<D,T> of(Collection<SampleInstance<D,T>> instances)
      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

      static <D, T> Dataset<D,T> of(List<D> data, List<T> target)
      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

      static <D, T> Dataset<D,T> of(D[] data, T[] target)
      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

      static <D> Dataset<D,Integer> of(D[] data, int[] target)
      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

      static <D> Dataset<D,Float> of(D[] data, float[] target)
      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

      static <D> Dataset<D,Double> of(D[] data, double[] target)
      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

      static <D, T> Collector<SampleInstance<D,T>,List<SampleInstance<D,T>>,Dataset<D,T>> 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.