scikit-adaptation / skada

Domain adaptation toolbox compatible with scikit-learn and pytorch
https://scikit-adaptation.github.io/
BSD 3-Clause "New" or "Revised" License
60 stars 16 forks source link

[MRG] Add KMM method + example #94

Closed antoinedemathelin closed 7 months ago

antoinedemathelin commented 7 months ago

Hi everyone, I open this PR to propose an implementation of the KMM method from the paper https://proceedings.neurips.cc/paper_files/paper/2006/file/a2186aa7c086b46ad4e8bf81e2a3a19b-Paper.pdf as suggested in issue #82.

KMM has the particularity to directly learn the source weights corresponding to the source data Xs given in fit. In the adapt method, I follow the same idea as for OT. The source data matrix are stored in an attribute X_source_, then, in the adapt method, we compare the given X[src_idx] with Xsource (cf. OT1), if both are equal, we return the weights learned in fit. If not, we return the weight of the closest neighbor in Xsource, as done for OT mapping, cf. OT2 (note that we use the kernel function to find the closest neighbor).

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.07%. Comparing base (9e7905d) to head (ac08382).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #94 +/- ## ========================================== + Coverage 89.58% 90.07% +0.48% ========================================== Files 41 41 Lines 2852 2981 +129 ========================================== + Hits 2555 2685 +130 + Misses 297 296 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

antoinedemathelin commented 7 months ago

Hi everyone, I added a qp_solve function to factorize the qp solver. I need to create specific test for it, I think. @rflamary I added the smooth_weights parameter as we discussed.

antoinedemathelin commented 7 months ago

Hi @rflamary, I added the tests for the QP solver, similar to the cvxopt example https://cvxopt.org/examples/tutorial/qp.html The example now shows the decision boundary for smooth weight True or False