Skip to content

Commit 38cf14c

Browse files
fix: add compatibility with sklearn<=0.20
1 parent 3a82cf9 commit 38cf14c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modAL/batch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def select_cold_start_instance(X: modALinput,
3838
Best instance for cold-start.
3939
"""
4040
# Compute all pairwise distances in our unlabeled data and obtain the row-wise average for each of our records in X.
41+
n_jobs = n_jobs if n_jobs else 1
4142
average_distances = np.mean(pairwise_distances(X, metric=metric, n_jobs=n_jobs), axis=0)
4243

4344
# Isolate and return our best instance for labeling as the record with the least average distance.
@@ -88,7 +89,7 @@ def select_instance(
8889

8990
# Compute pairwise distance (and then similarity) scores from every unlabeled record
9091
# to every record in X_training. The result is an array of shape (n_samples, ).
91-
if n_jobs is None:
92+
if n_jobs == 1 or n_jobs is None:
9293
_, distance_scores = pairwise_distances_argmin_min(X_pool, X_training, metric=metric)
9394
else:
9495
distance_scores = pairwise_distances(X_pool[mask], X_training, metric=metric, n_jobs=n_jobs).min(axis=1)

0 commit comments

Comments
 (0)