scikit-adaptation / skada

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

Properly process `sample_weight` when using reweight adapters #90

Closed kachayev closed 5 months ago

kachayev commented 5 months ago

Covers both #89 and #7

Now, when we create a pipeline with the adapter that outputs sample_weight but the next estimator in the pipeline does not accept it, the following exception is thrown

E    skada.base.IncompatibleMetadataError: The adapter provided 'sample_weight' parameter which is not explicitly set as requested or not for 'LogisticRegression.fit'.
E    Make sure that metadata routing is properly setup, e.g. by calling 'set_fit_request()'. See documentation at https://scikit-learn.org/stable/metadata_routing.html

IncompatibleMetadataError overrides sklearn exception UnsetMetadataPassedError, when it's clear that the latter was caused by the incompatibility between adapter output and the parametrization of the estimator. All test cases are updated accordingly.

codecov[bot] commented 5 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (53a0b92) 88.04% compared to head (bb1095b) 88.54%.

Files Patch % Lines
skada/base.py 96.55% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #90 +/- ## ========================================== + Coverage 88.04% 88.54% +0.49% ========================================== Files 41 41 Lines 2576 2601 +25 ========================================== + Hits 2268 2303 +35 + Misses 308 298 -10 ```

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