Giorgia Lotta
Giorgia Lotta

Reputation: 1

Using tsclust from dtwclust R library in Python. How do I access cluster?

I'm translating a R code to Python code and I need to implement a hierarchical time series clustering with dtw distance for time series of different lengths. The only solution that I find is to use the same library that I used in R (dtwclust, with tsclust) through rpy2 package of Python:

import rpy2
import rpy2.robjects.packages as rpackages
from rpy2.robjects.vectors import StrVector
from rpy2.robjects.packages import importr

from mRMRr import *
from datasets import *
import rpy2.robjects.packages as packages

packa = packages.importr('dtwclust')
Z = packa.tsclust(list_t_matrix_prof,type = "hierarchical", distance = "dtw_basic")

Now I have to access to the cluster assigned to each element and in R i can get this by Z@cluster. Can anyone tell me which is the corresponding command in Python?

Upvotes: 0

Views: 246

Answers (0)

Related Questions