第4章数据挖掘 - 福建省粒计算及其应用重点实验室

Download Report

Transcript 第4章数据挖掘 - 福建省粒计算及其应用重点实验室

数据的背后
闵帆 博士·副教授
漳州师范学院粒计算重点实验室 砺志楼414
作业:[email protected]
答疑:周四全天(包括晚上)
http://grc.fjzs.edu.cn/~fmin/
1
数据库表Weather
No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Outlook
sunny
sunny
overcast
rain
rain
rain
overcast
sunny
sunny
rain
sunny
overcast
overcast
rain
Temperature
hot
hot
hot
mild
cool
cool
cool
mild
cool
mild
mild
mild
hot
mild
Humidity
high
high
high
high
normal
normal
normal
high
normal
normal
normal
high
normal
high
Windy
false
true
false
false
false
true
true
false
false
false
true
true
false
true
Play
N
N
P
P
P
N
P
N
P
P
P
P
P
N
2
问题



有多少种可能的组合?
试比较记录No. 1与No. 2,可得到什么结论?
试比较记录No. 5与No. 6,可得到什么结论?
3
第一章 决策树
令Play为决策属性,以
Outlook -> Temperature -> Humidity ->
Windy
的顺序构造一棵决策树
4
决策树
Outlook
Sunny
Overcast
P
Temperature
Hot
N
Cool
P
Temperature
Cool
Mild
Humidity
Normal
P
Rain
Mild
Humidity
Humidity
High
Normal
Normal
N
P
Windy
False
P
Windy
True
N
High
False
P
True
N
5
课堂练习
以Temperature -> Outlook -> Windy ->
Humidity
与
Humidity -> Windy -> Temperature ->
Outlook
的顺序各构造一棵决策树

6
问题



不同的顺序导致决策树的大小是否相同?
不同的决策树进行分类的效果是否相同?
试构造一个新实例,它导致分类结果不同。
7
讨论



决策树越大越好还是越小越好?
Occam’s razor(上网搜索)
复杂的模型导致过度拟合,简单模型则有
更好的归纳能力
8
课堂练习

构造一棵最小的决策树,不同的分支可用
不同属性
9
最小决策树
Outlook
Sunny
Overcast
P
Humidity
High
N
Rain
Windy
False
Normal
P
P
True
N
10
ID3算法



Step 1. 选择合适的属性,使其信息增益最
大;
Step 2. 根据该属性将数据分成几个子集;
Step 3. 针对各子集重复以上步骤,直到所
有子集是“纯” 的,或者没有属性可用。
11
信息增益计算方法

选择属性时不需要计算I(p, n),因为对于
不同属性该值相同
12
Congratulations!

你已经掌握了数据挖掘最重要的算法!
13
作业2

Weka的安装与使用
 下载JDK, Weka
 安装
 运行Weka,测试数据集
Weather.nomimal
14
运行选项


Classifier: trees -> Id3
Test option: Using training set
15
结果
outlook = sunny
| humidity = high: no
| humidity = normal: yes
outlook = overcast: yes
outlook = rainy
| windy = TRUE: no
| windy = FALSE: yes
16
Woooo!


你已经能用决策树来分析自己的数据!
问题:分析的效果如何?
17
训练与测试


用一部分数据来训练分类器(决策树)
另外的数据来测试该分类器的效果
18
iris.nominal.arff运行结果
Test option: Percentage split 60%
=== Confusion Matrix ===
a b c <-- classified as
12 0 0 | a = Iris-setosa
0 11 2 | b = Iris-versicolor
0 0 10 | c = Iris-virginica

19
连续属性值


用C4.5(J48)
选择合适的断点(离散化)
20
iris.arff运行结果(树)
66%训练,其余测试
petalwidth <= 0.6: Iris-setosa (50.0)
petalwidth > 0.6
| petalwidth <= 1.7
| | petallength <= 4.9: Iris-versicolor (48.0/1.0)
| | petallength > 4.9
| | | petalwidth <= 1.5: Iris-virginica (3.0)
| | | petalwidth > 1.5: Iris-versicolor (3.0/1.0)
| petalwidth > 1.7: Iris-virginica (46.0/1.0)
21
iris.arff运行结果(准确率)
=== Confusion Matrix ===
a b c <-- classified as
15 0 0 | a = Iris-setosa
0 19 0 | b = Iris-versicolor
0 2 15 | c = Iris-virginica
22
作业3

专业数据分析
构造你所学专业数据
 用ID3或C4.5分析
 上传源数据与运行结果

23
参考文献
[1] J.R. Quinlan, Induction of Decision
Trees, Machine learning 1: 81-106,
1986 (被引用次数9054)
24
第二章 属性约简与属性值约简


属性约简是粗糙集的一个重要问题
动机
 删除冗余属性以加快学习速度,提
高分类器精度(多数属性约简工作
的目标)
 减少数据获取的代价,即测试代价
(闵帆的最新研究重点)
25
决策表的属性约简

在Weather决策表中,哪些属性去掉
后,不影响分类器(如决策树)的生
成?
26
数据库表Weather
No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Outlook
sunny
sunny
overcast
rain
rain
rain
overcast
sunny
sunny
rain
sunny
overcast
overcast
rain
Temperature
hot
hot
hot
mild
cool
cool
cool
mild
cool
mild
mild
mild
hot
mild
Humidity
high
high
high
high
normal
normal
normal
high
normal
normal
normal
high
normal
high
Windy
false
true
false
false
false
true
true
false
false
false
true
true
false
true
Play
N
N
P
P
P
N
P
N
P
P
P
P
P
N
27
删除Windy
No.
1
2
8
11
9
4
14
10
5
6
7
12
13
3
Outlook
sunny
sunny
sunny
sunny
sunny
rain
rain
rain
rain
rain
overcast
overcast
overcast
overcast
Temperature
hot
hot
mild
mild
cool
mild
mild
mild
cool
cool
cool
mild
hot
hot
Humidity
high
high
high
normal
normal
high
high
normal
normal
normal
normal
high
normal
high
Play
N
N
N
P
P
P
N
P
P
N
P
P
P
P
28
删除Humidity
No.
1
2
8
11
9
4
10
14
5
6
7
12
13
3
Outlook
sunny
sunny
sunny
sunny
sunny
rain
rain
rain
rain
rain
overcast
overcast
overcast
overcast
Temperature
hot
hot
mild
mild
cool
mild
mild
mild
cool
cool
cool
mild
hot
hot
Windy
false
true
false
true
false
false
false
true
false
true
true
true
false
false
Play
N
N
N
P
P
P
P
N
P
N
P
P
P
P
29
删除Temperature

?
30
删除Outlook

?
31
讨论

哪些属性可以被约简?
有哪些约简?

{Outlook, Humidity, Windy}
 {Outlook, Temperature, Windy}
可否有多个属性被同时约简?


32
最小约简


属性数量最少的约简被称为最小约简
Zoo有33个约简,最小的有5个属性,最多
的有7个
 { a2, a3, a5, a7, a12 }
 { a0, a2, a5, a7, a10, a12 }
 { a0, a2, a5, a6, a9, a11, a12 }
 { a0, a2, a5, a7, a11, a12 }
 ......
33
最小测试代价约简

假设各属性的测试代价如下:
Outlook Temperature Humidity Windy
¥1
¥2
¥3
¥4

哪个约简为最小代价约简?
34
问题



为什么要找最小约简?
为什么要找最小测试代价约简?
两个问题有什么关系?
35
核属性


包含在所有约简中的属性
本例中为{Outlook, Windy}
36
属性值约简

把某属性值设为“不关心”,用*表示
37
获得的特殊决策表
No. Outlook Temperature
Windy Play
1
sunny
hot
false
N
2 把某属性值设为“不关心”,用*表示
sunny
hot
true
N
8
sunny
mild
false
N
11
sunny
mild
true
P
9
sunny
cool
false
P
4
rain
mild
false
P
10
rain
mild
false
P
14
rain
mild
true
N
5
rain
cool
false
P
6
rain
cool
true
N
7
overcast
cool
true
P
12
overcast
mild
true
P
13
overcast
hot
false
P
3
overcast
hot
false
P
38
生成规则集合(课堂演示)
No. Outlook Temperature
Windy Play
1
sunny
hot
false
N
2 把某属性值设为“不关心”,用*表示
sunny
hot
true
N
8
sunny
mild
false
N
11
sunny
mild
true
P
9
sunny
cool
false
P
4
rain
mild
false
P
10
rain
mild
false
P
14
rain
mild
true
N
5
rain
cool
false
P
6
rain
cool
true
N
7
overcast
cool
true
P
12
overcast
mild
true
P
13
overcast
hot
false
P
3
overcast
hot
false
P
39
Yes!

你已经掌握了基于属性值约简的规则
生成算法!
40
最新进展

带测试代价约束条件的属性约简
 由于代价原因,无法获得一个真正
的约简
41
LEM2 算法

在Rses中使用LEM2算法生成规则集合。
42
参考文献
[1] Z. Pawlak, “Rough sets”, International Journal of
Computer and Information Sciences, 11: 341-356, 1982.
(被引用次数6887)
[2] A. Skowron and C. Rauszer, “The discernibility matrics
and functions in information systems”, Intelligent
Decision Support: 331-362, 1992.
[3]F. Min, H, He, Y. Qian, and W. Zhu, “Test-cost-sensitive
attribute reduction”, Information Sciences, vol. 181, Issue
22, pp. 4928-4942, November 2011. (Most read)
43