cNMF icon indicating copy to clipboard operation
cNMF copied to clipboard

Skip clustering if k > n_topics

Open scottgigante-immunai opened this issue 1 year ago • 1 comments

I get a ValueError if the number of topics after density filtering is less than the number of desired components.

Traceback (most recent call last):
  File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/cnmf/cnmf.py", line 727, in consensus
    kmeans_model.fit(l2_spectra)
  File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/cluster/_kmeans.py", line 1426, in fit
    self._check_params_vs_input(X)
  File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/cluster/_kmeans.py", line 1362, in _check_params_vs_input
    super()._check_params_vs_input(X, default_n_init=10)
  File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/cluster/_kmeans.py", line 859, in _check_params_vs_input
    raise ValueError(
ValueError: n_samples=19 should be >= n_clusters=41.

This PR solves that issue.

scottgigante-immunai avatar May 17 '23 21:05 scottgigante-immunai

@dylkot would you please take a look and consider merging this PR?

scottgigante-immunai avatar May 31 '23 17:05 scottgigante-immunai