Prunes candidate sets whose frequency < support threshold. Returns a dictionary of (candidate set, frequency)-items.
(self, sets, candidates, support=0.0)
| 1228 | return Ck |
| 1229 | |
| 1230 | def Lk(self, sets, candidates, support=0.0): |
| 1231 | """ Prunes candidate sets whose frequency < support threshold. |
| 1232 | Returns a dictionary of (candidate set, frequency)-items. |
| 1233 | """ |
| 1234 | Lk, x = {}, 1.0 / (len(sets) or 1) # relative count |
| 1235 | for s1 in candidates: |
| 1236 | for s2 in sets: |
| 1237 | if s1.issubset(s2): |
| 1238 | Lk[s1] = s1 in Lk and Lk[s1]+x or x |
| 1239 | return dict((s, f) for s, f in Lk.items() if f >= support) |
| 1240 | |
| 1241 | def __call__(self, sets, support=0.5): |
| 1242 | """ Returns a dictionary of (set(features), frequency)-items. |