Skip to content

Commit c052f1a

Browse files
Krsto ProrokovićKrsto Proroković
authored andcommitted
Add margin
1 parent a7ac50c commit c052f1a

File tree

1 file changed

+3
-1
lines changed
  • unsupervised_bias_detection/cluster

1 file changed

+3
-1
lines changed

unsupervised_bias_detection/cluster/_bahc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ def __init__(
2929
clustering_cls: Type[ClusterMixin],
3030
bahc_max_iter: int,
3131
bahc_min_cluster_size: int,
32+
margin: float = 1e-5,
3233
**clustering_params: Any,
3334
):
3435
self.clustering_cls = clustering_cls
3536
self.bahc_max_iter = bahc_max_iter
3637
self.bahc_min_cluster_size = bahc_min_cluster_size
38+
self.margin = margin
3739
self.clustering_params = clustering_params
3840

3941
def fit(self, X, y):
@@ -112,7 +114,7 @@ def fit(self, X, y):
112114
complement_mask[child_indices] = False
113115
y_complement = y[complement_mask]
114116
child_score = np.mean(y_complement) - np.mean(y_cluster)
115-
if child_score >= score:
117+
if child_score >= score + self.margin:
116118
valid_split = True
117119
child_scores.append(child_score)
118120

0 commit comments

Comments
 (0)