def __init__(self, clustercenters, metric='euclidean', stride=1, n_jobs=None, skip=0): super(AssignCenters, self).__init__(metric=metric, n_jobs=n_jobs) if isinstance(clustercenters, str): from pyemma.coordinates.data import create_file_reader reader = create_file_reader(clustercenters, None, None) clustercenters = reader.get_output()[0] else: clustercenters = np.array(clustercenters, dtype=np.float32, order='C') # sanity check. if not clustercenters.ndim == 2: raise ValueError('cluster centers have to be 2d') self.set_params(clustercenters=clustercenters, metric=metric, stride=stride, skip=skip) # since we provided centers, no estimation is required. self._estimated = True
def __init__(self, clustercenters, metric='euclidean', stride=1, n_jobs=None, skip=0): r"""Assigns given (pre-calculated) cluster centers. If you already have cluster centers from somewhere, you use this class to assign your data to it. .. deprecated:: 2.5.11 Use the deeptime `ClusterModel <https://deeptime-ml.github.io/latest/api/generated/deeptime.clustering.ClusterModel.html>`__ and its `transform` method instead. Will be removed in PyEMMA 3. Parameters ---------- clustercenters : path to file (csv) or npyfile or ndarray cluster centers to use in assignment of data metric : str metric to use during clustering ('euclidean', 'minRMSD') stride : int stride n_jobs : int or None, default None Number of threads to use during assignment of the data. If None, all available CPUs will be used. skip : int, default=0 skip the first initial n frames per trajectory. Examples -------- Assuming you have stored your centers in a CSV file: >>> from pyemma.coordinates.clustering import AssignCenters >>> from pyemma.coordinates import pipeline >>> reader = ... # doctest: +SKIP >>> assign = AssignCenters('my_centers.dat') # doctest: +SKIP >>> disc = pipeline(reader, cluster=assign) # doctest: +SKIP >>> disc.parametrize() # doctest: +SKIP """ super(AssignCenters, self).__init__(metric=metric, n_jobs=n_jobs) if isinstance(clustercenters, str): from pyemma.coordinates.data import create_file_reader reader = create_file_reader(clustercenters, None, None) clustercenters = reader.get_output()[0] else: clustercenters = np.array(clustercenters, dtype=np.float32, order='C') # sanity check. if not clustercenters.ndim == 2: raise ValueError('cluster centers have to be 2d') self.set_params(clustercenters=clustercenters, metric=metric, stride=stride, skip=skip) # since we provided centers, no estimation is required. self._estimated = True
def __init__(self, clustercenters, metric='euclidean'): super(AssignCenters, self).__init__(metric=metric) if isinstance(clustercenters, six.string_types): from pyemma.coordinates.data import create_file_reader reader = create_file_reader(clustercenters, None, None) self._clustercenters = reader.get_output()[0] else: self._clustercenters = np.array(clustercenters, dtype=np.float32, order='C') # sanity check. if not self.clustercenters.ndim == 2: raise ValueError('cluster centers have to be 2d') # since we provided centers, this transformer is already parametrized. self._parametrized = True