日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python如何使用apriori_python-如何加快基于Apriori框架的速度,以仅生...

發布時間:2025/3/21 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python如何使用apriori_python-如何加快基于Apriori框架的速度,以仅生... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我有一個具有60萬行和15列的csv文件“ Col1,Col2 … COl15”.我想生成關聯規則,其中只有右側只有col15中的值.我正在使用here的apriori實現

它以這種方式計算每個項目集的minSupport:

oneCSet = returnItemsWithMinSupport(itemSet,

transactionList,

minSupport,

freqSet)

print "reached line 80"

currentLSet = oneCSet

k = 2

while(currentLSet != set([])):

print k

largeSet[k-1] = currentLSet

currentLSet = joinSet(currentLSet, k)

currentCSet = returnItemsWithMinSupport(currentLSet,

transactionList,

minSupport,

freqSet)

currentLSet = currentCSet

k = k + 1

def returnItemsWithMinSupport(itemSet, transactionList, minSupport, freqSet):

"""calculates the support for items in the itemSet and returns a subset

of the itemSet each of whose elements satisfies the minimum support"""

_itemSet = set()

localSet = defaultdict(int)

#print itemSet

for item in itemSet:

#print "I am here", list(item)

for transaction in transactionList:

if item.issubset(transaction):

freqSet[item] += 1

localSet[item] += 1

print "Done half"

for item, count in localSet.items():

support = float(count)/len(transactionList)

if support >= minSupport:

_itemSet.add(item)

return _itemSet

但是對于我擁有的許多行,這將花費很多時間,因為我希望RHS被限制為僅具有特定列(Col15)中的值,所以我可以通過某種方式減少頻繁使用的項目集來使實現更快?其他方法之一是最后過濾規則,但是時間復雜度相同.還是有其他一些實現/庫可以幫助我加快速度?

總結

以上是生活随笔為你收集整理的python如何使用apriori_python-如何加快基于Apriori框架的速度,以仅生...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。