作家
登录

Apriori算法介绍(Python实现)

作者: 来源: 2017-04-19 08:55:49 阅读 我要评论

for item in t: 
  •  item_set = frozenset([item]) 
  •  C1.add(item_set) 
  •  return C1 
  •  
  •  
  • def is_apriori(Ck_item, Lksub1): 
  •  ""
  •  Judge whether a frequent candidate k-itemset satisfy Apriori property. 
  •  Args: 
  •  Ck_item: a frequent candidate k-itemset in Ck which contains all frequent 
  •  candidate k-itemsets. 
  •  Lksub1: Lk-1, a set which contains all frequent candidate (k-1)-itemsets. 
  •  Returns
  •  True: satisfying Apriori property. 
  •  FalseNot satisfying Apriori property. 
  •  ""
  •  for item in Ck_item: 
  •  sub_Ck = Ck_item - frozenset([item]) 
  •  if sub_Ck not in Lksub1: 
  •  return False 
  •  return True 
  •  
  •  
  • def create_Ck(Lksub1, k): 
  •  ""
  •  Create Ck, a set which contains all all frequent candidate k-itemsets 
  •  by Lk-1's own connection operation. 
  •  Args: 
  •  Lksub1: Lk-1, a set which contains all frequent candidate (k-1)-itemsets. 
  •  k: the item number of a frequent itemset. 
  •  Return
  •  Ck: a set which contains all all frequent candidate k-itemsets. 
  •  ""
  •  Ck = set() 
  •  len_Lksub1 = len(Lksub1) 
  •  list_Lksub1 = list(Lksub1) 
  •  for i in range(len_Lksub1): 
  •  for j 

      推荐阅读

      家用NAS有什么用?充分挖掘你的NAS功能

    家用NAS有什么竽暌姑?具体整顿如下:1. 存储所有照片并分类整顿。2. 建立本身的视频办事器,出差在外可以播放家里的视频、音频,看照片。3. 存储大年夜量音乐,经由过程光纤声卡直接连到音>>>详细阅读


    本文标题:Apriori算法介绍(Python实现)

    地址:http://www.17bianji.com/lsqh/34841.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)