You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CalcOneAttributeSimilarity.m 898B

5 years ago
123456789101112131415161718192021222324252627282930
  1. function [attSimilarity] = CalcOneAttributeSimilarity(data, attributes, attId, returnSparse)
  2. n = size(data,1);
  3. attSimilarity = zeros(n,n);
  4. %Note - Sigal, replace 0 and 2 so we can have sparse matrix
  5. for i=1:n
  6. for j=1:i-1
  7. val_i = attributes(i,attId);
  8. val_j = attributes(j,attId);
  9. if val_i == 0 && val_j == 0
  10. attSimilarity(i,j) = 2;
  11. elseif val_i == val_j
  12. attSimilarity(i,j) = 1;
  13. % else % can be skipped as already initilaize with zero
  14. % attSimilarity(i,j) = 0;
  15. end
  16. attSimilarity(j,i) = attSimilarity(i,j);
  17. end
  18. end
  19. for i = 1 : size(attSimilarity,1)
  20. attSimilarity(i,i) = 1;
  21. end
  22. if returnSparse == 1
  23. attSimilarity = sparse(attSimilarity);
  24. end
  25. end %function