加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

基于R语言的apriori算法介绍

(2015-02-06 15:33:30)
标签:

股票

分类: R语言

library(arules)  #加载arules程序包
data(Groceries)  #调用数据文件
frequentsets=eclat(Groceries,parameter=list(support=0.05,maxlen=10))  #求频繁项集
inspect(frequentsets[1:10])    #察看求得的频繁项集
inspect(sort(frequentsets,by="support")[1:10])    #根据支持度对求得的频繁项集排序并察看(等价于inspect(sort(frequentsets)[1:10])
rules=apriori(Groceries,parameter=list(support=0.01,confidence=0.01))    #求关联规则
summary(rules)    #察看求得的关联规则之摘要
x=subset(rules,subset=rhs%in%"whole milk"&lift>=1.2)    #求所需要的关联规则子集
inspect(sort(x,by="support")[1:5])    #根据支持度对求得的关联规则子集排序并察看


asahikawa重新翻译apriori关联挖掘包arules,详情如下:

 

apriori(arules)
apriori()所属R语言包:arules

----------描述如下----------

Mine frequent itemsets, association rules or association hyperedges using the Apriori algorithm.

The Apriori algorithm employs level-wise search for frequent itemsets.

 The implementation of Apriori used includes some improvements (e.g., a prefix tree and item sorting).
在进行”项集频率、关联规则或关联超边“的挖掘是需要使用apriori算法。

 Apriori算法采用的是“逐层搜索频繁项集”的方法。

Apriori算法在实现过程中会做一些改进(例如:前序树和项目分类)。


----------用法如下----------

apriori(data, parameter = NULL, appearance = NULL, control = NULL)

 

----------参数解释如下----------

参数:data
object of class transactions or any data structure which can be coerced into transactions (e.g., a binary matrix or data.frame).
可转换类别的实体或任何可以将其强制进行转换的数据结构(例如:一个二进制矩阵或数据框)。


参数:parameter
object of class APparameter or named list.

The default behavior is to mine rules with support 0.1, confidence 0.8, and maxlen 10.
类别为APparameter的实体或命名列表。

默认的挖掘规则为:支持度0.1,置信度0.8,最大长度10(此处长度指结果个数)。


参数:appearance
object of class APappearance or named list.

With this argument item appearance can be restricted.

By default all items can appear unrestricted.
类别为APparameter的实体或命名列表。

使用该参数来控制对应项。

默认情况下,所有项目无限制。


参数:control
object of class APcontrol or named list.

Controls the performance of the mining algorithm (item sorting, etc.)
对象的类APcontrol或命名列表。

控制挖掘算法的性能(例如:项目排序)

 

----------详细信息如下----------

Calls the C implementation of the Apriori algorithm by Christian Borgelt for mining frequent itemsets, rules or hyperedges.
调用Christian Borgelt 所写的基于C语言实现的Apriori算法来挖掘“频繁项集,规则或超边”。

Note: Apriori only creates rules with one item in the RHS (Consequent)!
注:Apriori算法在只有一个项目在RHS时(即结果为一个项目),才会创建规则。

Note: The default value in APparameter for minlen is 1.

This means that rules with only one item (i.e., an empty antecedent/LHS) like    will be created. 

注:APparameter的最小长度默认值是1。
这意味着将会创建只有一个项目的规则(即只有一个项目在LHS),例如   {} => {beer} 

 

These rules mean that no matter what other items are involved the  item in the RHS will appear with the probability given by the rule's confidence (which equals the support).

 

If you want to avoid these rules then use  the argument parameter=list(minlen=2).

这些规则意味着,无论其他什么项目与“在RHS中的项目”相关,都会根据概率给出规则置信度(相当于支持度)。

如果你想避免某些规则,那么就使用参数parameter=list(minlen=2)。


----------Value值----------

Returns an object of class rules or itemsets.

返回规则类或项目集的实体


----------References参考文献----------

between sets of items in large databases. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 207–216, Washington D.C.
Apriori Implementation. 15th Conference on Computational Statistics (COMPSTAT 2002, Berlin, Germany) Physica Verlag, Heidelberg, Germany.
Eclat.  Workshop of Frequent Item Set Mining Implementations (FIMI 2003, Melbourne, FL, USA).

参见----------See Also----------

APparameter-class, APcontrol-class, APappearance-class, transactions-class, itemsets-class, rules-class
APparameter-class,APcontrol-class,APappearance-class,transactions-class,itemsets-class,rules-class


实例----------Examples----------


data("Adult")
## Mine association rules.[矿的关联规则。]
rules <- apriori(Adult,
                 parameter = list(supp = 0.5, conf = 0.9,
                                  target = "rules"))
summary(rules)
 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有