Package smile.data

Interface BinarySparseDataset<T>

Type Parameters:
T - the target type.
All Superinterfaces:
Dataset<int[],T>, Iterable<SampleInstance<int[],T>>

public interface BinarySparseDataset<T> extends Dataset<int[],T>
Binary sparse dataset. Each item is stored as an integer array, which are the indices of nonzero elements in ascending order.
  • Method Details

    • length

      int length()
      Returns the number of nonzero entries.
      Returns:
      the number of nonzero entries.
    • ncol

      int ncol()
      Returns the number of columns.
      Returns:
      the number of columns.
    • get

      default int get(int i, int j)
      Returns the binary value at entry (i, j) by binary search.
      Parameters:
      i - the row index.
      j - the column index.
      Returns:
      the binary value of cell.
    • toMatrix

      SparseMatrix toMatrix()
      Returns the Harwell-Boeing column-compressed sparse matrix.
      Returns:
      the sparse matrix.
    • of

      static <T> BinarySparseDataset<T> of(Collection<SampleInstance<int[],T>> data)
      Returns a default implementation of BinarySparseDataset.
      Type Parameters:
      T - the target type.
      Parameters:
      data - The sample instances.
      Returns:
      the sparse dataset.
    • of

      static BinarySparseDataset<Void> of(int[][] data)
      Returns a default implementation of BinarySparseDataset without targets.
      Parameters:
      data - Each row is a data item which are the indices of nonzero elements. Every row will be sorted into ascending order.
      Returns:
      the sparse dataset.
    • from

      Parse a binary sparse dataset from a file, of which each line is a data item which are the indices of nonzero elements.
      Parameters:
      path - the input file path.
      Returns:
      the sparse dataset.
      Throws:
      IOException - if stream to file cannot be read or closed.
      NumberFormatException - if an entry is not an integer.