Skip to content

Commit

Permalink
Use BF_plot_timeseries to visualise results
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabsethi committed Aug 15, 2016
1 parent a40e773 commit db7a16e
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions SS_TestOpsOnTSClusters.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,31 @@
load('run_options.mat');
load('HCTSA_N.mat');
load('linkage_clustered_ops.mat');
load('resid_variance.mat');
load('auto_chosen_ops.mat');

% Create a reduced data matrix using the automatically chosen operations
reducedMat = TS_DataMat(:,autoChosenIdxs);
reducedDists = pdist(reducedMat);

% Cluster the time series using the reduced (K-medoids) operation space
maxIter = 100;
nrepeats = 500;
ts_k = round(size(TS_DataMat,1) / av_ts_cluster_size);

[CCi, Cass, err, Cord] = BF_kmedoids(squareform(S_red), ts_k, maxIter, nrepeats);
[~,Cass,~,Cord] = BF_kmedoids(squareform(reducedDists), ts_k, maxIter, ts_km_repeats);

% Sort clusters by size
[~,I] = sort(cellfun(@length,Cord),'descend');

% Plot a few TS from each of the clusters
sPlotNum = 1;
plotsPerGroup = 4;
plotColours = get(0,'DefaultAxesColorOrder');
numGroups = 10;
for i = 1:numGroups
figure;
plotOptions = struct('plotFreeForm',1,'displayTitles',0,'newFigure',0);
numPerGroup = 40;
maxLength = 500;
numPlots = 12;
for i = 1:numPlots
subplot(2,numPlots / 2,i);
series = find(Cass == I(i));
for j = 1:min(plotsPerGroup,length(series))
subplot(numGroups,plotsPerGroup,sPlotNum);
plot(TimeSeries(series(j)).Data,'color',plotColours(max(1,mod(i,8)),:));
set(gca,'XTickLabel','','YTickLabel','')
if j == 1
title(['Group ',num2str(i)]);
end
title(TimeSeries(series(j)).Keywords);
sPlotNum = sPlotNum + 1;
end
sPlotNum = (plotsPerGroup * i) + 1;
end

TS_plot_timeseries('norm',numPerGroup,series,maxLength,plotOptions);
title(sprintf('Cluster %i (%i time series)',i,length(series)));
end

0 comments on commit db7a16e

Please sign in to comment.