scikit-learn/scikit-learn — pull request #2854 by jnothman (2014-02-12 10:02:00+00:00)
Title: [MRG] Ensure delegated ducktyping in MetaEstimators

Supersedes #2019, with a more readable (?) reimplementation, and an extension of the test to fix #2853.

This patch ensures that `GridSearchCV`, `RandomizedSearchCV`, `Pipeline`, `RFE` and `RFECV` 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` (with some exceptions where delegation doesn't apply).

To fix #2853, `hasattr` must be True before the metaestimator is `fit`, and if the delegating method is called before fit, an exception will be raised, as with other un-fit estimators.