liana.utils.neg_to_zero#
- liana.utils.neg_to_zero(X, cutoff=0)#
Set negative values to 0.
- Parameters:
- Return type:
csr_matrix- Returns:
The modified data matrix
Examples
>>> x = np.array([-1, -0.5, 0.1, 0.4, 2]) >>> print(neg_to_zero(x)) <Compressed Sparse Row sparse matrix of dtype 'float64' with 5 stored elements and shape (1, 5)> Coords Values (0, 0) 0.0 (0, 1) 0.0 (0, 2) 0.1 (0, 3) 0.4 (0, 4) 2.0 >>> print(neg_to_zero(x, cutoff=0.5)) <Compressed Sparse Row sparse matrix of dtype 'float64' with 5 stored elements and shape (1, 5)> Coords Values (0, 0) 0.0 (0, 1) 0.0 (0, 2) 0.0 (0, 3) 0.0 (0, 4) 2.0