-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip clustering if k > n_topics #65
Open
scottgigante-immunai
wants to merge
8
commits into
dylkot:master
Choose a base branch
from
scottgigante-immunai:patch-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I get a `ValueError` if the number of topics after density filtering is less than the number of desired components.
If a single component is all zeroes (which can be the case now that k too large doesn't throw an exception), this introduces a div0 which turns the results into NaNs.
@dylkot would you please take a look and consider merging this PR? |
If density_threshold is too low, a very confusing error is raised: ``` Traceback (most recent call last): File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/utils/_param_validation.py", line 192, in wrapper return func(*args, **kwargs) File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/decomposition/_nmf.py", line 1106, in non_negative_factorization est._validate_params() File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/base.py", line 600, in _validate_params validate_parameter_constraints( File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/utils/_param_validation.py", line 97, in validate_parameter_constraints raise InvalidParameterError( sklearn.utils._param_validation.InvalidParameterError: The 'n_components' parameter of NMF must be an int in the range [1, inf) or None. Got 0 instead. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/cnmf/cnmf.py", line 739, in consensus rf_usages = self.refit_usage(norm_counts.X, median_spectra) File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/cnmf/cnmf.py", line 658, in refit_usage _, rf_usages = self._nmf(X, nmf_kwargs=refit_nmf_kwargs) File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/cnmf/cnmf.py", line 551, in _nmf (usages, spectra, niter) = non_negative_factorization(X, **nmf_kwargs) File "/Users/scottgigante/envs/immunaISR/lib/python3.8/site-packages/sklearn/utils/_param_validation.py", line 203, in wrapper raise InvalidParameterError(msg) from e sklearn.utils._param_validation.InvalidParameterError: The 'n_components' parameter of non_negative_factorization must be an int in the range [1, inf) or None. Got 0 instead. ``` This PR makes the error more comprehensible.
Skip clustering if k > n_topics
Raise error if zero components meet density threshold
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I get a
ValueError
if the number of topics after density filtering is less than the number of desired components.This PR solves that issue.