Skip to content

Commit b85fbab

Browse files
committed
Fix ref_index of OptiSim
1 parent 282d6e3 commit b85fbab

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

selector/methods/distance.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __init__(
278278
eps=0,
279279
p=2,
280280
random_seed=42,
281-
ref_index=None,
281+
ref_index=0,
282282
fun_dist=None,
283283
):
284284
"""
@@ -312,13 +312,13 @@ def __init__(
312312
Seed for random selection of points be evaluated.
313313
ref_index: int, list, optional
314314
Index of the reference sample to start the selection algorithm from.
315-
It can be an integer, or a list of integers or None. When None, the medoid center is chosen as the reference
316-
sample.
317-
When the `ref_index` is a list for multiple classes, it will be shared among all clusters.
318-
If we want to use different reference indices for each class, we can perform the subset
319-
selection for each class separately where different `ref_index` parameters can be used.
320-
For example, if we have two classes, we can pass `ref_index=[0, 1]` to select samples
321-
from class 0 and `ref_index=[3, 6]` class 1 respectively.
315+
It can be an integer, or a list of integers.
316+
When the `ref_index` is a list for multiple classes, it will be shared among all
317+
clusters. If we want to use different reference indices for each class, we can perform
318+
the subset selection for each class separately where different `ref_index` parameters
319+
can be used. For example, if we have two classes, we can pass `ref_index=[0, 1]` to
320+
select samples from class 0 and `ref_index=[3, 6]` class 1 respectively.
321+
Default is [0].
322322
fun_dist : callable, optional
323323
Function for calculating the pairwise distance between sample points to be used in
324324
calculating the medoid. `fun_dist(x) -> x_dist` takes a 2D feature array of shape
@@ -354,7 +354,7 @@ def algorithm(self, x, max_size) -> Union[List, Iterable]:
354354
"""
355355
# set up reference index
356356
selected = get_initial_selection(x=x, x_dist=None, ref_index=self.ref_index, fun_dist=None)
357-
count = 1
357+
count = len(selected)
358358

359359
# establish a kd-tree for nearest-neighbor lookup
360360
tree = spatial.KDTree(x)
@@ -475,9 +475,10 @@ def __init__(self, r0=None, ref_index=None, tol=0.05, n_iter=10, p=2.0, eps=0.0,
475475
Initial guess for radius of the exclusion sphere.
476476
ref_index: int, list, optional
477477
Index of the reference sample to start the selection algorithm from.
478-
It can be an integer, or a list of integers or None. When None, the medoid center is chosen as the reference
479-
sample.
480-
When the `ref_index` is a list for multiple classes, it will be shared among all clusters.
478+
It can be an integer, or a list of integers or None. When None, the medoid center is
479+
chosen as the reference sample.
480+
When the `ref_index` is a list for multiple classes,
481+
it will be shared among all clusters.
481482
If we want to use different reference indices for each class, we can perform the subset
482483
selection for each class separately where different `ref_index` parameters can be used.
483484
For example, if we have two classes, we can pass `ref_index=[0, 1]` to select samples

0 commit comments

Comments
 (0)