Skip to content

Commit

Permalink
Merge pull request #265 from VlachosGroup/sklearn-compat-patch
Browse files Browse the repository at this point in the history
Update clustering.py for compatibility with latest sklearn
  • Loading branch information
JacksonBurns authored Jan 23, 2024
2 parents d815423 + 475e4d5 commit 45a978e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aimsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from . import chemical_datastructures
from . import utils

__version__ = "2.1.1"
__version__ = "2.1.2"
21 changes: 15 additions & 6 deletions aimsim/ops/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,21 @@ def _get_kmedoids_model_(self, **kwargs):

def _get_linkage_model(self, linkage_method, **kwargs):
_ = kwargs.pop('affinity', None)
return AgglomerativeClustering(
n_clusters=self.n_clusters,
affinity="precomputed",
linkage=linkage_method,
**kwargs
)
try:
return AgglomerativeClustering(
n_clusters=self.n_clusters,
affinity="precomputed",
linkage=linkage_method,
**kwargs
)
except TypeError:
# different kwargs in sklearn versions
return AgglomerativeClustering(
n_clusters=self.n_clusters,
metric="precomputed",
linkage=linkage_method,
**kwargs
)

def fit(self, X):
"""Fit the estimator.
Expand Down

0 comments on commit 45a978e

Please sign in to comment.