phausamann / sklearn-xarray

Metadata-aware machine learning.
http://bit.do/sklearn-xarray
BSD 3-Clause "New" or "Revised" License
102 stars 12 forks source link

Replicate entire sklearn module structure #7

Open phausamann opened 6 years ago

phausamann commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.