sklearn-xarray icon indicating copy to clipboard operation
sklearn-xarray copied to clipboard

Replicate entire sklearn module structure

Open phausamann opened this issue 6 years ago • 2 comments

For easier usage, the package should replicate all sklearn estimators in their respective modules by decorating them with a generalized EstimatorWrapper.

Users could then use all sklearn estimators just by modifying their import statements, for example:

from sklearn_xarray.decomposition import PCA

which would yield an xarray-compatible PCA estimator.

phausamann avatar Dec 04 '17 10:12 phausamann

On second thought, class decorators seem like a bad idea, mostly because the resulting object is not pickleable. It makes more sense for each estimator to subclass the corresponding wrapper, like

class PCA(TransformerWrapper):
    def __init__(self, **fit_params):
        super(self, PCA).__init__(sklearn.decomposition.PCA, **fit_params)

and provide the full parameter list instead of **fit_params

phausamann avatar Dec 12 '17 06:12 phausamann

The benefit of this approach would be that each estimator could inherit the methods it needs from the corresponding mixin, e.g.:

class PCA(_CommonEstimatorWrapper, _ImplementsTransformMixin, _ImplementsScoreMixin)

In some cases, the class could also implement wrappers for 'exotic' methods that might not warrant a dedicated mixin to be written for them.

phausamann avatar Jan 12 '18 07:01 phausamann