
Chinese: 
大家好，欢迎学习More Data Mining with Weka第三部分。
这一部分，我们要来学习规则和聚类。
前几节课，我们来学习决策规则。
I这节课，我们从抽象的层面来对比规则和决策树。
下节课，我们来看如何创建决策规则。
在课程Data Mining with Weka中，我们提到过很多次决策树。
对于任何决策树，我们都可以得到一组等效规则。
我们需要查看叶节点。
对于五个叶节点中的任一节点，我们只需要读取叶节点之上的条件，
即从根节点到叶节点的条件。

English: 
Hello again! Welcome to Class 3 of More Data
Mining with Weka.
In this class, we're going to look at rules
and clustering.
In the first couple of lessons, we're going
to look at decision rules.
I'm going to look in this lesson at rules
versus trees, in abstract, as it were.
In the next lesson, we'll look at how to generate
decision rules.
We talked a lot about decision trees in Data
Mining with Weka.
For any decision tree, you can read off an
equivalent set of rules.
You just go along the leaves.
For each of the five leaves, you just read
off the conditions above that leaf that get
you from the root to the leaf.

English: 
"If outlook is sunny and humidity is high
then 'no'"--that's a rule corresponding to
the left-most leaf.
That's easy.
We call this a "decision list" if we execute
these rules in order.
If we execute them in order, then we can delete
some of these clauses.
We can delete the "and humidity is normal"
in the second rule, because we've already
dealt with the "humidity is high" case in
the first rule, and there are no other options--if
it's not high, it's got to be normal.
Similarly, in the fourth rule, we can delete
the "outlook = rainy" bit, because we've already
dealt with sunny and overcast, and if we pass
through those rules, then the outlook has
got to be rainy.
Using this technique, if we execute our rules
as a decision list, we can make the rule set
a little bit simpler.
There are other rule sets that are equivalent
that are even simpler.

Chinese: 
如果天气晴朗，湿度大，即为no--这是和最左边叶节点
对应的规则。
这很简单。
如果我们按顺序执行这些规则，就得到决策表。
如果我们按顺序执行这些规则，便可删除一些条件。
我们可以删除第二条规则中的“湿度正常”，因为我们已经
在第一条规则中处理了“湿度大”的情况，这里没有其他的选择
如果湿度不大，就会是正常。
同理，在第四条规则中，我们可以删除“雨天”，因为我们已经
处理了晴天和阴天，除去这些条件，
天气就只有雨天。
使用这样的技巧，如果我们将规则做成决策表，
规则集会略微简单。
这里有其他同等或更简单的规则集。

Chinese: 
来看这个包含三个规则的数据集。
想想：会不会有对应的决策树？通过决策树，我们可以找到规则；
通过规则，我们能创建决策树吗？答案是可以。
这比之前的例子稍微抽象些。
可以看到：如果x=1,y=1,得到a。
如果z=1,w=1,也是a。
其他情况是b。假设x和y都有三个可能的数值，
我们用x和y从左侧分支，
如果它们的值都是1，就是a，非常好！不然，如果y=2，我们就要看
z和w的值。
也就是下面这个灰色的树，有点复杂。
更复杂的是，我们要重复这个决策树。
如果y=3，我们要重复这个决策树。
这个小的灰三角表示重复灰色的树。
图中共有四个同样的决策树。

English: 
Let's look at this 3-rule set.
Imagine: is there an equivalent tree? For
any tree, you can make rules; for any set
of rules, can you make a tree? The answer
is, you can.
This is slightly more abstract than the previous
example.
I've got: "If x=1 and y=1 then a.
If z=1 and w=1 then a.
Otherwise, b." I'm assuming that both x and
y have three possible values.
We branch on x and y down the left-hand branch.
If they're both 1, that's a; fantastic! Otherwise,
though, if y=2, then we've got to check z
and w.
That's done in that gray tree underneath,
which is a little bit complex.
To make matters much worse, we've got to repeat
this tree.
If y=3, then we've got to repeat the same
tree.
That little gray triangle stands for that
whole gray tree replicated.
There are a total of 4 copies of it in this.

Chinese: 
我们从简单规则集开始，以复杂决策树结束，
因此，在一定意义上，树和规则是同等的。
它们可以描述同样的事物：有决策树，就可以总结出规则集；
有规则集，就可以创建决策树。
但在实践中，它们非常不同。
因为如果规则被制成决策表，并且顺序执行，
会比决策树小得多。
人们喜欢规则：它们容易阅读和理解。
规则被视为独立的“知识块”。
如果制成决策表--这是通常的做法--那么对规则的解释必要考虑
之前规则。
规则并不真正相互独立，尽管看上去像。
创建规则的方法之一是--假设你想创建规则--创建决策树。

English: 
We start with a rather simple set of rules,
and we end up with a pretty complicated tree.
So in one sense, trees and rules are equivalent.
They can describe the same things: given a
tree, you can create a set of rules; given
a set of rules, you can create a tree.
But in practice, they're very different.
Because--particularly if rules are expressed
as a decision list and they're executed in
order--they can be much smaller than trees.
People like rules: they're easy to read and
understand.
It's tempting to view them as independent
"nuggets of knowledge".
If you're executing them as a decision list--and
you usually are--then the meaning of the rule
must be taken in the context of the rules
that precede it.
They don't really stand independently, although
they look like they do.
One way of creating rules--let's say you want
to create rules--you could just create a decision tree.

English: 
We know how to do that--the top-down, divide-and-conquer
method used by J48--and read rules off the
tree, one rule for each leaf, like we did
at the beginning.
Very straightforward, but the rules will contain
repeated tests.
You can get rid of some of those quite easily,
but more effective conversions are not so
easy to do.
Another completely different approach for
generating rules is to do it bottom-up, a
"covering method" that's called separate-and-conquer.
We work on the different classes in turn.
For each class, in turn, we find the rules
that cover all its instances.
We do that by first identifying a useful rule,
then separating out those instances it covers;
and then carry on and conquer the remaining
instances in that class, finding more rules
for them.
Here's a simple little example.
We're going to generate a rule for class a.
We start out with a rule that says "Everything
is class a!" Of course, that rule is not correct.
So, we add clauses to that rule.

Chinese: 
我们知道如何做--J48使用的自上而下，分而治之的方法--从决策树读取规则，
每个叶节点是一个规则，就像我们在这节课开始做的一样。
非常直接，但是规则会包括重复的测试。
我们可以很容易删除那些重复的测试，但是更为有效的变换却不容易。
却不容易。
另一个截然不同的创建规则的方式是自下而上，
“覆盖算法”，也叫做割治算法。
我们依次处理不同的分类。
针对每个类别，我们寻找能覆盖所有实例的规则。
We do that by first identifying a useful rule,
then separating out those instances it covers;首先找到一个有用的规则，然后用它划分实例
然后继续寻找能覆盖同一类别中剩余
实例的规则。
这有一个简单的小例子。
我们要为类别a创建规则。
我们从“所有实例都属于类别a”开始，当然，这条规则并不正确。
我们来增加条件。

English: 
"If x>1.2 then class=a." That rule is still
not correct, but it's better than the first rule.
Then we can add another clause to make it
even more correct: "If x>1.2 and y>2.6, then
class=a." That's completely correct.
It does miss out one other a.
We could add a new rule for that, or we could
decide that maybe we don't need to because
it's just one instance that's being missed
out.
Then, for a rule for class b, we could say
"if x<=1.2 than class=b": that gets half of them.
Another rule could be "if x>1.2 and y<=2.6,
then class=b." We could get rid of the first
test if we knew those rules were going to
be executed in order.
We could add more rules to get a perfect rule
set, or we could stop there with the rules
that we have.
The termination conditions are something that
you have to decide on when you devise a rule-making
algorithm.

Chinese: 
“如果x>1.2,类别为a。”这条规则还是不正确，但是比第一条强。
然后我们增加另一个条件使规则更为正确：“如果x>1.2 且 y>2.6,类别为a。”
这就很确切了。
规则确实漏掉了一个a。
我们可以为这个实例增加一条新的规则，或者我们可以选择不增加，
因为只漏掉了一个实例。
然后，类别b的规则，我们可以设定“如果x<=1.2,类别为b。”，得到半数的实例。
另一条规则为“如果x>1.2 且y<=2.6,类别为b。”这样我们不需要第一个测试，
如果我们知道这些规则会依次执行。
我们可以增加更多的规则来制定完美的规则集，或者
可以就此停止。
当你创建规则的算法时，你必须决定
终止的条件。

English: 
Here's a decision tree that corresponds to
the rule set we just looked at.
Rules sets can be more perspicuous than decision
trees.
Decision trees sometimes have to contain replicated
subtrees.
Also, there's a big difference between the
divide-and-conquer and the separate-and-conquer,
the top-down and the bottom-up algorithms.
In a multi-class situation, the covering algorithm
focuses on one class at a time: it gets rules
for that class.
Whereas the divide-and-conquer decision tree
algorithm takes all the classes into account
when making any of the decisions.
Here are the details of a simple bottom-up,
covering algorithm for creating rules.
It's called PRISM.
It consists of three loops.
The outer loop is over each class.
Then the middle loop is, we're going to cover
some of the instances in that class, and then
carry on creating more rules that can cover
more of the instances until we're satisfied
we've covered enough.

Chinese: 
这是和我们刚才谈到的规则集对应的决策树。
规则集能够比决策树更明了。
决策树有时会包含重复的子树。
而且，分治法和割治算法，自上而下和自下而上的算法，
有很大不同。
针对多类别的情况，覆盖算法一次侧重一个类别，为那个类别
制定规则。
而分而治的决策树算法做决策时
考虑所有类别。
这是一个简单的在下而上的覆盖算法制定规则的详细步骤。
叫做PRISM，
包括三个循环。
最外的循环每个类别。
中间的是要覆盖类别中的一些实例，然后
制定给更多的规则来覆盖大多数实例，直到我们
认为已经覆盖足够多的实例为止。

English: 
The inner loop is taking a rule and adding
clauses to the rule until it's accurate enough.
It's a simple, iterative algorithm for covering
a dataset class-by-class, instance-by-instance,
bottom-up; elaborating the rules with more
conditions as we go along.
That's it.
We've seen that decision trees and rules have
got the same expressive power, but either
can be more perspicuous than the other.
It just depends on the dataset.
Rules can be created using a bottom-up covering
process.
They're often executed as decision lists,
in order.
If rules assign different classes to an instance,
then the first rule wins if you're executing
them in order--which means that the rules
are not really independent nuggets of knowledge.
Still, people like rules, and they often prefer
them to trees.
There's some stuff in the textbook about covering
algorithms for rules, and an activity which

Chinese: 
最里的循环是制定规则，并增加前提条件，直到规则足够准确。
这是一个简单的循环算法，一个类别一个类别地，一个实例一个实例地，自下而上地涵盖数据集；
逐渐增加规则的条件。
这就是我们这节课的内容。
我们学习了决策树和有相同表现力的规则，
两者中任何一个都可能更明了，
这取决于数据集。
规则可以通过自下而上的覆盖过程来创建。
规则通常作为决策表，依次执行。
如果多个规则给一个实例分配了不同的类别，依次执行时，第一条规则会起决定作用
也就是说，这些规则不是独立的知识块。
和决策树相比，人们更喜欢规则。
教材中有些关于覆盖算法的内容和

Chinese: 
为数据集制定规则的练习。
请做练习。下次课见。
再见。

English: 
will make you think about rules for datasets.
Off you go and do that, and we'll see you
in the next lesson.
Bye for now!
