brede_mat_kmc - K-means clustering function [M1, M2] = brede_mat_kmc(M, ... 'PropertyName', 'PropertyValue') Input: M 'Mat' structure or matrix Property: Assignment [ {left} | right ] Determines if the assignment matrix is the left of the right of the output arguments. Components [ {10} | Integer>0 ] Number of clusters. Info [ {0} | Waitbar | Integer ] Amount of debug and progress information Init [ {ReverseLog} | Linear | UpperLinear | Random ] Initial cluster centers determination. The variables are sorted according to max of xcorr or std of variables and the initial centers are chosen from this list. MaxIterations [ {Inf} | Integer ] Number of iterations. Runs [ {1} | Integer>0 ] Number of runs Standardization [ {None} | Std | Range ] Determines the individual standardization (normalization) of the variables (the columns in the datamatrix. 'Std' will standardize with the standard deviation, 'Range' with the difference max-min Type [ median | {mean} ] Output: M1 'Mat' structure with assignment matrix if 'assignment' is 'left' else centroid matrix M2 'Mat' structure with matrix containing centers if 'assignment' is 'left' else the assignment matrix. brede_mat_kmc performs K-means. The number of clusters is specified with 'Components'. The input should be a matrix or a 'mat' structure with a matrix. 'Assigment' determines whether the left matrix is containing the assigment matrix (labels, a matrix containing ones and zeros) or the centers. 'Init' determines how the cluster centers are initialized. For all types of 'init' K specific objects (eg, voxels) are selected (K corresponding to the number of clusters): For 'random' the initial cluster centers are initialized by randomly picking K objects. For the other initialization methods the selection is deterministic from sorted objects. The sorting is either based on the standard deviation of the original data or the maximum of the cross-correlation function between the data and the paradigm. 'Linear' will select with linear space though the sorted list of objects, while 'reverselog' will select logarithmic through the list with the most cluster centers picked from the objects with the largest standard deviation or cross-correlation. 'UpperLinear' will select from the top of the list. 'MaxIterations' is the maximum number of iterations of the clustering algorithm. The K-means algorithm always finish in a finite number of iterations and the algorithm will return when there is no more permutations among the cluster labels. 'Runs' specifies the number of reruns of the entire algorithm. The K-means algorithm can converge to a local minimum and multiple runs is better to find the global minimum. For multiple runs the result from the run with the lowest error is returned. The individual variables (columns) in the datamatrix can be scaled according to 'Standardization': With 'Std' the columns are scaled to have equal standard deviation; with 'Range' the difference between minimum and maximum in each column is used to scale. Standardization should be used when the variables are measured with different units or the interesting features important for the discrimination lies in the variables with low magnitude. When the centers are found they are scaled back to the original space. 'Type' determines whether the clustering is K-means or K-median. Example: % Generate data X = [ randn(30,2) ; ones(30,1)*[1 2]+randn(30,2) ]; % K-means clustering [A,C] = brede_mat_kmc(X, 'components', 2); % Plot figure, plot(X(:,1), X(:,2), '.k') hold on i1=find(A.matrix(:,1)); i2=find(A.matrix(:,2)); plot(X(intersect(1:30,i1),1), X(intersect(1:30,i1),2), 'rd') plot(X(intersect(1:30,i2),1), X(intersect(1:30,i2),2), 'rs') plot(X(intersect(31:60,i1),1), X(intersect(31:60,i1),2), 'bs') plot(X(intersect(31:60,i2),1), X(intersect(31:60,i2),2), 'bd') plot(C.matrix(:,1), C.matrix(:,2), '+k', 'markersize', 15) hold off brede_mat_2mat2html(A,C); See also BREDE, BREDE_MAT, BREDE_MAT_2MAT2HTML, BREDE_MAT_HKMC, BREDE_MAT_ICA, BREDE_MAT_NMF, BREDE_MAT_RECONERROR, BREDE_MAT_SVD. $Id: brede_mat_kmc.m,v 1.20 2008/03/19 15:26:58 fn Exp $

- brede_mat_mat2mat brede_mat_mat2mat - Convert or clean matrix
- brede_mat_mean brede_mat_mean - Mean of matrix

- brede_exp_exp2html brede_exp_exp2html - Write 'exp' structures to HTML files
- brede_mat_hkmc brede_mat_hkmc - K-means clustering
- brede_ui_mat brede_ui_mat - UI for viewing a 'Mat' structure

Generated on Fri 27-Nov-2009 18:11:22 by