我有2个scipy.sparse.csr_matrix
如下:
A = [ 1 0 1 0 0 1
1 0 0 1 0 0
0 1 0 0 0 0 ]
B = [ 1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0 ]
我愿意购买在B中出现但在A中没有的"新的"。
C = [ 0 0 0 0 1 0
0 1 0 0 0 0
1 0 1 0 0 0 ]
iUC应该非常简单:
In [98]: C = B - A
In [99]: C
Out[99]:
<3x6 sparse matrix of type '<class 'numpy.int32'>'
with 4 stored elements in Compressed Sparse Row format>
In [100]: C.A
Out[100]:
array([[0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0]], dtype=int32)