bugfix: Set requires_fit tag to False for all stateless estimators#1390
bugfix: Set requires_fit tag to False for all stateless estimators#1390reevesc7 wants to merge 5 commits intoEpistasisLab:mainfrom
requires_fit tag to False for all stateless estimators#1390Conversation
|
While trolling through TPOT's code, I noticed that other estimator classes have I looked into scikit-learn's conventions for fitting determination as well, and found that the recommended approach for stateless estimators is to set the The scikit-learn 1.6 release highlights state that estimators should set tags by overriding As such, I have now reverted the changes I made to I also added I have validated that my overload of |
Passthrough, SkipTransformerrequires_fit tag to False for all stateless estimators
What does this PR do?
This PR adds the following line to
Passthrough.fit()andSkipTransformer.fit():It also alters the docstring for each function to reflect the new behavior.
Where should the reviewer start?
tpot/builtin_modules/passthrough.py:Passthrough.fit()SkipTransformer.fit()How should this PR be tested?
The following script produces the issue described below:
When run before the patch, TPOT raises a "No individuals could be evaluated in the initial population...." exception, with each individual raising the following exception:
After the patch, fitting should complete successfully.
Notably, the above script only tests
Passthrough.I personally have only run into this issue while using
Passthrough, as I have not usedSkipTransformer.However, I infer that it would cause the same problem and that this solution will not cause any issues.
Any background context you want to provide?
As is,
Passthrough.fit()andSkipTransformer.fit()do not set any properties which indicate to scikit-learn that the object is fitted.scikit-learn checks whether objects are fitted by identifying properties which end in
_and do not start with__.To determine whether a pipeline is fitted, scikit-learn checks whether each component of the pipeline has such properties.
Passthrough.fit()andSkipTransformer.fit()merely returnself, failing to adhere to scikit-learn's fitting convention.This causes an exception when
Passthroughis a step in aDynamicLinearPipelinewhich is a step in aSequentialPipeline.However, I believe it does not cause an exception when a
Passthroughis merely included as a step in aSequentialPipeline.I have not investigated other cases.
What are the relevant issues?
None that I found with a brief search.
Questions: