[go: up one dir, main page]

Skip to content
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

Add Tangent Space Alignment #320

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

qbarthelemy
Copy link
Member
@qbarthelemy qbarthelemy commented Aug 24, 2024

Deep refacto of code shared in #319.

@qbarthelemy
Copy link
Member Author
qbarthelemy commented Sep 3, 2024

I decided to redo the TSA like the RPA, ie like a pipeline of transformers.
I created three new classes of transformers for transfer learning Tl in tangent space Ts :
TlTsCenter, TlTsNormalize and TlTsRotate.

I used prefix TlTs, to make the difference between
new transformations in tangent space: TlTsCenter, TlTsNormalize and TlTsRotate;
and already existing transformations in manifold : TLCenter, TLStretch and TLRotate.

To be coherent, we could change the prefix of transformations in manifold,
using TlMa to emphasize that transfer learning Tl is applied in the manifold Ma.
TLCenter would be deprecated and renamed into TlMaCenter,
TLStretch into TlMaStretch, and TLRotate into TlMaRotate.

Another solution, maybe better, is to have a single class TlRotate which makes the rotation in the manifold if the dimension of input is 3 (like TLRotate), and in the tangent space if dimension is 2 (like TlTsRotate). Same for TlCenter, and TlScale (grouping TLStretch and TlTsNormalize).

What do you think @agramfort , @sylvchev and @plcrodrigues ?

Documentation of TLDummy, TLEstimator, TLClassifier and TLRegressor have been updated to be compatible in both TL cases, in manifold (as before) and in tangent space.
They are deprecated and respectively renamed into TlDummy, TlEstimator, TlClassifier and TlRegressor

To be coherent, TSclassifier is deprecated and renamed into TsClassifier.

Copy link
Member
@plcrodrigues plcrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @qbarthelemy for this new feature on pyriemann (and sorry for the delay for the review).

The code and implementation of TSA looks good to me. Did you use the same code as the one provided by Alexandre Bleuzé? Maybe add a comment about it on the docstring?

I must admit that I would have preferred to keep the names of the classes with TL in caps at the beginning. And I find it a bit confusing to add Ts and Ma on the name of the class. Would it make sense (and doable) to always use the TLCenter class and have an option to say whether we're doing stuff on the manifold or the tangent space? (same thing for stretch and rotate). This would allow people to easily switch between operations and even create pipelines that start on manifold and finish on tangent space.

pyriemann/transfer/_estimators.py Outdated Show resolved Hide resolved
pyriemann/transfer/_estimators.py Outdated Show resolved Hide resolved
@qbarthelemy
Copy link
Member Author
qbarthelemy commented Oct 31, 2024

Thanks @plcrodrigues for your feedback. It's a good idea not to duplicate classes.

In the lastest version, there is a single class TlCenter which makes the centering in the manifold if the dimension of input is 3 (like TLCenter), or in the tangent space if dimension is 2 (like TlTsCenter).
Same for TlScale, merging TLStretch and TlTsNormalize; and for TlRotate, merging TLRotate and TlTsRotate.

I complete documentation.

Copy link
Member
@plcrodrigues plcrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to force the user to explicitly say whether he wants to do the centering (and stretching and rotation) on the manifold or the tangent space. Of course, the fit function can detect what kind of data is given depending of its dimensions, but I find the current implementation a bit too implicit and it could be annoying to debug or explain the code later. Why not instantiate the classes saying where the transformations are done?

Also, I still prefer calling things as TLCenter instead of TlCenter, etc. Since it is an acronym, it makes more sense to me to keep things with capital letters.

@qbarthelemy
Copy link
Member Author

Ok for me to keep prefix TL, instead of Tl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants