Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我正在尝试编写 Apriori 算法。我这里有
L1= ['apple', 'banana','orange','mango]
这个列表已经通过了支持阈值,现在我必须将这些项目组合为另一个支持阈值,它应该如下所示:
C2 = [['apple','banana'],['apple','orange'],['apple','mango']]
L1= ['apple', 'banana','orange','mango'] C2 = [[L1[0], i] for i in L1[1:]]
结果C2:
C2
[['apple', 'banana'], ['apple', 'orange'], ['apple', 'mango']]
要对列表中的所有项目运行此操作:
C2 = [] for i in L1: l = [[i, x] for x in L1 if not i == x] C2.extend(l)