[scikit-learn] Delegating "get_params" and "set_params" to a wrapped estimator when parameter is not defined.
Javier López
jlopez at ende.cc
Fri Apr 13 11:51:29 EDT 2018
I have a class `FancyEstimator(BaseEstimator, MetaEstimatorMixin): ...`
that wraps
around an arbitrary sklearn estimator to add some functionality I am
interested about.
This class contains an attribute `self.estimator` that contains the wrapped
estimator.
Delegation of the main methods, such as `fit`, `transform` works just fine,
but I am
having some issues with `get_params` and `set_params`.
The main idea is, I would like to use my wrapped class as a drop-in
replacement for
the original estimator, but this raises some issues with some functions
that try using the `get_params` and `set_params` straight in my class, as
the original
parameters now have prefixed names (for instance `estimator__verbose`
instead of `verbose`)
I would like to delegate calls of set_params and get_params in a smart way
so that if a
parameter is unknown for my wrapper class, then it automatically goes
looking for it in
the wrapped estimator.
I am not concerned about my class parameter names as there are only a
couple of very
specific names on it, so it is safe to assume that any unknown parameter
name should
refer to the base estimator. Is there an easy way of doing that?
Cheers,
J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20180413/f32ef910/attachment.html>
More information about the scikit-learn
mailing list