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.

CombineDataWithAttributes3.m 942B

5 years ago
123456789101112131415161718192021222324252627282930
  1. function [dataWithAtt, totalAttNum] = CombineDataWithAttributes3(data, attData, attWeight)
  2. totalAttNum = size(attData,2);
  3. sizeWithAtt = totalAttNum + size(data,1);
  4. dataWithAtt = sparse(sizeWithAtt, sizeWithAtt);
  5. dataWithAtt(totalAttNum+1:end,totalAttNum+1:end) = data;
  6. dataLines = size(data,1);
  7. attLines = size(attData,1);
  8. if (attLines ~= dataLines)
  9. fprintf('CombineDataWithAttributes - Invalid data sizes: data %d, attributes %d\n',dataLines,attLines);
  10. end
  11. % Sigal 1.3.13: normalizeWeight
  12. % make sure that ratio att/link is same w/1-w
  13. if attWeight < 1 && attWeight >= 0
  14. normalizeWeight = attWeight/(1-attWeight);
  15. else
  16. normalizeWeight = 1;
  17. end
  18. for line=1:dataLines
  19. nnzAtt = find(attData(line,:));
  20. for att = nnzAtt
  21. dataWithAtt(totalAttNum+line,att)=normalizeWeight;
  22. dataWithAtt(att,totalAttNum+line)=normalizeWeight;
  23. end
  24. end
  25. dataWithAtt = sparse(dataWithAtt);