Skip to content

Commit

Permalink
Merge pull request #25 from marscher/add_vamp
Browse files Browse the repository at this point in the history
Add VAMP, CKTests (MSM and VAMP)
  • Loading branch information
marscher committed Sep 24, 2019
2 parents 955a3c9 + 7cc8380 commit 071108c
Show file tree
Hide file tree
Showing 20 changed files with 1,945 additions and 536 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- checkout
- run: conda config --add channels conda-forge
- run: conda config --set always_yes true
- run: conda config --set channel_priority strict
- run: conda config --set quiet true
- run: conda install conda-build conda-verify -c defaults
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
Expand Down
20 changes: 18 additions & 2 deletions sktime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from sklearn.base import _pprint as pprint_sklearn


class _base_methods_mixin(object):
class _base_methods_mixin(object, metaclass=abc.ABCMeta):
""" defines common methods used by both Estimator and Model classes.
"""

def __repr__(self):
name = '{cls}-{id}:'.format(id=id(self), cls=self.__class__.__name__)
Expand Down Expand Up @@ -89,10 +91,19 @@ def copy(self):
class Estimator(_base_methods_mixin):

def __init__(self, model=None):
self._model = model if model is not None else self._create_model()
# we only need to create a default model in case the subclassing Estimator provides the partial_fit interface.
if hasattr(self.__class__, 'partial_fit') and model is None:
self._model = self._create_model()
# TODO: not tested (e.g. by partially fitted models.
elif model is not None:
self._model = model

@abc.abstractmethod
def fit(self, data):
""" performs a fit of this estimator with data. Creates a new model instance by default.
:param data:
:return: self
"""
pass

def fetch_model(self) -> Model:
Expand All @@ -102,6 +113,11 @@ def fetch_model(self) -> Model:
def _create_model(self):
pass

def __getattribute__(self, item):
if item == 'fit':
self._model = self._create_model()
return super(_base_methods_mixin, self).__getattribute__(item)


class Transformer(object):

Expand Down
10 changes: 5 additions & 5 deletions sktime/decomposition/tica.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,19 @@ class TICA(Estimator, Transformer):
"""
def __init__(self, lagtime, epsilon=1e-6, reversible=True, dim=0.95,
scaling='kinetic_map', ncov=5):
super(TICA, self).__init__()
# tica parameters
self._model.epsilon = epsilon
self._model.dim = dim
self._model.scaling = scaling
self.epsilon = epsilon
self.dim = dim
self.scaling = scaling

# online cov parameters
self.reversible = reversible
self._covar = OnlineCovariance(lagtime=lagtime, compute_c00=True, compute_c0t=True, compute_ctt=False, remove_data_mean=True,
reversible=self.reversible, bessels_correction=False, ncov=ncov)
super(TICA, self).__init__()

def _create_model(self) -> TICAModel:
return TICAModel()
return TICAModel(scaling=self.scaling, dim=self.dim, epsilon=self.epsilon)

def transform(self, data):
r"""Projects the data onto the dominant independent components.
Expand Down

0 comments on commit 071108c

Please sign in to comment.