当前位置: 首页 > news >正文

做网站需要会语言吗济南做seo排名

做网站需要会语言吗,济南做seo排名,永嘉网站开发公司,ui设计现在好找工作吗通过Apriori算法挖掘以下事务集合的频繁项集: 流程图 代码 # 导入必要的库 from itertools import combinations# 定义Apriori算法函数 def apriori(transactions, min_support, min_confidence):# 遍历数据,统计每个项的支持度 item_support {}for tr…

通过Apriori算法挖掘以下事务集合的频繁项集:

流程图

代码
# 导入必要的库
from itertools import combinations# 定义Apriori算法函数
def apriori(transactions, min_support, min_confidence):# 遍历数据,统计每个项的支持度 item_support = {}for transaction in transactions:for item in transaction:if item not in item_support:item_support[item] = 0item_support[item] += 1# 计算总事务数total_transactions = len(transactions)# 计算频繁项集frequent_itemsets = {}for item, support in item_support.items():if support / total_transactions >= min_support: # 即该项集在事务数据库中出现的次数除以总数frequent_itemsets[(item,)] = support / total_transactions# 生成候选项集并迭代生成频繁项集k = 2while True:candidates = set() # 存储所有可能的项集for itemset in frequent_itemsets.keys():for item in itemset:candidates.add(item)# 生成候选项集candidates = list(combinations(candidates, k)) # 生成所有可能的k项集# 统计候选项集的支持度candidate_support = {}for transaction in transactions:for candidate in candidates:if set(candidate).issubset(set(transaction)):if candidate not in candidate_support:candidate_support[candidate] = 0candidate_support[candidate] += 1# 更新频繁项集frequent_itemsets_k = {}for candidate, support in candidate_support.items():if support / total_transactions >= min_support:frequent_itemsets_k[candidate] = support / total_transactions# 如果没有频繁项集则停止迭代if not frequent_itemsets_k:breakfrequent_itemsets.update(frequent_itemsets_k)k += 1# 生成关联规则rules = []for itemset in frequent_itemsets.keys():if len(itemset) >= 2:for i in range(1, len(itemset)):for combination in combinations(itemset, i):X = combinationY = tuple(set(itemset) - set(combination))confidence = frequent_itemsets[itemset] / frequent_itemsets[X]if confidence >= min_confidence:rules.append((X, Y, frequent_itemsets[itemset], confidence))# frequent_itemsets (dict): 频繁项集和对应的支持度,键为项集的元组,值为支持度# rules (list): 关联规则,每一条规则表示为一个元组 (X, Y),其中X为前项集合,Y为后项集合return frequent_itemsets, rules# 示例数据集
transactions = [    ['I1', 'I2', 'I5'],['I2', 'I4'],['I2', 'I3'],['I1', 'I2', 'I4'],['I1', 'I3'],['I2', 'I3'],['I1', 'I3'],['I1', 'I2', 'I3', 'I5'],['I1', 'I2', 'I3']
]
# 设置最小支持度和最小置信度阈值
min_support = 0.3
min_confidence = 0.6
# 调用Apriori算法函数
frequent_itemsets, rules = apriori(transactions, min_support, min_confidence)
print("频繁项集和对应的支持度:")
for itemset, support in frequent_itemsets.items():print("{}: Support = {:.2f}".format(itemset, support))
# 输出关联规则和置信度
print("\n关联规则和置信度:")
for X, Y, support, confidence in rules:print("{} => {}: Support = {:.2f}, Confidence = {:.2f}".format(X, Y, support, confidence))
  • 输出结果截图

http://www.tj-hxxt.cn/news/126505.html

相关文章:

  • 怎么自己做网站的优化电子商务与网络营销题库
  • 中国摄影网站排名优化工具
  • 什么网站做热能表好简述搜索引擎优化的方法
  • 设计师推荐网站欣赏信息流优化师简历模板
  • 贵州省建设厅网站查seo技术培训山东
  • 网站怎么定位软文推广是什么
  • 做网站一个月工资360网站收录提交
  • 最权威的网站推广公司互联网整合营销推广
  • 安康网站建设技巧搜索引擎优化入门
  • 有什么平台可以做网站淄博网站营销与推广
  • 纯flash网站价格网络营销专业学什么课程
  • 幼儿园网站模板怎么做北京seo方法
  • 苏州建设工程人才招聘网信息网站中国关键词
  • 成都网站建设 今网科技网站源码下载
  • 武汉专业网站做网页常见的网络营销方法有哪些
  • 男女做爰视频网站在线企业网络营销
  • 中国国防建设网站营销型网站建设
  • wordpress 繁體西安关键词优化服务
  • server2008做DNS与网站seo工具优化软件
  • 牟平网站制作公司软文推广文章范文
  • 贵州安顺住房城乡建设网站google推广 的效果
  • 青岛网站建设找润商怎么做公司网站推广
  • centos6.3 网站开发门户网站有哪些
  • 眉山网站推广搜索引擎营销seo
  • 郑州网站建站怎样做好销售和客户交流
  • 做网站开发没有人带爱站网seo工具
  • 泰安关键词优化公司江苏企业seo推广
  • 房产管理系统日照网站优化公司
  • 雄县没有做网站的公司浙江专业网站seo
  • 网站底部模板源码抖来查关键词搜索排名