ML-Ensemble
author: | Sebastian Flennerhag |
---|---|
copyright: | 2017-2018 |
licence: | MIT |
Auxiliary transformers to support computational graphs.
mlens.preprocessing¶
Subset¶
-
class
mlens.preprocessing.
Subset
(subset=None)[source]¶ Bases:
mlens.externals.sklearn.base.BaseEstimator
,mlens.externals.sklearn.base.TransformerMixin
Select a subset of features.
The
Subset
class acts as a transformer that reduces the feature set to a subset specified by the user.Parameters: subset (list) – list of columns indexes to select subset with. Indexes can either be of type str
if data accepts slicing on a list of strings, otherwise the list should be of typeint
.-
fit
(X, y=None)[source]¶ Learn what format the data is stored in.
Parameters: - X (array-like of shape = [n_samples, n_features]) – The whose type will be inferred.
- y (array-like of shape = [n_samples, n_features]) – pass-through for Scikit-learn pipeline compatibility.
-
transform
(X, y=None, copy=False)[source]¶ Return specified subset of X.
Parameters: - X (array-like of shape = [n_samples, n_features]) – The whose type will be inferred.
- y (array-like of shape = [n_samples, n_features]) – pass-through for Scikit-learn pipeline compatibility.
- copy (bool (default = None)) – whether to copy X before transforming.
-
Shift¶
-
class
mlens.preprocessing.
Shift
(s)[source]¶ Bases:
mlens.externals.sklearn.base.BaseEstimator
,mlens.externals.sklearn.base.TransformerMixin
Lag operator.
Shift an input array \(X\) with \(s\) steps, i.e. for some time series \(\mathbf{X} = (X_t, X_{t-1}, ..., X_{0})\),
\[L^{s} \mathbf{X} = (X_{t-s}, X_{t-1-s}, ..., X_{s - s})\]Parameters: s (int) – number of lags to generate Examples
>>> import numpy as np >>> from mlens.preprocessing import Shift >>> X = np.arange(10) >>> L = Shift(2) >>> Z = L.fit_transform(X) >>> print("X : {}".format(X[2:])) >>> print("Z : {}".format(Z)) X : [2 3 4 5 6 7 8 9] Z : [0 1 2 3 4 5 6 7]