天天看点

weka –Apriori算法 关联规则挖掘实验 一、Apriori算法参数含义 二、实验结果及分析

本次共进行了9组实验,使用了weka安装目录data文件夹下的contact-lenses.arff数据。

toolsàarffviewer,打开contact-lenses,可以看到实验数据contact-lenses共有24条记录,5个属性值。具体内容如下:

weka –Apriori算法 关联规则挖掘实验 一、Apriori算法参数含义 二、实验结果及分析

结合实验结果阐释下列12个参数的含义

1.        car 如果设为真,则会挖掘类关联规则而不是全局关联规则。

2.        classindex 类属性索引。如果设置为-1,最后的属性被当做类属性。

3.        delta 以此数值为迭代递减单位。不断减小支持度直至达到最小支持度或产生了满足数量要求的规则。

4.        lowerboundminsupport 最小支持度下界。

5.        metrictype 度量类型。设置对规则进行排序的度量依据。可以是:置信度(类关联规则只能用置信度挖掘),提升度(lift),杠杆率(leverage),确信度(conviction)。

在 weka中设置了几个类似置信度(confidence)的度量来衡量规则的关联程度,它们分别是:

a)        lift : p(a,b)/(p(a)p(b)) lift=1时表示a和b独立。这个数越大(>1),越表明a和b存在于一个购物篮中不是偶然现象,有较强的关联度.

b)        leverage :p(a,b)-p(a)p(b)

leverage=0时a和b独立,leverage越大a和b的关系越密切

c)        conviction:p(a)p(!b)/p(a,!b) (!b表示b没有发生) conviction也是用来衡量a和b的独立性。从它和lift的关系(对b取反,代入lift公式后求倒数)可以看出,这个值越大, a、b越关联。

6.        minmtric 度量的最小值。

7.        numrules 要发现的规则数。

8.        outputitemsets 如果设置为真,会在结果中输出项集。

9.        removeallmissingcols 移除全部为缺省值的列。

10.    significancelevel 重要程度。重要性测试(仅用于置信度)。

11.    upperboundminsupport 最小支持度上界。 从这个值开始迭代减小最小支持度。

12.    verbose 如果设置为真,则算法会以冗余模式运行。

weka –Apriori算法 关联规则挖掘实验 一、Apriori算法参数含义 二、实验结果及分析

=== run information ===     // 实验运行信息

scheme:       weka.associations.apriori -i -n 10 -t 0 -c 0.9 -d 0.05 -u 1.0 -m 0.5 -s -1.0 -c -1

relation:     contact-lenses       //数据的名称 contact-lenses

instances:    24         //数据的记录数 24

attributes:   5         //属性数目 5以及各属性名称

              age

              spectacle-prescrip

              astigmatism

              tear-prod-rate

              contact-lenses

=== associator model (full training set) ===

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%  scheme -所选的关联规则挖掘方案: apriori算法

%  算法的参数设置:-i -n 10 -t 0 -c 0.9 -d 0.05 -u 1.0 -m 0.5 -s -1.0 -c -1 ;

%  各参数依次表示:

%  i - 输出项集,若设为false则该值缺省;

%  n 10 - 规则数为10;

%  t 0 – 度量单位选为置信度,(t1-提升度,t2杠杆率,t3确信度);

%  c 0.9 – 度量的最小值为0.9;

%  d 0.05 - 递减迭代值为0.05;

%  u 1.0 - 最小支持度上界为1.0;

%  m 0.5 - 最小支持度下届设为0.5;

%  s -1.0 - 重要程度为-1.0;

%  c -1 - 类索引为-1输出项集设为真

%  (由于car, removeallmissingcols, verbose都保持为默认值false,因此在结果的参数设置为缺省,若设为true,则会在结果的参数设置信息中分别表示为a,

r,v)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

apriori  // apriori算法运行结果

=======

minimum support: 0.5 (12 instances)  //最小支持度0.5,即最少需要12个实例

minimum metric <confidence>: 0.9   //最小度量<置信度>:

0.9

number of cycles performed: 10    //进行了10轮搜索

generated sets of large itemsets:     //生成的频繁项集

size of set of large itemsets l(1): 7     //频繁1项集:7个

large itemsets l(1):      //频繁1项集(outputitemsets设为true, 因此下面会具体列出)

spectacle-prescrip=myope 12

spectacle-prescrip=hypermetrope 12

astigmatism=no 12

astigmatism=yes 12

tear-prod-rate=reduced 12

tear-prod-rate=normal 12

contact-lenses=none 15

%%%%%%%%%%%%%%%%%%%%%%%%

在上面所示数据界面中,分别点击标签spectacle-prescrip,astigmatism,tear-prod-rate和contact-lenses,该列的值会自动进行分类排序,可以很方便的对上面结果进行。点击age标签,其值按pre-presbiopic、presbiopic和young分类排序,可以看到各属性值的记录数均为8<12,不满足最小支持度,因此age属性的所有取值都没有列在上面结果中。

size of set of large itemsets l(2): 1    //频繁2项集: 1个

large itemsets l(2):

tear-prod-rate=reduced contact-lenses=none 12

//tear-prod-rate取值为reduced且 contact-lenses取值为none 的记录数共有12个

best rules found:    //最佳关联规则

 1. tear-prod-rate=reduced 12 ==> contact-lenses=none 12    conf:(1)

// 若tear-prod-rate取值为reduced可以推出 contact-lenses的取值为none,该关联规则置信度为100%

1. 实验中,若其它参数保持为默认值,将最小支持度下界设为0.8,则运行结果会显示”no large itemsets and rules found!”,即找不到满足条件的关联规则。

2. 若其它参数保持为默认值,将最小支持度下界设为0.25,上界设为0.8,度量选为置信度,最小值为0.8,则运行结果找到:频繁1项集10个,频繁2项集18个,频繁3项集4个,找到的最佳关联规则为:

1. tear-prod-rate=reduced 12 ==> contact-lenses=none 12    conf:(1)

 2. spectacle-prescrip=myope tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1)

 3. spectacle-prescrip=hypermetrope tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1)

 4. astigmatism=no tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1)

 5. astigmatism=yes tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1)

 6. spectacle-prescrip=myope contact-lenses=none 7 ==> tear-prod-rate=reduced 6    conf:(0.86)

 7. astigmatism=no contact-lenses=none 7 ==> tear-prod-rate=reduced 6    conf:(0.86)

3. 若其它参数保持为默认值,将最小支持度下界设为0.25,上界设为0.8,度量选为提升度(lift : p(a,b)/(p(a)p(b))),最小值为1.1,则运行结果找到10条最佳关联规则,前3条如下:

1. tear-prod-rate=reduced 12 ==> spectacle-prescrip=myope contact-lenses=none 6    conf:(0.5) < lift:(1.71)> lev:(0.1) [2] conv:(1.21)

 2. spectacle-prescrip=myope contact-lenses=none 7 ==> tear-prod-rate=reduced 6    conf:(0.86) < lift:(1.71)> lev:(0.1) [2] conv:(1.75)

 3. tear-prod-rate=reduced 12 ==> astigmatism=no contact-lenses=none 6    conf:(0.5) < lift:(1.71)> lev:(0.1) [2] conv:(1.21)

4. 若其它参数保持为默认值,将最小支持度下界设为0.25,上界设为0.8,度量选为杠杆率(leverage:p(a,b)-p(a)p(b),在下面第一条规则中,[4]表示满足lev:(0.19)的实例数目),最小值为0.1,则运行结果找到6条最佳关联规则,前3条如下:

1. tear-prod-rate=reduced 12 ==> contact-lenses=none 12    conf:(1) lift:(1.6) < lev:(0.19) [4]> conv:(4.5)

2. contact-lenses=none 15 ==> tear-prod-rate=reduced 12    conf:(0.8) lift:(1.6) < lev:(0.19) [4]> conv:(1.88)

3. tear-prod-rate=reduced 12 ==> spectacle-prescrip=myope contact-lenses=none 6   

5. 若其它参数保持为默认值,将最小支持度下界设为0.25,上界设为0.8,度量选为确信度(conviction:p(a)p(!b)/p(a,!b)),最小值为1.1,则运行结果找到10条最佳关联规则,前3条如下:

1. tear-prod-rate=reduced 12 ==> contact-lenses=none 12    conf:(1) lift:(1.6) lev:(0.19) [4] < conv:(4.5)>

2. spectacle-prescrip=myope tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1) lift:(1.6) lev:(0.09) [2] < conv:(2.25)>

3. spectacle-prescrip=hypermetrope tear-prod-rate=reduced 6 ==> contact-lenses=none 6    conf:(1) lift:(1.6) lev:(0.09) [2] < conv:(2.25)>

继续阅读