add sklearn_tags - #833
Conversation
|
Super nit: the title of the PR should be Have a nice day |
|
Thanks for your effort in maintaining this library @solegalli. |
| FAILED_CHECKS_AOC.update( | ||
| { | ||
| "check_fit2d_1sample": msg1, | ||
| "check_parameters_default_constructible": msg2, | ||
| } | ||
| ) |
There was a problem hiding this comment.
Same here, maybe it is better to add the failing checks in here to have a more consistent API
There was a problem hiding this comment.
I don't understand :_(
more_tags imports from return_tags, which has the tests that all of our transformers fail. So in more_tags, I add tests that the transformer fails in addition to those in return_tags.
Maybe you could give me a code example of what you mean?
There was a problem hiding this comment.
Yes sure, sorry for not being clear before.
So let's take this for example.
Instead of adding the expected_failed_checks check_estimators_nan_inf in the test module, we could add to the BaseForecastTransformer class in here the following code:
tags_dict["_xfail_checks"][
"check_estimators_nan_inf"
] = "This estimator does not check for NaN or Infinity"This way we would keep all of the xfail_checks in one place instead of having check_methods_subset_invariance in the class tags and check_estimators_nan_inf in the test module.
Please let me know if it's still unclear, I can also submit a new MR with the change if that's easier for you.
There was a problem hiding this comment.
Oh, I see, thanks.
I thought briefly about that: in the longer term I imagine that we would get rid of _more_tags(), for example, when we stop supporting sklearn <1.6, so I thought it made more sense to specify the tests that fail in the test file, instead of making the transformers more dependent on _more_tags(). What's your view on this?
There was a problem hiding this comment.
Makes sense, thanks for the explanation.
Following your reasoning I also agree with your conclusion, this way you keep separate the checks that were introduced by sklearn 1.6 from the ones existing prior to sklearn 1.6.
On the other hand, if we were to end supporting sklearn < 1.6 we would have to move the failing checks that are currently in _more_tags() to the testing modules (or to some other class attributes). Having the information of exactly which check fails with each estimator all in one place would make it easier for the developer that will do the migration.
Ultimately, both options have pros and cons so I would leave the final decision to you :).
There was a problem hiding this comment.
I agree!
I prefer leaving code refactoring for a later stage, when we have a clearer view on whether we will continue with more_tags or deprecate.
Right now, the priority is to get feature-engine running with the latest release of sklearn as soon as possible, so that users can continue working.
* make transformation module compatible * Remove positive only tag from more_tags * Revert adding input tag positive only
* make time_series module compatible * fix typo * refactor test code
* make wrappers module compatible * Add missing new line * Sort imports in test file
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #833 +/- ##
==========================================
- Coverage 98.04% 98.03% -0.02%
==========================================
Files 111 111
Lines 4494 4623 +129
Branches 728 729 +1
==========================================
+ Hits 4406 4532 +126
- Misses 54 56 +2
- Partials 34 35 +1 ☔ View full report in Codecov by Sentry. |
|
All tests pass. We could leave the different version tests for a different pr #837 @ClaudioSalvatoreArcidiacono could you have a quick look at this PR when you have a minute? I think it's ready to be merged from my side. |
|
Yes sure, I will drop some suggestions |
| # In sklearn 1.6. the API changes break the tests for the target mean selector. | ||
| # We need to investigate further. | ||
| est = [ | ||
| DropFeatures(features_to_drop=["x0"]), | ||
| DropConstantFeatures(missing_values="ignore"), | ||
| DropDuplicateFeatures(), | ||
| DropCorrelatedFeatures(), | ||
| DropHighPSIFeatures(bins=5), | ||
| SmartCorrelatedSelection(), | ||
| SelectByShuffling(estimator=_logreg, scoring="accuracy"), | ||
| SelectBySingleFeaturePerformance(estimator=_logreg, scoring="accuracy"), | ||
| RecursiveFeatureAddition(estimator=_logreg, scoring="accuracy"), | ||
| RecursiveFeatureElimination( | ||
| estimator=_logreg, scoring="accuracy", threshold=-100 | ||
| ), | ||
| SelectByInformationValue(bins=2), | ||
| ProbeFeatureSelection(estimator=_logreg, scoring="accuracy"), | ||
| MRMR(regression=False), | ||
| ] | ||
|
|
||
| @pytest.mark.parametrize("estimator", est) | ||
| def test_check_estimator_from_sklearn(estimator): | ||
| failed_tests = estimator._more_tags()["_xfail_checks"] | ||
| return check_estimator(estimator=estimator, expected_failed_checks=failed_tests) |
There was a problem hiding this comment.
May I suggest to reuse the _estimators list defined above and to skip the tests for target mean selector, this way we avoid code duplication.
Co-authored-by: Claudio Salvatore Arcidiacono <22871978+ClaudioSalvatoreArcidiacono@users.noreply.github.com>
Co-authored-by: Claudio Salvatore Arcidiacono <22871978+ClaudioSalvatoreArcidiacono@users.noreply.github.com>
Co-authored-by: Claudio Salvatore Arcidiacono <22871978+ClaudioSalvatoreArcidiacono@users.noreply.github.com>
Co-authored-by: Claudio Salvatore Arcidiacono <22871978+ClaudioSalvatoreArcidiacono@users.noreply.github.com>
closes #831