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.

CalcAttributesAffinity_S2.m 1.6KB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. function [attAffinity] = CalcAttributesAffinity_S2(data, attData, last_known_node, addMissingAtt, threshold)
  2. n = size(attData,1);
  3. numAtt = size(attData,2);
  4. if addMissingAtt> 0 && last_known_node < n
  5. attData = AddMissingNodesAttrFromNeighborsNeighbors(data, attData, last_known_node, addMissingAtt);
  6. end
  7. count = sum(attData,2);
  8. nnz_n = nnz(count);
  9. % fprintf('calculating attribtes affinity matrix - common start\n');
  10. common = attData*attData';
  11. [r,c,v] = find(common);
  12. clear('common');
  13. x=size(r,1);
  14. perc_x = x/(n*n);
  15. LogMsg(sprintf('attAffinity common (%d, %.3f) - nnz=%d, %7.5f%%, max %d, min %d, mean %7.5f',numAtt,threshold,x,100*perc_x,max(v),min(v),mean(v)));
  16. LogMsg(sprintf('attAffinity count (%d, %.3f) - nnz=%d, %7.5f%%, max %d, min %d, mean %7.5f',numAtt,threshold,nnz_n, 100*nnz_n/n, max(count),min(count),mean(count)));
  17. % Sigal 22.3.13 - TODO use sparse if x < 40%
  18. if perc_x<0.4
  19. attAffinity = sparse(n,n);
  20. else
  21. attAffinity = zero(n,n);
  22. LogMsg(sprintf('*** attAffinity - using full matrix'));
  23. end
  24. for i=1:x
  25. total = count(r(i))+count(c(i))-v(i);
  26. if total > 0
  27. val = v(i)/total;
  28. if val > threshold
  29. attAffinity(r(i),c(i)) = val;
  30. % else
  31. % filter = filteer+1;
  32. end
  33. end
  34. end
  35. nnz_n = nnz(attAffinity);
  36. LogMsg(sprintf('attAffinity total (%d, %.3f) - nnz=%d, %7.5f%%',numAtt,threshold,nnz_n,100*nnz_n/(n*n)));
  37. end %function