InvertedData
in package
Stores a data matrix in an inverted index on columns with non-zero entries.
The index is just an array of entries <j, i, X[i][j]> sorted first by j and then by i, where all X[i][j] > 0. Provides a method to iterate over all rows which have a non-zero entry for a particular column (feature) j. There is no efficient way to iterate over rows in order.
Tags
Table of Contents
- $columns : int
- Number of columns in the matrix.
- $data : array<string|int, mixed>
- Array of non-zero matrix entries.
- $index : array<string|int, mixed>
- Array of offsets into the $data array, where each offset gives the start of the entries for a particular feature.
- $rows : int
- Number of rows in the matrix.
- __construct() : mixed
- Converts a SparseMatrix into an InvertedData instance. The data is duplicated.
- columns() : number
- Accessor method which the number of columns in the matrix
- iterateColumn() : object
- Returns an iterator over the values for a particular column of the matrix. If no matrix entry in the column is non-zero then an empty iterator is returned.
- iterateData() : object
- Returns an iterator over the entire matrix. Note that this iterator is not in row order, but effectively in column order.
- rows() : number
- Accessor method which the number of rows in the matrix
Properties
$columns
Number of columns in the matrix.
public
int
$columns
$data
Array of non-zero matrix entries.
public
array<string|int, mixed>
$data
$index
Array of offsets into the $data array, where each offset gives the start of the entries for a particular feature.
public
array<string|int, mixed>
$index
$rows
Number of rows in the matrix.
public
int
$rows
Methods
__construct()
Converts a SparseMatrix into an InvertedData instance. The data is duplicated.
public
__construct(object $X) : mixed
Parameters
- $X : object
-
SparseMatrix instance to convert
Return values
mixed —columns()
Accessor method which the number of columns in the matrix
public
columns() : number
Return values
number —of columns
iterateColumn()
Returns an iterator over the values for a particular column of the matrix. If no matrix entry in the column is non-zero then an empty iterator is returned.
public
iterateColumn(into $j) : object
Parameters
- $j : into
-
feature index (column) to iterate over
Return values
object —iterator over values in the column
iterateData()
Returns an iterator over the entire matrix. Note that this iterator is not in row order, but effectively in column order.
public
iterateData() : object
Return values
object —iterator over every non-zero entry in the matrix
rows()
Accessor method which the number of rows in the matrix
public
rows() : number
Return values
number —of rows