Skip to content

Commit 577b78b

Browse files
committed
bug in rerank prob assign to sparse coo matrix
1 parent 89e981e commit 577b78b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/adila.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ def rerank(self, fpred, minorities, ratios, algorithm='det_greedy', k_max=100, a
165165

166166
else: raise ValueError('Invalid fair reranking algorithm!')
167167

168-
for j, expert_ in enumerate(experts_): preds_[i][expert_] = team_[j][2]
168+
for j, expert_ in enumerate(experts_):
169+
if not preds.is_sparse: preds_[i][expert_] = team_[j][2]
170+
else: #sparse coo is immutable, cannot assign/modify values as it changes sparsity pattern
171+
mask = (preds_.indices()[0] == i) & (preds_.indices()[1] == expert_) # within the k_max/topK nnz values
172+
preds_.values()[mask] = team_[j][2]
169173
# we switch the top-rank probs for top-re-ranked experts
170174
# this way both lists give correct top experts after final rankings for evaluation
171175
# example:

0 commit comments

Comments
 (0)