ML-ENSEMBLE

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

mlens.estimators

BaseEstimator

class mlens.estimators.BaseEstimator[source]

Bases: mlens.parallel.wrapper.EstimatorMixin, mlens.parallel.base.ParamMixin, mlens.externals.sklearn.base.BaseEstimator

Base class for estimators

Ensure proper initialization of Mixins.

LearnerEstimator

class mlens.estimators.LearnerEstimator(estimator, indexer, verbose=False, scorer=None, backend=None, n_jobs=-1, dtype=None)[source]

Bases: mlens.estimators.estimators.BaseEstimator

Learner estimator

Wraps an estimator in a cross-validation strategy.

Parameters:
  • estimator (obj) – estimator to construct learner from.
  • indexer (str, obj) – a cross-validation strategy. Either a :mod`mlens.index` indexer instance or a string.
  • name (str, optional) – name of learner. If preprocessing is not None, the name of the transformer will be prepended. If not specified, the name of the learner will be the name of the estimator in lower case.
  • scorer (func, optional) – function to use for scoring predictions during cross-validated fitting.
  • verbose (bool, int (default = False)) – whether to report completed fits.
  • backend (str (default='threading')) – parallel backend. One of 'treading', 'multiprocessing' and 'sequential'.
  • n_jobs (int (default=-1)) – degree of concurrency. Set to -1 for maximum and 1 for sequential processing.

TransformerEstimator

class mlens.estimators.TransformerEstimator(preprocessing, indexer, verbose=False, backend=None, n_jobs=-1, dtype=None)[source]

Bases: mlens.estimators.estimators.BaseEstimator

Transformer estimator

Wraps an preprocessing pipeline in a cross-validation strategy.

Parameters:
  • preprocessing (obj) – preprocessing pipeline to construct transformer from.
  • indexer (str, obj) – a cross-validation strategy. Either a :mod`mlens.index` indexer instance or a string.
  • name (str) – name of transformer.
  • verbose (bool, int (default = False)) – whether to report completed fits.
  • backend (str (default='threading')) – parallel backend. One of 'treading', 'multiprocessing' and 'sequential'.
  • n_jobs (int (default=-1)) – degree of concurrency. Set to -1 for maximum and 1 for sequential processing.

LayerEnsemble

class mlens.estimators.LayerEnsemble(groups, propagate_features=None, shuffle=False, n_jobs=-1, backend=None, verbose=False, random_state=None, dtype=None)[source]

Bases: mlens.estimators.estimators.BaseEstimator

One-layer ensemble

An ensemble of estimators and preprocessing pipelines in one layer. Takes an input X and generates an output P. Assumes all preprocessing pipelines and all estimators are independent.

Parameters:
  • groups (list,) – list of Group instances to build layer with.
  • proba (bool (default = False)) – whether to call predict_proba on the estimators in the layer when predicting.
  • propagate_features (list, range, optional) – Features to propagate from the input array to the output array. Carries input features to the output of the layer, useful for propagating original data through several stacked layers. Propagated features are stored in the left-most columns.
  • verbose (int or bool (default = False)) –

    level of verbosity.

    • verbose = 0 silent (same as verbose = False)
    • verbose = 1 messages at start and finish (same as verbose = True)
    • verbose = 2 messages for preprocessing and estimators
    • verbose = 3 messages for completed job

    If verbose >= 10 prints to sys.stderr, else sys.stdout.

  • shuffle (bool (default = False)) – Whether to shuffle data before fitting layer.
  • random_state (obj, int, optional) – Random seed number to use for shuffling inputs
get_params(deep=True)[source]

Get parameters for this estimator. :param deep: If True, will return the parameters for this estimator and

contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
pop(idx)[source]

Pop group

Parameters:idx (int) – index of group to be popped in stack (0-based indexing). Equivalent to [group_0, group_1, …, group_n].pop(idx)
push(*groups)[source]

Push more groups onto stack

Parameters:*groups (objects) – Group instance(s) to push onto stack. Order is preserved (see pop).