質問は非常に単純です。scipyスパース行列M(100,000X500,000)から特定の行rがあり、M行列でその位置/インデックスを見つけたいとしましょう。どうすればこれを効率的に達成できますか?
現在、私は次の方法を試していますが、それはひどく遅いです。
offset = 500
begin = 0
end = begin + offset
row = row.todense() #convert sparse to dense
while 1:
sub_M = M[begin:end,:].todense() #M matrix is too big that its dense cannot fit memory
labels=np.all(row == sub_M, axis=1) # here we find row in the sub set of M, but in a dense representation
begin = end
end = end + offset
if (end - offset) == M.shape[0]:
break
elif end > M.shape[0]:
end = M.shape[0]