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
Schaefer-Strimmer shrinkage covariance estimator #59
Conversation
… initialized on one of the point of the set, generating zero-divide error.
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
==========================================
+ Coverage 98.09% 98.63% +0.54%
==========================================
Files 18 18
Lines 1311 1322 +11
==========================================
+ Hits 1286 1304 +18
+ Misses 25 18 -7
Continue to review full report at Codecov.
|
Very nice ! In practice, do you observe a difference in performances ? It would be great if you can add an example with the 3 different shrinkage estimator. |
Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
or better use a RandomState instance :)
please avoid setting the global seed
… |
Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com>
Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com>
Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com>
Code ok for me! Good job Sylvain! |
Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
Thx @sylvchev |
* rewriting base file to get ride of numpy matrices. * last modification to rewrite into full numpy integration * rewriting mean with dotted notation and getting rid of numpy matrices * continuing to rewrite the geodesic * rewriting of the spatial filters * small style correction in channelselection * updating the use of numpy for all higher packages * last rewriting of pyriemann file * adding slack notification * finishing to update numpy ref and removing numpy matrices * covering all functions of classification: TSclassifier, kNN * PEP8 conformation for test clustering * PEP 8 normalisation * fixing last bugs for testing * update test * adding test for Potato * end of modification of test units and coverage improvment. * modifying and adapting travis file. * updating travis file and correcting error in testing wasserstein mean * adding pandas in the requierement for Travis * ajout de la generation de matrice SPD * Correcting the Karcher mean implementation if the gradient descent is initialized on one of the point of the set, generating zero-divide error. * adding ALM to mean computation * adding ref for the parametrized geodesic * update avant merge * uncomplete merge * merge with upstream * use fixture and parametrize for tests, avoid code redundancy, systematic test of dist and metric * correct tangent fit bug Co-authored-by: kjersbry <noreply@github.com> Co-authored-by: sylvchev <noreply@github.com> * add tsupdate check * reduce complexity of the test to make them faster * add flake8 to tests and examples, correct style in tests * switch to triangular inequality to avoid random failure * update coverage * remove redundant tests, add coverage * correct flake8 * correct F401,F811 import errors with fixtures * correct w value * remove assert_array_equal and correct variable names Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * add is_spsd and get_labels fixture * adding test for Schaefer estimator * update test for spatial filters Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * correct var name for inverse transform * use get_labels fixture * correct flake8 * add is_psd and is_semi_psd * add independence test for fit/transform * correct zeros -> empty * Schaefer-Strimmer shrinkage covariance estimator (#59) * rewriting base file to get ride of numpy matrices. * last modification to rewrite into full numpy integration * rewriting mean with dotted notation and getting rid of numpy matrices * continuing to rewrite the geodesic * rewriting of the spatial filters * small style correction in channelselection * updating the use of numpy for all higher packages * last rewriting of pyriemann file * adding slack notification * finishing to update numpy ref and removing numpy matrices * covering all functions of classification: TSclassifier, kNN * PEP8 conformation for test clustering * PEP 8 normalisation * fixing last bugs for testing * update test * adding test for Potato * end of modification of test units and coverage improvment. * modifying and adapting travis file. * updating travis file and correcting error in testing wasserstein mean * adding pandas in the requierement for Travis * ajout de la generation de matrice SPD * Correcting the Karcher mean implementation if the gradient descent is initialized on one of the point of the set, generating zero-divide error. * adding ALM to mean computation * adding ref for the parametrized geodesic * update avant merge * adding computation and test of Schaefer-Strimmer covariance estimator * replacing loops with algebra * adding an example * correcting plots * uncomplete merge * pep8 * update test for tangent space * correct docstring and bug * converting notebook into py file * correct style * rewrite plots, reduce computation time * update link and rename variables * correct style * correct plot layout * adding Schaefer-Strimmer in whatsnew * update test, docstring and docs from suggestions Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * improve tests for covariance * keep the same color for each estimator across figures * correct example text Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * raise error for covariance_EP and initialize RandomState in example * correct import order * Apply suggestions from code review Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * sort import, correct spd Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * switch zeros to np.empty Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * add doc * rebase on master * correct tangent fit bug Co-authored-by: kjersbry <noreply@github.com> Co-authored-by: sylvchev <noreply@github.com> * add tsupdate check * reduce complexity of the test to make them faster * add flake8 to tests and examples, correct style in tests * switch to triangular inequality to avoid random failure * update coverage * remove redundant tests, add coverage * correct flake8 * correct F401,F811 import errors with fixtures * correct w value * add is_spsd and get_labels fixture * remove assert_array_equal and correct variable names Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * adding test for Schaefer estimator * correct var name for inverse transform * update test for spatial filters Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * use get_labels fixture * correct flake8 * add is_psd and is_semi_psd * add independence test for fit/transform * correct zeros -> empty * define is_spd/is_spsd fixtures * clean code * updating whats new Co-authored-by: kjersbry <noreply@github.com> Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
A PR to merge the code of Schaefer-Strimmer covariance estimator [1]. This shrinkage estimator is not implemented in scikit-learn, but is useful to estimate covariance matrices from a limited number of samples.
There is a python implementation already available, see https://github.com/rmcgibbo/covar/, but it relies on Cython and thus does not seem to fit well with the pyRiemann scope. The code of this PR is in pure Python.
[1] Schafer, J., and K. Strimmer. 2005. A shrinkage approach to large-scale covariance estimation and implications for functional genomics. Statist. Appl. Genet. Mol. Biol. 4:32.
http://doi.org/10.2202/1544-6115.1175