Skip to content

Commit a5e789f

Browse files
authored
Merge pull request #13 from krstopro/master
Add `_dtype` to clustering algorithms
2 parents cd30f12 + 0713f9c commit a5e789f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

unsupervised_bias_detection/clustering/_bahc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def fit(self, X, y):
3737
Fitted estimator.
3838
"""
3939
X, y = self._validate_data(
40-
X, y, reset=False, accept_large_sparse=False, dtype=[np.float32, np.float64], order="C"
40+
X, y, reset=False, accept_large_sparse=False, dtype=self._dtype, order="C"
4141
)
4242
n_samples, _ = X.shape
4343
# We start with all samples in a single cluster

unsupervised_bias_detection/clustering/_kmeans.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
from ._bahc import BiasAwareHierarchicalClustering
23
from sklearn.cluster import KMeans
34

@@ -41,6 +42,8 @@ class BiasAwareHierarchicalKMeans(BiasAwareHierarchicalClustering):
4142
array([ 10., -10.])
4243
"""
4344

45+
_dtype = [np.float32, np.float64]
46+
4447
def __init__(
4548
self,
4649
n_iter,

unsupervised_bias_detection/clustering/_kmodes.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class BiasAwareHierarchicalKModes(BiasAwareHierarchicalClustering):
4141
array([ 10., -10.])
4242
"""
4343

44+
_dtype = None
45+
4446
def __init__(self, n_iter, min_cluster_size, **kmodes_params):
4547
super().__init__(n_iter, min_cluster_size)
4648

0 commit comments

Comments
 (0)