|
123456789101112131415161718192021222324252627282930 |
- function [attSimilarity] = CalcOneAttributeSimilarity(data, attributes, attId, returnSparse)
- n = size(data,1);
- attSimilarity = zeros(n,n);
-
- %Note - Sigal, replace 0 and 2 so we can have sparse matrix
-
- for i=1:n
- for j=1:i-1
- val_i = attributes(i,attId);
- val_j = attributes(j,attId);
- if val_i == 0 && val_j == 0
- attSimilarity(i,j) = 2;
- elseif val_i == val_j
- attSimilarity(i,j) = 1;
- % else % can be skipped as already initilaize with zero
- % attSimilarity(i,j) = 0;
- end
- attSimilarity(j,i) = attSimilarity(i,j);
- end
- end
-
- for i = 1 : size(attSimilarity,1)
- attSimilarity(i,i) = 1;
- end
-
- if returnSparse == 1
- attSimilarity = sparse(attSimilarity);
- end
-
- end %function
|