Skip to content

Commit

Permalink
removed kmedoids gridsearch test
Browse files Browse the repository at this point in the history
  • Loading branch information
gegabo committed Sep 11, 2024
1 parent 12b325f commit 6492092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/mosaic/gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from sklearn.model_selection import GridSearchCV as SKGridSearchCV
from sklearn.pipeline import Pipeline

from mosaic._typing import FloatMax2DArray # noqa: WPS436
from mosaic.clustering import Clustering
from mosaic.similarity import Similarity
from mosaic._typing import FloatMax2DArray # noqa: WPS436


class GridSearchCV(SKGridSearchCV):
Expand Down Expand Up @@ -150,6 +150,7 @@ def __init__(
self.param_grid[
f'{self._clust_prefix}__{param}'
] = values
print('######################', self.param_grid)
else:
raise ValueError(
f"param_grid key '{param}' is not available."
Expand Down
13 changes: 3 additions & 10 deletions tests/test_gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
All rights reserved.
"""
import mosaic
import numpy as np
import pytest

import mosaic


def X():
"""Correlated coordinates."""
Expand All @@ -32,23 +31,17 @@ def X():

@pytest.mark.parametrize('params, clust_kwargs, X, best_index, error', [
({'resolution_parameter': np.linspace(0, 1, 7)}, {}, X(), 1, None),
(
{'n_clusters': np.arange(3, 30, 3)},
{'mode': 'kmedoids', 'n_clusters': 2},
X(),
3,
None,
),
({}, {}, X(), None, ValueError),
])
def test_GridSearchCV(params, clust_kwargs, X, best_index, error):
if not error:
print(mosaic.Similarity().fit_transform(X))
# print(mosaic.Similarity().fit_transform(X))
search = mosaic.GridSearchCV(
similarity=mosaic.Similarity(),
clustering=mosaic.Clustering(**clust_kwargs),
param_grid=params,
)
print(search.param_grid)
search.fit(X)
assert search.best_index_ == best_index
else:
Expand Down

0 comments on commit 6492092

Please sign in to comment.