“ Apyori模块的RelationRecord对象”先验算法python

编程入门 行业动态 更新时间:2024-10-14 18:14:19
本文介绍了“ Apyori模块的RelationRecord对象”先验算法python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请问我的英语水平,,我想识别出一组数据中经常出现的属性,以便使用python的apyori软件包得出分类。我在20772个交易的数据帧上进行练习,最大交易是543个项目。

Excuse me for my english, I'm trying to recognize properties that come up frequently in a set of data to deduce a categorization using the apyori package of python. i'm practicing on a dataframe of 20772 transactions and the largest transaction is 543 items.

DataFrame

我将此DataFrame转换为列表:

I converted this DataFrame into a list :

liste = df.astype(str).values.tolist()

我有此列表

列表

我使用了apyori库的apriori函数来生成关联规则:

I used the apriori function of the library apyori to generate the association rules:

from apyori import apriori rules = apriori(liste, min_support= 0.01, min_confidence= 0.2)

显示结果,我将规则变量转换为列表:

to display the result I converted the rules variable to a list :

MB = list(rules)

问题在于,它不是向我显示规则,而是显示RelationRecord Apyori模块的RelationRecord对象。

The problem is that instead of showing me the rules but it shows the RelationRecord "RelationRecord object of apyori module".

像这里

结果

推荐答案

要从RelationRecord获取规则列表,请将RelationRecord转换为list

To get list of rules from RelationRecord, convert RelationRecord to list

listRules = [list(MB[i][0]) for i in range(0,len(MB))]

listRules预览

更多推荐

“ Apyori模块的RelationRecord对象”先验算法python

本文发布于:2023-11-29 20:02:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647484.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   模块   对象   Apyori   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!