Package smile.data

Class BinarySparseDataset<T>

java.lang.Object
smile.data.SimpleDataset<int[],T>
smile.data.BinarySparseDataset<T>
Type Parameters:
T - the target type.
All Implemented Interfaces:
Iterable<SampleInstance<int[],T>>, Dataset<int[],T>

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

    • BinarySparseDataset

      public BinarySparseDataset(Collection<SampleInstance<int[],T>> data)
      Constructor.
      Parameters:
      data - The sample instances.
  • Method Details

    • length

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

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

      public 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

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

      public 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

      public static BinarySparseDataset<Void> from(Path path) throws IOException, NumberFormatException
      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.