covariance_order#
- tangles.util.matrix_order.covariance_order(adjacency_matrix: ndarray | spmatrix, feats: ndarray, shift: float = 0)#
Order function defined by the matrix \(A^T A\), where \(A\) is the adjacency matrix of a graph.
For a feature indicator vector \(f\) this function computes \(|f| = f^T A^T Af = (Af)^T Af\).
Parameters#
- adjacency_matrixnp.ndarray or sparse.spmatrix
A matrix with
seps.shape[0]
columns.- featsnp.ndarray
Matrix containing indicator vectors of features as columns.
- shiftfloat
This parameter changes the order function’s preference for balanced features (note: it might also have an effect on its sub- or supermodularity). Let \(c\) denote the value of shift. The order function computes the order by \(|f| = f^T (M + cJ) f\).
Returns#
- ordersnp.ndarray
1-dimensional np.ndarray of length
seps.shape[1]
containing the orders.