title: How to count the occurrences of sets which are part of a list in Python?
body: <p>Trying to implement the apriori algorithm and made it to the point where I can extract the subsets occurring together in all transactions.</p>
  
  <p>This is what I have:  </p>
  
  <pre><code>subsets = [set(['Breakfast &amp; Brunch', 'Restaurants']), set(['American (Traditional)', 'Breakfast &amp; Brunch']), set(['American (Traditional)', 'Restaurants']), set(['American (Traditional)', 'Breakfast &amp; Brunch']), set(['Breakfast &amp; Brunch', 'Restaurants']), set(['American (Traditional)', 'Restaurants'])]
  </code></pre>
  
  <p>For example <code>set(['Breakfast &amp; Brunch', 'Restaurants'])</code> occurs twice
  and I need to keep track of the numbers of occurrences together with the corresponding patterns.</p>
  
  <p>I tried to use:</p>
  
  <pre><code>from collections import Counter
  
  support_set = Counter()
  # some code that generated the list above
  
  support_set.update(subsets)
  </code></pre>
  
  <p>but it generates this error:</p>
  
  <pre><code>  supported = itemsets_support(transactions, candidates)
    File "apriori.py", line 77, in itemsets_support
      support_set.update(subsets)
    File"/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/collections.py", line 567, in update
      self[elem] = self_get(elem, 0) + 1
  TypeError: unhashable type: 'set'
  </code></pre>
  
  <p>Any idea?</p>