# Path: mlens/externals/sklearn/base.py
# class BaseEstimator(object):
#     """Base class for all estimators in scikit-learn
#     Notes
#     -----
#     All estimators should specify all the parameters that can be set
#     at the class level in their ``__init__`` as explicit keyword
#     arguments (no ``*args`` or ``**kwargs``).
#     """
# 
#     @classmethod
#     def _get_param_names(cls):
#         """Get parameter names for the estimator"""
#         # fetch the constructor or the original constructor before
#         # deprecation wrapping if any
#         init = getattr(cls.__init__, 'deprecated_original', cls.__init__)
#         if init is object.__init__:
#             # No explicit constructor to introspect
#             return []
# 
#         # introspect the constructor arguments to find the model parameters
#         # to represent
#         init_signature = signature(init)
#         # Consider the constructor parameters excluding 'self'
#         parameters = [p for p in init_signature.parameters.values()
#                       if p.name != 'self' and p.kind != p.VAR_KEYWORD]
#         for p in parameters:
#             if p.kind == p.VAR_POSITIONAL:
#                 raise RuntimeError("scikit-learn estimators should always "
#                                    "specify their parameters in the signature"
#                                    " of their __init__ (no varargs)."
#                                    " %s with constructor %s doesn't "
#                                    " follow this convention."
#                                    % (cls, init_signature))
#         # Extract and sort argument names excluding 'self'
#         return sorted([p.name for p in parameters])
# 
#     def get_params(self, deep=True):
#         """Get parameters for this estimator.
#         Parameters
#         ----------
#         deep : boolean, optional
#             If True, will return the parameters for this estimator and
#             contained subobjects that are estimators.
#         Returns
#         -------
#         params : mapping of string to any
#             Parameter names mapped to their values.
#         """
#         out = dict()
#         for key in self._get_param_names():
#             value = getattr(self, key, None)
#             if deep and hasattr(value, 'get_params'):
#                 deep_items = value.get_params().items()
#                 out.update((key + '__' + k, val) for k, val in deep_items)
#             out[key] = value
#         return out
# 
#     def set_params(self, **params):
#         """Set the parameters of this estimator.
#         The method works on simple estimators as well as on nested objects
#         (such as pipelines). The latter have parameters of the form
#         ``<component>__<parameter>`` so that it's possible to update each
#         component of a nested object.
#         Returns
#         -------
#         self
#         """
#         if not params:
#             # Simple optimization to gain speed (inspect is slow)
#             return self
#         valid_params = self.get_params(deep=True)
# 
#         nested_params = defaultdict(dict)  # grouped by prefix
#         for key, value in params.items():
#             key, delim, sub_key = key.partition('__')
#             if key not in valid_params:
#                 raise ValueError('Invalid parameter %s for estimator %s. '
#                                  'Check the list of available parameters '
#                                  'with `estimator.get_params().keys()`.' %
#                                  (key, self))
# 
#             if delim:
#                 nested_params[key][sub_key] = value
#             else:
#                 setattr(self, key, value)
#                 valid_params[key] = value
# 
#         for key, sub_params in nested_params.items():
#             valid_params[key].set_params(**sub_params)
# 
#         return self
# 
#     def __repr__(self):
#         class_name = self.__class__.__name__
#         return '%s(%s)' % (class_name, _pprint(self.get_params(deep=False),
#                                                offset=len(class_name),),)
# 
#     def __getstate__(self):
#         try:
#             state = super(BaseEstimator, self).__getstate__()
#         except AttributeError:
#             state = self.__dict__.copy()
# 
#         if type(self).__module__.startswith('sklearn.'):
#             return dict(state.items(), _sklearn_version=__version__)
#         else:
#             return state
# 
#     def __setstate__(self, state):
#         if type(self).__module__.startswith('sklearn.'):
#             pickle_version = state.pop("_sklearn_version", "pre-0.18")
#             if pickle_version != __version__:
#                 warnings.warn(
#                     "Trying to unpickle estimator {0} from version {1} when "
#                     "using version {2}. This might lead to breaking code or "
#                     "invalid results. Use at your own risk.".format(
#                         self.__class__.__name__, pickle_version, __version__),
#                     UserWarning)
#         try:
#             super(BaseEstimator, self).__setstate__(state)
#         except AttributeError:
#             self.__dict__.update(state)
# 
# class TransformerMixin(object):
#     """Mixin class for all transformers in scikit-learn."""
# 
#     def fit_transform(self, X, y=None, **fit_params):
#         """Fit to data, then transform it.
#         Fits transformer to X and y with optional parameters fit_params
#         and returns a transformed version of X.
#         Parameters
#         ----------
#         X : numpy array of shape [n_samples, n_features]
#             Training set.
#         y : numpy array of shape [n_samples]
#             Target values.
#         Returns
#         -------
#         X_new : numpy array of shape [n_samples, n_features_new]
#             Transformed array.
#         """
#         # non-optimized default implementation; override when a better
#         # method is possible for a given clustering algorithm
#         if y is None:
#             # fit method of arity 1 (unsupervised transformation)
#             return self.fit(X, **fit_params).transform(X)
#         else:
#             # fit method of arity 2 (supervised transformation)
#             return self.fit(X, y, **fit_params).transform(X)


from ..externals.sklearn.base import BaseEstimator, TransformerMixin
"""ML-ENSEMBLE

:author: Sebastian Flennerhag
:copyright: 2017-2018
:licence: MIT
"""

from __future__ import division, print_function




# Path: mlens/externals/sklearn/base.py
# class BaseEstimator(object):
#     """Base class for all estimators in scikit-learn
#     Notes
#     -----
#     All estimators should specify all the parameters that can be set
#     at the class level in their ``__init__`` as explicit keyword
#     arguments (no ``*args`` or ``**kwargs``).
#     """
# 
#     @classmethod
#     def _get_param_names(cls):
#         """Get parameter names for the estimator"""
#         # fetch the constructor or the original constructor before
#         # deprecation wrapping if any
#         init = getattr(cls.__init__, 'deprecated_original', cls.__init__)
#         if init is object.__init__:
#             # No explicit constructor to introspect
#             return []
# 
#         # introspect the constructor arguments to find the model parameters
#         # to represent
#         init_signature = signature(init)
#         # Consider the constructor parameters excluding 'self'
#         parameters = [p for p in init_signature.parameters.values()
#                       if p.name != 'self' and p.kind != p.VAR_KEYWORD]
#         for p in parameters:
#             if p.kind == p.VAR_POSITIONAL:
#                 raise RuntimeError("scikit-learn estimators should always "
#                                    "specify their parameters in the signature"
#                                    " of their __init__ (no varargs)."
#                                    " %s with constructor %s doesn't "
#                                    " follow this convention."
#                                    % (cls, init_signature))
#         # Extract and sort argument names excluding 'self'
#         return sorted([p.name for p in parameters])
# 
#     def get_params(self, deep=True):
#         """Get parameters for this estimator.
#         Parameters
#         ----------
#         deep : boolean, optional
#             If True, will return the parameters for this estimator and
#             contained subobjects that are estimators.
#         Returns
#         -------
#         params : mapping of string to any
#             Parameter names mapped to their values.
#         """
#         out = dict()
#         for key in self._get_param_names():
#             value = getattr(self, key, None)
#             if deep and hasattr(value, 'get_params'):
#                 deep_items = value.get_params().items()
#                 out.update((key + '__' + k, val) for k, val in deep_items)
#             out[key] = value
#         return out
# 
#     def set_params(self, **params):
#         """Set the parameters of this estimator.
#         The method works on simple estimators as well as on nested objects
#         (such as pipelines). The latter have parameters of the form
#         ``<component>__<parameter>`` so that it's possible to update each
#         component of a nested object.
#         Returns
#         -------
#         self
#         """
#         if not params:
#             # Simple optimization to gain speed (inspect is slow)
#             return self
#         valid_params = self.get_params(deep=True)
# 
#         nested_params = defaultdict(dict)  # grouped by prefix
#         for key, value in params.items():
#             key, delim, sub_key = key.partition('__')
#             if key not in valid_params:
#                 raise ValueError('Invalid parameter %s for estimator %s. '
#                                  'Check the list of available parameters '
#                                  'with `estimator.get_params().keys()`.' %
#                                  (key, self))
# 
#             if delim:
#                 nested_params[key][sub_key] = value
#             else:
#                 setattr(self, key, value)
#                 valid_params[key] = value
# 
#         for key, sub_params in nested_params.items():
#             valid_params[key].set_params(**sub_params)
# 
#         return self
# 
#     def __repr__(self):
#         class_name = self.__class__.__name__
#         return '%s(%s)' % (class_name, _pprint(self.get_params(deep=False),
#                                                offset=len(class_name),),)
# 
#     def __getstate__(self):
#         try:
#             state = super(BaseEstimator, self).__getstate__()
#         except AttributeError:
#             state = self.__dict__.copy()
# 
#         if type(self).__module__.startswith('sklearn.'):
#             return dict(state.items(), _sklearn_version=__version__)
#         else:
#             return state
# 
#     def __setstate__(self, state):
#         if type(self).__module__.startswith('sklearn.'):
#             pickle_version = state.pop("_sklearn_version", "pre-0.18")
#             if pickle_version != __version__:
#                 warnings.warn(
#                     "Trying to unpickle estimator {0} from version {1} when "
#                     "using version {2}. This might lead to breaking code or "
#                     "invalid results. Use at your own risk.".format(
#                         self.__class__.__name__, pickle_version, __version__),
#                     UserWarning)
#         try:
#             super(BaseEstimator, self).__setstate__(state)
#         except AttributeError:
#             self.__dict__.update(state)
# 
# class TransformerMixin(object):
#     """Mixin class for all transformers in scikit-learn."""
# 
#     def fit_transform(self, X, y=None, **fit_params):
#         """Fit to data, then transform it.
#         Fits transformer to X and y with optional parameters fit_params
#         and returns a transformed version of X.
#         Parameters
#         ----------
#         X : numpy array of shape [n_samples, n_features]
#             Training set.
#         y : numpy array of shape [n_samples]
#             Target values.
#         Returns
#         -------
#         X_new : numpy array of shape [n_samples, n_features_new]
#             Transformed array.
#         """
#         # non-optimized default implementation; override when a better
#         # method is possible for a given clustering algorithm
#         if y is None:
#             # fit method of arity 1 (unsupervised transformation)
#             return self.fit(X, **fit_params).transform(X)
#         else:
#             # fit method of arity 2 (supervised transformation)
#             return self.fit(X, y, **fit_params).transform(X)


# Path: mlens/preprocessing/preprocess.py
from ..externals.sklearn.base import BaseEstimator, TransformerMixin

"""ML-ENSEMBLE

:author: Sebastian Flennerhag
:copyright: 2017-2018
:licence: MIT
"""

from __future__ import division, print_function




class Subset(BaseEstimator, TransformerMixin):