Package smile.data
Interface BinarySparseDataset<T>
- Type Parameters:
T
- the target type.
- All Superinterfaces:
Dataset<int[],
,T> Iterable<SampleInstance<int[],
T>>
Binary sparse dataset. Each item is stored as an integer array, which
are the indices of nonzero elements in ascending order.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BinarySparseDataset
<Void> Parse a binary sparse dataset from a file, of which each line is a data item which are the indices of nonzero elements.default int
get
(int i, int j) Returns the binary value at entry (i, j) by binary search.int
length()
Returns the number of nonzero entries.int
ncol()
Returns the number of columns.static BinarySparseDataset
<Void> of
(int[][] data) Returns a default implementation of BinarySparseDataset without targets.static <T> BinarySparseDataset
<T> of
(Collection<SampleInstance<int[], T>> data) Returns a default implementation of BinarySparseDataset.toMatrix()
Returns the Harwell-Boeing column-compressed sparse matrix.Methods inherited from interface smile.data.Dataset
apply, batch, get, isEmpty, size, stream, toList, toString
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
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
Returns a default implementation of BinarySparseDataset.- Type Parameters:
T
- the target type.- Parameters:
data
- The sample instances.- Returns:
- the sparse dataset.
-
of
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.
-