1

I wonder what would be the most efficient way to form the cooccurrence matrix in python if you have two list of tuples and their counts, like:

l1 = [(a, b, c, d), (b, c, d), (d, a)]
l2 = [(one, two), (two, three), (one)]
counts = [3, 7, 4]

And then, the outcome should be like this:

#     one     two     three
# a     7       3         0
# b     3      10         7
# c     3      10         7
# d     7      10         7

However, actual matrices (lists of tuples) and resulting matrix can be quite large.

Many thanks!

striatum
  • 1,428
  • 3
  • 14
  • 31
  • Please explain better, also sis you try anything? – Kobi K Jun 13 '14 at 15:56
  • I tried several things, but far from any success. I have not good direction about how to solve, except very "traditional", i.e., iterative or the like. [link](http://stackoverflow.com/questions/20574257/constructing-a-co-occurance-matrix-in-python-pandas) looks similar, but it is not duplicate. I think the problem I posted here is more complicated. – striatum Jun 13 '14 at 16:25
  • Not a duplicate: this question does not require to use pandas – Franck Dernoncourt Aug 19 '15 at 21:41

0 Answers0