deeptime-ml / deeptime

Python library for analysis of time series data including dimensionality reduction, clustering, and Markov model estimation

Home Page:https://deeptime-ml.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TransitionCountModel.states_to_symbols incorrectly handles negative indices

MaaikeG opened this issue · comments

I have a dtraj where I am only interested in the samples from the largest connected set. All other samples should be assigned index -1.

I have a submodel of a transitioncountsmodel and use transform_discrete_trajectories_to_submodel, to assign -1 to all samples that don't belong in the connected set. Now I want to convert the new indices back to the original symbols, while preserving all -1 indices. However, the states_to_symbols assigns some incorrect index to the states indexed -1. The -1-states seem to be assigned the largest index of the connected set.

The following script reproduces the issue:

from deeptime.markov import TransitionCountEstimator
import numpy as np


estimator = TransitionCountEstimator(lagtime=1, count_mode='sliding')
dtrajs = np.asarray([[1,2,1,2,1,2,3], [4,5,4,4,5,5,4]])

counts = estimator.fit_fetch(dtrajs)

submodel = counts.submodel_largest(connectivity_threshold=1, directed=True)

restricted_dtraj = submodel.transform_discrete_trajectories_to_submodel(dtrajs)

print('items not in connected set are labelled -1:')
print(restricted_dtraj)

print('When converting back to symbols, states previously labelled with -1 are now given an incorrect index:')
for traj in restricted_dtraj:
    print(submodel.states_to_symbols(traj))

thanks!