-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MRG, API: Deprecate max_pca_components #8351
Conversation
Okay this is ready for review/merge from my end |
Travis failure is an unrelated conda-forge python 3.9-related bug that's hitting all PRs/branches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoechenberger and @cbrnr you might want to review and test this branch before it gets merged
what should n_pca_components=3, n_components=1. mean?
should break. you cannot limit the number of PCA components and require all
the variance to be explained
for ICA.
|
It depends on if you're talking about wanting the |
(It certainly breaks more tests, but those are quick enough to fix) |
Wait, are we really distinguishing |
Yes float and int are different, I can add a test that
This is the default as |
If we're re-thinking these questions from scratch anyway, I'd prefer if I cannot really imagine anyone would want a fraction of a fraction? |
I believe this would lead to a cleaner API, yes. Good idea. |
What if I do want to select just one component? |
Is that an actual use case or just a theoretical consideration? |
It's theoretical, but I'm pretty sure someone will want to use it for a good reason. Also, it is a pretty unusual behavior to treat |
But ok, allowing 1 as int probably won't hurt anyone either.. |
If both 1 and 1.0 do they same thing, then yes. |
Can you open a separate issue about this? Let's solve it and discuss it elsewhere |
but using 1 component for ICA does not make sense it should not be allowed
anyway
… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- docs updated
- killed 1. (float) and 1 (int) to be safe
- updated behavior of
n_components=None
(see inline comment) - made
n_components
float value operate on total explained variance, not relative ton_pca_components
mne/preprocessing/ica.py
Outdated
- ``None`` | ||
``n_pca_components`` or ``0.999999`` will be used, whichever | ||
results in fewer components. This is done to avoid numerical | ||
stability problems when whitening. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important change/fix I think. The defaults of n_pca_components=None
and n_components=None
are still dangerous for rank-reduced data. This makes our defaults safe for rank-reduced data.
To be consistent with sklearn: "If 0 < n_components < 1 and svd_solver == 'full', select the number of components such that the amount of variance that needs to be explained is greater than the percentage specified by n_components" For floats you generally shouldn't rely on equivalence anyway so this is really in practice a tiny (hopefully meaningless in practice) distinction here anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal to make the docs a little easier to understand, otherwise looks super great and good to merge!
@cbrnr Would be great to get your feedback / approval too before merging. Thanks! |
Friendly ping @cbrnr |
I'll take a look within the next hour or so! |
Great, thank you |
Where can I find the updated rendered ICA diagram? |
The doc artifact is at https://22659-1301584-gh.circle-artifacts.com/0/dev/index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I've tested this with one of my current data sets, and everything seems to work as before.
I have one comment that we could also discuss in a separate issue, but I wanted to bring it up here. Do we really need n_pca_components
in ICA.__init__
? As far as I can see, this parameter is neither used during initialization nor fitting. It is used in ICA.apply
, which also has an n_pca_components
parameter, which when set overrides the value passed in the initializer (I think). Wouldn't our API be much cleaner and easier to understand if we dropped n_pca_components
from __init__
and just kept it in apply
? Or am I missing something and we actually need to pass it when constructing the ICA
object? Again, we don't have to discuss this here, so feel free to merge this PR and discuss this in a separate issue.
You're absolutely right, it's only used during But happy to open this discussion again! |
Thanks a bunch, @larsoner! |
This must have been the PR that closed the most issues at once! Thanks @larsoner! |
Absolutely. I like how I kept opening issues and @larsoner would come along closing them. How convenient 💪 |
* API: Deprecate max_pca_components * FIX: Flake * FIX: Test * FIX: Fix viz tests * FIX: Test * ENH: Warn and doc * FIX: Exp var and 1. and 1 * STY: Update docs [skip travis] [skip github] * TST: Faster test * DOC: Better docs [ci skip] * Apply suggestions from code review [skip travis] * Fix docstring [skip travis] Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
@larsoner any chance we can backport this? It contains a nice fix in If it's too big of a change for a backport that's OK, it's not that I can't just install |
Although of course just because of this I'm running into the issue that scikit-learn has not been released for Python 3.9 yet, so generating the wheel myself takes ages. |
we do not backport API changes.
we should push a new MNE release in early 2021?
… |
Yes, if we do not have to stick to a 6 month release cycle I'd be happy if the next one was a bit sooner. |
point taken :)
… |
Yes, can we cut a new release in December already? These ICA changes are really… important. Also lots of @drammock's viz changes are a real game changer already! |
if we have the bandwidth I am all for it !
… |
Todo:
max_pca_components
test_ica.py
workingn_pca_components
toplot_ica_overlay
plot_40_artifact_correction_ica.py
n_components
leads to unstable pseudoinversiondoc/_static/diagrams/ica.dot
n_components
as float selects based on the variance remaining of then_pca_components
components. This is howmax_pca_components
worked (it was relative to that)Closes #8337
Closes #8342
Closes #8327
Closes #8328
Closes #8316
Closes #8313
Closes #7727
Closes #8353