Skip to content

Commit

Permalink
Merge pull request #13 from krstopro/master
Browse files Browse the repository at this point in the history
Add `_dtype` to clustering algorithms
  • Loading branch information
krstopro authored Sep 16, 2024
2 parents cd30f12 + 0713f9c commit a5e789f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion unsupervised_bias_detection/clustering/_bahc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def fit(self, X, y):
Fitted estimator.
"""
X, y = self._validate_data(
X, y, reset=False, accept_large_sparse=False, dtype=[np.float32, np.float64], order="C"
X, y, reset=False, accept_large_sparse=False, dtype=self._dtype, order="C"
)
n_samples, _ = X.shape
# We start with all samples in a single cluster
Expand Down
3 changes: 3 additions & 0 deletions unsupervised_bias_detection/clustering/_kmeans.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
from ._bahc import BiasAwareHierarchicalClustering
from sklearn.cluster import KMeans

Expand Down Expand Up @@ -41,6 +42,8 @@ class BiasAwareHierarchicalKMeans(BiasAwareHierarchicalClustering):
array([ 10., -10.])
"""

_dtype = [np.float32, np.float64]

def __init__(
self,
n_iter,
Expand Down
2 changes: 2 additions & 0 deletions unsupervised_bias_detection/clustering/_kmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class BiasAwareHierarchicalKModes(BiasAwareHierarchicalClustering):
array([ 10., -10.])
"""

_dtype = None

def __init__(self, n_iter, min_cluster_size, **kmodes_params):
super().__init__(n_iter, min_cluster_size)

Expand Down

0 comments on commit a5e789f

Please sign in to comment.