PART 1

PART 1

传统回归模型的困难

1.为什么一定是线性的?或某种非线性模型?

2.过分依赖于分析者的经验

3.对于非连续的离散数据难以处理

网格方法

Science》上的文章《Detecting Novel Associations in Large Data Sets

方法概要:用网格判断数据的集中程度,集中程度意味着是否有关联关系

方法具有一般性,即无论数据是怎样分布的,不限于特点的关联函数类型,此判断方法都是有效

方法具有等效性,计算的熵值和噪音的程度有关,跟关联的类型无关

MIC:the Maximal Information Coefficient

MINE:Maximal Information-based Nonparametric Exploration

MIC值计算

坐标平面被划分为(x,y)网格G(未必等宽),其中

在G上可以诱导出“自然概率密度函数”p(x,y),任何一个方格(box)内的概率密度函数值为这个方格所包含的样本点数量占全体的样本点的比例

计算网格划分G下mutual information值



构造特征矩阵,矩阵元素

取遍所有可能的(x,y)网格G

。Max取遍所有可能的(x,y)对

的计算是个难点,数据科学家构造了一个近似的逼近算法以提高效率

enter link description here

在作者的网站上,可以下载MINE计算MIC的程序(Java和R)以及测试用数据集

enter link description here

MIC的性质

如果变量对x,y存在函数关系,则当样本数增加时,MIC必然趋于1

如果变量对x,y可以由参数方程所表达的曲线描画,则当样本数增加时,MIC必然趋于1

如果变量对x,y在统计意义下互相独立,则当样本数增加时,MIC趋于0

PART 2

数据挖掘:关联规则挖掘

例子:购物篮分析

名词

挖掘数据集:购物篮数据

挖掘目标:关联规则

关联规则:牛奶=>鸡蛋【支持度=2%,置信度=60%】

支持度:分析中的全部事务的2%同时购买了牛奶和鸡蛋

置信度:购买了牛奶的同志有60%也购买了鸡蛋

最小支持度阈值和最小置信度阈值:由挖掘者或领域专家设定

项集:项(商品)的集合

k-项集:k个项组成的项集

频繁项集:满足最小支持度的项集,频繁k-项集一般记为

强关联规则:满足最小支持度阈值和最小置信度阈值的规则

关联规则挖掘路线图

两步过程:找出所有频繁项集;由频繁项集产生强关联规则

算法:Apriori

例子:详见《数据挖掘:概念与技术》

用R进行购物篮分析

安装arules()包并加载

内置Groceries数据集

> library(arules)#加载arules程序包
> data(Groceries)#调用数据文件
> inspect(Groceries)#观看数据集里的数据
> .....................省略........
>9834 {semi-finished bread,
bottled water,
soda,
bottled beer}
9835 {chicken,
tropical fruit,
other vegetables,
vinegar,
shopping bags}

利用apriori函数提取关联规则

> rules=apriori(Groceries,parameter=list(support=0.01,confidence=0.5))#support为最小支持度,confidence为最小置信度

Parameter specification:
confidence minval smax arem aval originalSupport support minlen maxlen target
0.5 0.1 1 none FALSE TRUE 0.01 1 10 rules
ext
FALSE

Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE

apriori - find association rules with the apriori algorithm
version 4.21 (2004.05.09) (c) 1996-2004 Christian Borgelt
set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
sorting and recoding items ... [88 item(s)] done [0.00s].
creating transaction tree ... done [0.01s].
checking subsets of size 1 2 3 4 done [0.00s].
writing ... [15 rule(s)] done [0.00s].
creating S4 object ... done [0.00s].

列出关联规则

> summary(rules)#查看求得的关联规则之摘要
set of 15 rules

rule length distribution (lhs + rhs):sizes
3
15

Min. 1st Qu. Median Mean 3rd Qu. Max.
3 3 3 3 3 3

summary of quality measures:
support confidence lift
Min. :0.01007 Min. :0.5000 Min. :1.984
1st Qu.:0.01174 1st Qu.:0.5151 1st Qu.:2.036
Median :0.01230 Median :0.5245 Median :2.203
Mean :0.01316 Mean :0.5411 Mean :2.299
3rd Qu.:0.01403 3rd Qu.:0.5718 3rd Qu.:2.432
Max. :0.02227 Max. :0.5862 Max. :3.030

mining info:
data ntransactions support confidence
Groceries 9835 0.01 0.5
> inspect(rules)
lhs rhs support
1 {curd,yogurt} => {whole milk} 0.01006609
2 {other vegetables,butter} => {whole milk} 0.01148958
3 {other vegetables,domestic eggs} => {whole milk} 0.01230300
4 {yogurt,whipped/sour cream} => {whole milk} 0.01087951
5 {other vegetables,whipped/sour cream} => {whole milk} 0.01464159
6 {pip fruit,other vegetables} => {whole milk} 0.01352313
7 {citrus fruit,root vegetables} => {other vegetables} 0.01037112
8 {tropical fruit,root vegetables} => {other vegetables} 0.01230300
9 {tropical fruit,root vegetables} => {whole milk} 0.01199797
10 {tropical fruit,yogurt} => {whole milk} 0.01514997
11 {root vegetables,yogurt} => {other vegetables} 0.01291307
12 {root vegetables,yogurt} => {whole milk} 0.01453991
13 {root vegetables,rolls/buns} => {other vegetables} 0.01220132
14 {root vegetables,rolls/buns} => {whole milk} 0.01270971
15 {other vegetables,yogurt} => {whole milk} 0.02226741
confidence lift
1 0.5823529 2.279125
2 0.5736041 2.244885
3 0.5525114 2.162336
4 0.5245098 2.052747
5 0.5070423 1.984385
6 0.5175097 2.025351
7 0.5862069 3.029608
8 0.5845411 3.020999
9 0.5700483 2.230969
10 0.5173611 2.024770
11 0.5000000 2.584078
12 0.5629921 2.203354
13 0.5020921 2.594890
14 0.5230126 2.046888
15 0.5128806 2.007235

按需要筛选关联规则

> x=subset(rules,subset=rhs%in%"whole milk"&lift>=1.2)#求所需要的关联规则子集
> inspect(sort(x,by="support")[1:5])#根据支持度对求得的关联规则子集排序并查看
lhs rhs support confidence
15 {other vegetables,yogurt} => {whole milk} 0.02226741 0.5128806
10 {tropical fruit,yogurt} => {whole milk} 0.01514997 0.5173611
5 {other vegetables,whipped/sour cream} => {whole milk} 0.01464159 0.5070423
12 {root vegetables,yogurt} => {whole milk} 0.01453991 0.5629921
6 {pip fruit,other vegetables} => {whole milk} 0.01352313 0.5175097
lift
15 2.007235
10 2.024770
5 1.984385
12 2.203354
6 2.025351

其中life=P(L,R)/(P(L)P(R))是一个类似相关系数的指标。lift=1时表示L和R独立,这个数越大,越表明L和R存在在一个购物篮中不是偶然现象。

最新文章

  1. C#+HtmlAgilityPack+XPath带你采集数据(以采集天气数据为例子)
  2. iOS-常见问题
  3. 数据结构->直接插入排序
  4. 介绍DSA数字签名,非对称加密的另一种实现
  5. 你想的到想不到的 javascript 应用小技巧方法
  6. SQL位移运算函数
  7. fatl exception occurred异常/错误的一种可能情况
  8. 网页绘制图表 Google Charts with JavaScript #2 ....与ASP.NET网页结合 (ClientScriptManager.RegisterStartupScript 方法)
  9. QT与JavaScript互调 - 虹的日志 - 网易博客
  10. [转]About the security content of iOS 8
  11. CNN-梯度下降
  12. java中的注解总结
  13. python编程基础--计算机原理之硬件基础
  14. JS面向对象之原型链
  15. autofac生命周期入门(如何避免内存泄漏)
  16. 垂直打击之JVM剖析
  17. Ajax详细剖析
  18. [转]OpenMP 入门指南
  19. 【TP3.2】TP3.2的 FIND_IN_SET()的用法
  20. 使用EmbeddedValueResolverAware读取配置文件内容

热门文章

  1. Protobuf-net基础
  2. sql2008R2数据库备份--双机备份
  3. SQLite语法
  4. Ubuntu引导修复问题
  5. js——DOM操作(二)
  6. js call方法介绍
  7. C++ char和string的区别
  8. [非技术参考]C#枚举类型
  9. MYSQL定时创建表分区
  10. CentOS yum安装配置lnmp服务器(Nginx+PHP+MySQL)