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

[MRG] Modification source_target_merge function behaviours #71

Merged
merged 26 commits into from
Feb 20, 2024

Conversation

YanisLalou
Copy link
Collaborator

@YanisLalou YanisLalou commented Feb 2, 2024

Issue: #61
Change the name of source_target_merge
Allow an N dimension array as an input for source_target_merge
Add test cases

For source_target_merge:

  • Sample domain input should be optional
  • Y_target can be equal to None (check there's only one None given in all pairs)
  • X_source/target can be list of arrays, check all sizes are coherent

@YanisLalou YanisLalou changed the title source_target_merge accepts now N dimenstion array + name change + te… [TO_REVIEW] Modification source_target_merge function behaviours Feb 2, 2024
@YanisLalou YanisLalou changed the title [TO_REVIEW] Modification source_target_merge function behaviours [WIP] Modification source_target_merge function behaviours Feb 2, 2024
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (52b63b0) 88.54% compared to head (4445f07) 88.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   88.54%   88.83%   +0.29%     
==========================================
  Files          41       41              
  Lines        2601     2678      +77     
==========================================
+ Hits         2303     2379      +76     
- Misses        298      299       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@YanisLalou YanisLalou changed the title [WIP] Modification source_target_merge function behaviours [TO_REVIEW] Modification source_target_merge function behaviours Feb 2, 2024
@@ -243,3 +243,56 @@ def source_target_split(
return list(chain.from_iterable(
(a[source_idx], a[~source_idx]) for a in arrays
))


def source_target_merge(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should match split API: accept as many pairs of 'things' as necessary, alongside with a named argument 'sample_domain'.

So I can do something like

X, y = source_target_merge(X_source, X_target, y_source, y_target, sample_domain=sample_domain)

Copy link
Collaborator

@rflamary rflamary Feb 5, 2024

Choose a reason for hiding this comment

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

Do you mean :

X, y, sample_domain = source_target_merge(X_source, X_target, y_source, y_target, sample_domain)

insterad?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In source_target_split() we don't output back the sample domain, just the splitted arrays. Makes sense to do the same here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, as we have this function to pair up with the split functionality, we shouldn't encourage swapping sample_domain to a new one, even though it's technically possible (it would mean that we have to return it with every operation). Moreover, it might easily lead to 'accidental' loss of the information when having multiple sources/targets.

@YanisLalou YanisLalou changed the title [TO_REVIEW] Modification source_target_merge function behaviours [WIP] Modification source_target_merge function behaviours Feb 5, 2024
@YanisLalou
Copy link
Collaborator Author

For now source_target_merge() accepts an even number of arrays as input + the sample domain array.
It works by considering the arrays by duo (the first one is considered as the source and the second the target).
Thus I'm wondering:

  • if it would be better to accept the duos as tuples rather than directly in the *arrays.
  • Don't know if the doc is clear enough

Would love your feedbacks

@kachayev
Copy link
Collaborator

kachayev commented Feb 7, 2024

Regarding pairs, you are right, it might be better with pairs. But it's common to have pairs of ndarrays as an input type... So it might also be a bit confusing. Let's keep the current implementation to see how it works in practice. We will be able to change it if necessary.

@kachayev
Copy link
Collaborator

kachayev commented Feb 8, 2024

@YanisLalou is this one ready for review?

@YanisLalou
Copy link
Collaborator Author

@YanisLalou is this one ready for review?

Almost, there's one codevoc test that I still need to implement + check if I've managed to handle all possible cases.
But otherwise yes you can start reviewing it + if you find any edge cases that I didn't foreseen, that would really help me

@YanisLalou YanisLalou changed the title [WIP] Modification source_target_merge function behaviours [TO_REVIEW] Modification source_target_merge function behaviours Feb 19, 2024
@YanisLalou YanisLalou requested a review from kachayev February 19, 2024 08:33
Copy link
Collaborator

@kachayev kachayev left a comment

Choose a reason for hiding this comment

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

Overall comment, let's replace 'duo' with 'pair'. I mentioned it multiple times in different places in the code but certainly not everywhere.

@YanisLalou YanisLalou requested a review from kachayev February 20, 2024 08:37
Copy link
Collaborator

@kachayev kachayev left a comment

Choose a reason for hiding this comment

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

Great work, @YanisLalou!

@kachayev kachayev merged commit c50867e into scikit-adaptation:main Feb 20, 2024
7 checks passed
@kachayev kachayev changed the title [TO_REVIEW] Modification source_target_merge function behaviours [MRG] Modification source_target_merge function behaviours Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants