|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- function [attAffinity] = CalcAttributesAffinity_O(data, attData, last_known_node, addMissingAtt, normalize, returnSparse)
- n = size(attData,1);
- numAtt = size(attData,2);
-
- if addMissingAtt> 0 && last_known_node < n
- attData = AddMissingNodesAttrFromNeighborsNeighbors(data, attData, last_known_node, addMissingAtt);
- end
-
- count = sum(attData,2);
- nnz_n = nnz(count);
- % fprintf('calculating attribtes affinity matrix - common start\n');
- common = attData*attData';
- [r,c,v] = find(common);
- clear('common');
- x=size(r,1);
- LogMsg(sprintf('attAffinity common (%d) - nnz=%6.5d, %7.5d%%, max %d, min %d, mean %7.5d',numAtt,x,100*x/(n*n),max(v),min(v),mean(v)));
- LogMsg(sprintf('attAffinity count (%d) - nnz=%6.5d, %7.5d%%, max %d, min %d, mean %7.5d',numAtt,nnz_n, 100*nnz_n/n, max(count),min(count),mean(count)));
- fprintf('calculating attribtes affinity matrix \n');
-
- % fprintf('calculating attribtes affinity matrix - loop start\n');
- attAffinity = zeros(n,n); %% Sigal 13.3.13 - TODO use sparse if x < 50%???
- for i=1:x
- total = count(r(i))+count(c(i))-v(i);
- if total > 0
- attAffinity(r(i),c(i)) = v(i)/total;
- end
- end
- % [r,c,v] = find(attAffinity);
- % x=size(r,1);
- % LogMsg(sprintf('attAffinity final -> nnz=%d, %d%%, max %d, min %d, mean %d',x,100*x/(n*n),max(v),min(v),mean(v)));
- % [r,c,v] = find(attAffinity>=0.02);
- % x=size(r,1);
- % LogMsg(sprintf('attAffinity 0.02 - nnz=%d, %d%%, max %d, min %d, mean %d',x,100*x/(n*n),max(v),min(v),mean(v)));
- % [r,c,v] = find(attAffinity>=0.05);
- % x=size(r,1);
- % LogMsg(sprintf('attAffinity 0.05 - nnz=%d, %d%%, max %d, min %d, mean %d',x,100*x/(n*n),max(v),min(v),mean(v)));
-
- % LogMsg(sprintf('==> attAffinity - max %d, min %d, mean %d',max(max(attAffinity)),min(min(attAffinity)),mean(mean(attAffinity))));
-
- % for i=1:n %% sigal 25.2.13 last_known_node
- % for j=1:i-1
- % if common(i,j)>0
- % total = count(i)+count(j)-common(i,j);
- % if total > 0
- % attAffinity(i,j) = common(i,j)/total;
- % attAffinity(j,i) = attAffinity(i,j);
- % end
- % end
- % end
- % % for k=last_known_node+1:n
- % % attAffinity(i,k) = 1;
- % % attAffinity(k,i) = 1;
- % % end
- % end
-
- % fprintf('calculating attribtes affinity matrix - loop end\n');
-
- % fprintf('calculating attribtes affinity matrix - normalize start\n');
- % if normalize == 1
- % maxValue = max(max(attAffinity));
- % if maxValue>0 && maxValue ~= 1
- % attAffinity = attAffinity ./ maxValue;
- % end
- % end
- % fprintf('calculating attribtes affinity matrix - normalize end max=%d\n',maxValue);
- %
- % for i = 1 : size(attAffinity,1)
- % attAffinity(i,i) = 1;
- % end
-
-
- % if returnSparse == 1
- % attAffinity = sparse(attAffinity);
- % end
- fprintf('calculating attribtes affinity matrix - end function\n');
-
- end %function
|