MCPcopy Index your code
hub / github.com/clips/pattern / Lk

Method Lk

pattern/vector/__init__.py:1230–1239  ·  view source on GitHub ↗

Prunes candidate sets whose frequency < support threshold. Returns a dictionary of (candidate set, frequency)-items.

(self, sets, candidates, support=0.0)

Source from the content-addressed store, hash-verified

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.

Callers 1

__call__Method · 0.95

Calls 2

lenFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected