Skip to content

[MRG] Ensure delegated ducktyping in MetaEstimators #2019

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

Closed
wants to merge 5 commits into from

Conversation

jnothman
Copy link
Member

This intends to solve #1805, ensuring that appropriate metaestimators have hasattr(metaest, method) == True iff the sub-estimator does for the set of standard methods: inverse_transform, transform, predict, predict_proba, predict_log_proba, decision_function, score.

I posted this as a WIP so that you can:

  • check the testing is reasonable;
  • confirm the set of methods is correct;
  • contribute patches to relevant estimators.

I currently take the approach of testing for attributes only after fitting. There may be problems if ducktyping is used before fitting on, say, a GridSearchCV, but I guess that's just something we'll have to be aware of when working with ducktyping.

I also am not currently dealing with metaestimators that delegate their fit methods. (I'm not sure if they exist, but I have considered some.)

(I have pulled in the relevant commit from #1769 and removed its Pipeline-particular testing.)

@jnothman
Copy link
Member Author

I have tests passing, fixing #1805 for:

  • Pipeline
  • GridSearchCV
  • RandomizedSearchCV
  • RFE
  • RFECV

I do not know of other implemented metaestimators where this type of ducktyping delegation should occur.

So please come forth and review!

@amueller
Copy link
Member

this needs further discussion before it can be merged. retagging 0.15 :(

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 159bb7b on jnothman:meta-ducktyping into 5319994 on scikit-learn:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants