public class SparseDoubleMatrixReader extends DoubleMatrixReader
log
Constructor and Description |
---|
SparseDoubleMatrixReader() |
Modifier and Type | Method and Description |
---|---|
DoubleMatrix<String,String> |
read(InputStream stream)
Read a sparse matrix that is expressed as an adjacency list in a tab-delimited file:
item1 item2 weight
item1 item5 weight
By definition the resulting matrix is square and symmetric.
|
DoubleMatrix<String,String> |
read(InputStream stream,
Collection<String> wantedRowNames) |
DoubleMatrix<String,String> |
read(InputStream stream,
Collection<String> wantedRowNames,
boolean createEmptyRows,
int skipColumns,
int maxRows) |
DoubleMatrix<String,String> |
readJW(InputStream stream)
Read a sparse matrix in "JW" (Jason Weston) format.
|
createEmptyRow, createMatrix, read, read, read, read, read
readHeader
public DoubleMatrix<String,String> read(InputStream stream) throws IOException
item1 item2 weight item1 item5 weight
By definition the resulting matrix is square and symmetric.
Note that the ordering of the items will be as they are encountered in the file.
read
in class DoubleMatrixReader
stream
- InputStreamIOException
public DoubleMatrix<String,String> read(InputStream stream, Collection<String> wantedRowNames)
read
in class DoubleMatrixReader
stream
- InputStreamwantedRowNames
- Setread( stream, wantedRowNames, createEmptyRows )
with createEmptyRows
set to
true.public DoubleMatrix<String,String> read(InputStream stream, Collection<String> wantedRowNames, boolean createEmptyRows, int skipColumns, int maxRows)
read
in class DoubleMatrixReader
stream
- InputStreamwantedRowNames
- SetcreateEmptyRows
- if a row contained in wantedRowNames
is not found in the file, create an
empty row filled with Double.NaN iff this param is true.public DoubleMatrix<String,String> readJW(InputStream stream) throws IOException
2 <--- number of items - the first line of the file only. NOTE - this line is often blank or not present. 1 2 <--- items 1 has 2 edges 1 2 <--- edge indices are to items 1 & 2 0.1 100 <--- with the following weights 2 2 <--- items 2 also has 2 edges 1 2 <--- edge indices are also to items 1 & 2 (fully connected) 100 0.1 <--- with the following weights
Note that the item numbering starts at 1. This is a requirement.
Note that this cannot handle very large matrices - the limit to rows x columns is the number Integer.MAX_VALUE. This is an implementation problem for colt's sparse matrix.
stream
- wantedRowNames
- IOException
Copyright © 2003–2022 UBC Michael Smith Laboratories. All rights reserved.