“ Apyori模块的RelationRecord对象”先验算法python [英] "RelationRecord object of apyori module" apriori algorithm python

查看:329
本文介绍了“ 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆