Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8778f5

Browse files
committed
fix: correct best_instance_index in batch.select_instance
1 parent 452898f commit f8778f5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

modAL/batch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def select_instance(
101101
scores = alpha * (1 - similarity_scores) + (1 - alpha) * X_uncertainty[mask]
102102

103103
# Isolate and return our best instance for labeling as the one with the largest score.
104-
best_instance_index = np.argmax(scores)
104+
best_instance_index_in_unlabeled = np.argmax(scores)
105+
n_pool, _ = X_pool.shape
106+
unlabeled_indices = [i for i in range(n_pool) if mask[i]]
107+
best_instance_index = unlabeled_indices[best_instance_index_in_unlabeled]
105108
mask[best_instance_index] = 0
106109
return best_instance_index, X_pool[best_instance_index].reshape(1, -1), mask
107110

0 commit comments

Comments
 (0)