Emania

Untitled

Jan 2nd, 2017
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.85 KB | None | 0 0
  1. function nextWords = apriori_gen(words, sortedA)
  2. %-----------------------------------------------------------
  3. % created by Jan Hrdlicka, 16.9.2010
  4. %-----------------------------------------------------------
  5. % Generates next level words(itemsets).
  6. % input is cell array "words" with words (arrays of items represented by numbers)
  7. % and vector of sorted items "sortedA" with size 1xM, where M is number of
  8. % items.
  9. % Size of the cell array "words" is Nx1, where N is number of words. Word
  10. % is vector with size 1xI, where I is number of items in the current word.
  11.     nextWords = {};
  12.     for i = 1:size(words, 2)
  13.         actWord = words{1,i};
  14.         ind = find(sortedA==actWord(end));
  15.         if ind~=length(sortedA)
  16.             for j = sortedA(ind+1:end)
  17.                 nextWords{end+1,1} = [actWord j];
  18.             end
  19.         end
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment