Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
function [expansionPoints, matrixOfDistancesFromCentres] = getExpansionPoints(X, nClusters, rep, debugLevel, debugMsgLocation)
% GETEXPANSIONPOINTS
% Performs k-means and returns the clusterCentres as the expansion points
%
% INPUT PARAMS
% Param X (matrix)
% All bags opened up into instances
%
% Param nClusters (matrix)
% Number of clusters for k-means
%
% OUTPUT PARAMS
% Param 'expansionPoints' (matrix)
% a set of expansionPoints, in other words cluster centres
%
% Param 'matrixOfDistancesFromCentres' (matrix)
% As the name suggests,
%
% ADDITIONAL NOTES
%
% Author: snikumbh@mpi-inf.mpg.de
logMessages(debugMsgLocation, sprintf('--- Obtaining a set of expansion points '), debugLevel);
% Obtained X in the input arguments is an n x p matrix, ready for kmeans
% expansionPoints, to be returned, is a k-by-p matrix
% Below, matrixOfDistancesFromCentres is a n-by-k matrix giving distances from each point to every
% cluster centre.
%
% sumD, from the Matlab documentation, is the within-cluster sums of point-to-centroid distances in a k-by-1 vector
%
tic;
rng('default');
logMessages(debugMsgLocation, sprintf('with K-means: \n'), debugLevel);
if debugLevel == 2
[idx, expansionPoints, sumD, matrixOfDistancesFromCentres] = kmeans(X, nClusters, 'Replicates', rep, 'Display','off');
% Display could be set to 'final'
elseif debugLevel == 0
[idx, expansionPoints, sumD, matrixOfDistancesFromCentres] = kmeans(X, nClusters, 'Replicates', rep, 'Display','off');
end
logMessages(debugMsgLocation, sprintf('--- Took %.3f seconds\n',toc), debugLevel);
end