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>
Binary sparse dataset. Each item is stored as an integer array, which
are the indices of nonzero elements in ascending order.
-
Constructor Summary
Constructors -
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.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.toMatrix()
Returns the Harwell-Boeing column-compressed sparse matrix.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BinarySparseDataset
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
Returns the Harwell-Boeing column-compressed sparse matrix.- Returns:
- the sparse matrix.
-
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.
-