필터 지우기
필터 지우기

Clustering Time Series with DTW multiple column(time series) different lengths

조회 수: 43 (최근 30일)
Amila
Amila 2023년 3월 10일
댓글: Amila 2023년 3월 20일
Please kindly hellp me !!!
I have data in a timetable format (TT)
I wanted to use DTW (Dynamic Time Warping) to cluster data into 3 categories without removing NaN raws;
can someone help me, please
please consider the starting points of the numerical data in a column as the start of the time series
n number of time series
all the time series are synchronized into common time in the timetable data(TT).
data collection was not started and ended at the same time so depending on the starting and ending time NaN values are at the beginning and end of the columns

답변 (1개)

Divyank
Divyank 2023년 3월 16일
Hello @Amila, following steps might help:
Convert your timetable data (TT) to a matrix format using the table2array function.
>> data = table2array(TT);
You can use the 'pdist' function to calculate the pairwise distance between time series using the DTW distance metric. The pdist function can handle missing (NaN) values. The output of the pdist function is a condensed distance matrix.
>> dist = pdist(data(:, 2:end), @(x, y) dtw(x, y));
Then, 'linkage' function can be used to perform hierarchical clustering on the distance matrix.
>> Z = linkage(dist, 'ward');
To assign each time series to a cluster based on the hierarchical clustering result you can use the 'cluster' function. You can specify the number of clusters using the maxclust option.
>> idx = cluster(Z, 'maxclust', 3);
Finally, you can plot the clustering result using the 'gscatter' function.
>> gscatter(data(:,1), data(:,end), idx);
I hope this helps!
  댓글 수: 1
Amila
Amila 2023년 3월 20일
Thank you very much for your kid help
Im stugeling with this quite some time now, still due to NaN values this is not working it gives this error
Error in divyank (line 4)
dist=pdist(data(:,2:end),@(x,y) dtw(x,y));
Caused by:
Error using dtw
Expected input number 1, X, to be non-NaN.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by