machine learning: machine learning:

6
1 Machine Learning: Machine Learning: Inductive Logic Programming Inductive Logic Programming Dr Valentina Plekhanova University of Sunderland, UK Valentina Plekhanova Machine Learning: ILP 2 Formalisms in Inductive Learning Formalisms in Inductive Learning Learning the Learning the attribute attribute descriptions descriptions, e.g. Decision Tree , e.g. Decision Tree Learning the Learning the first first-order relational order relational descriptions, e.g. ILP descriptions, e.g. ILP Valentina Plekhanova Machine Learning: ILP 3 ILP: a Framework ILP: a Framework Theoretical Setting Theoretical Setting: : Inductive Logic Programming Inductive Logic Programming Task Task: : Concept Learning Concept Learning Methods Methods: : Inductive Leaning Inductive Leaning Algorithms Algorithms: : FOIL FOIL

Upload: butest

Post on 05-Dec-2014

1.256 views

Category:

Documents


16 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Machine Learning: Machine Learning:

1

Machine Learning:Machine Learning:Inductive Logic ProgrammingInductive Logic Programming

Dr Valentina PlekhanovaUniversity of Sunderland, UK

Valentina Plekhanova Machine Learning: ILP 2

Formalisms in Inductive LearningFormalisms in Inductive Learning

Learning theLearning the attributeattribute descriptionsdescriptions, e.g. Decision Tree, e.g. Decision Tree

Learning theLearning the firstfirst--order relationalorder relational descriptions, e.g. ILPdescriptions, e.g. ILP

Valentina Plekhanova Machine Learning: ILP 3

ILP: a FrameworkILP: a Framework

•• Theoretical SettingTheoretical Setting: : Inductive Logic ProgrammingInductive Logic Programming•• TaskTask: : Concept LearningConcept Learning•• MethodsMethods: : Inductive LeaningInductive Leaning•• AlgorithmsAlgorithms: : FOILFOIL

Page 2: Machine Learning: Machine Learning:

2

Valentina Plekhanova Machine Learning: ILP 4

Inductive Logic ProgrammingInductive Logic Programming

Inductive Logic Programming , where Inductive Logic Programming , where I I stands stands for induction in machine learning, for induction in machine learning, LPLP stands for logic stands for logic programming. programming.

LPIILP ∩=

Valentina Plekhanova Machine Learning: ILP 5

Inductive Concept Learning: Inductive Concept Learning: DefinitionDefinition

Given a set Given a set EE of positive and negative examples of concept of positive and negative examples of concept CC , , find a hypothesis find a hypothesis H H , expressed in a given concept description , expressed in a given concept description language language LL , such that , such that

every positive example is covered by every positive example is covered by HH

no negative examples are covered by no negative examples are covered by HH

( ( H H is "complete and consistent").is "complete and consistent").

+Ε∈ε−Ε∈ε

Valentina Plekhanova Machine Learning: ILP 6

Inductive Logic Programming: Inductive Logic Programming: a Methoda Method

ReminderReminder: Induction means reasoning from specific : Induction means reasoning from specific to general. to general. In the case of inductive leaning from examples, the In the case of inductive leaning from examples, the learner is given some examples from which general learner is given some examples from which general rules or a theory underplaying the examples are rules or a theory underplaying the examples are derived. derived. Inductive inference can involve the use ofInductive inference can involve the use ofbackground knowledgebackground knowledge to construct ato construct a hypothesis hypothesis which agrees with some set ofwhich agrees with some set of examplesexamples according toaccording torelationshiprelationship..

Page 3: Machine Learning: Machine Learning:

3

Valentina Plekhanova Machine Learning: ILP 7

Definitions

Clause Clause -- component of a (complex) sentence, with its own component of a (complex) sentence, with its own subject and predicate.subject and predicate.

PredicatePredicate -- part of a statement which says something about part of a statement which says something about the subject ,e.g. "the subject ,e.g. "is shortis short" in "" in "Life is shortLife is short". ".

Subject Subject -- (contrasted with predicate) word(s) in a sentence (contrasted with predicate) word(s) in a sentence about which something is predicated (contrasted with about which something is predicated (contrasted with object), e.g.object), e.g. LifeLife..

InferenceInference -- process of inferring process of inferring -- to get conclusion or to reach to get conclusion or to reach an option from facts or reasoning. an option from facts or reasoning.

Valentina Plekhanova Machine Learning: ILP 8

ILPILPIn an ILP problem the task is to define, from given examples, anunknown relationunknown relation (i.e. the target predicate) in terms of (itself and) known relations from background knowledge.

In ILP, theIn ILP, the training examplestraining examples, the, the background knowledgebackground knowledge and and thethe induced hypothesesinduced hypotheses are all expressed in a logic program are all expressed in a logic program form, with additional restrictions imposed on each of theform, with additional restrictions imposed on each of the three three languageslanguages. .

For example, training examples are typically represented as For example, training examples are typically represented as ground facts of the target predicate, and most often background ground facts of the target predicate, and most often background knowledge is restricted to be of the same form.knowledge is restricted to be of the same form.

Valentina Plekhanova Machine Learning: ILP 9

FirstFirst--Order Predicate LogicOrder Predicate Logic- formal framework for describing and reasoning about objects, their parts, and relations among the objects and/or the parts. An important subset of first-order logic is Horn clauses: grandparent (X,Y) ← parent (X, Z), parent (Z,Y)

where

grandparent (X,Y) - head of clause or postcondition,

parent (X, Z), parent (Z,Y) - body of clause or precondition,

grandparent, parent - predicates; a Literal is any predicate or its negation,

(X,Y), (X,Z), (Z,Y) - arguments,

X, Y, Z - variables,

comma between predicates means "conjunction", ← means

IF IF (body of clause) THEN THEN (head of clause )

Page 4: Machine Learning: Machine Learning:

4

Valentina Plekhanova Machine Learning: ILP 10

Reasons for ILP

ILP is very convenient learning because there are two reasons:

ILP is based on the sets of IF-THEN rules (logic) - one of the most expressive and human readable representations for learned hypotheses.

ILP can be viewed as automatically inferring PROLOG programs from examples. PROLOG is a programming language in which programs are expressed as collections of Horn clauses.

Any sets of first-order Horn clauses can be interpreted as programs in the logic programming language PROLOG, so learning them (Horn clauses) is often called inductive logic programming (ILP).

Valentina Plekhanova Machine Learning: ILP 11

ILP Problem: an ExampleILP Problem: an Example

•• Illustration of the ILP task on a simple problem of learning Illustration of the ILP task on a simple problem of learning family relations.family relations.

•• Example Example –– an ILP Probleman ILP Problem•• The taskThe task is to define the target relationis to define the target relation daughter (x,y)daughter (x,y) which which

states that personstates that person xx is a daughter of personis a daughter of person yy, in terms of the , in terms of the background knowledge relationsbackground knowledge relations femalefemale andand parentparent..

•• These relations are given in the following table.These relations are given in the following table.•• There areThere are two positivetwo positive and and two negativetwo negative examples examples

of the target relation.of the target relation.⊕ Θ

Valentina Plekhanova Machine Learning: ILP 12

A Simple ILP Problem: A Simple ILP Problem: Learning theLearning the daughterdaughter RelationRelation

Training ExamplesTraining Examples Background KnowledgeBackground Knowledge Background KnowledgeBackground Knowledge

daughter (mary, ann) parent (ann, mary) female(ann)

daughter (eve, tom) parent (ann, tom) female(mary)

daughter (tom, ann) parent (tom, eve) female(eve)

daughter (eve, ann) parent (tom, ian)

Θ

Θ

In the hypothesis language of Horn clauses it is possible to forIn the hypothesis language of Horn clauses it is possible to formulate the mulate the following definition of target relation:following definition of target relation:

daughter (x,y) female (x), parent (y,x)daughter (x,y) female (x), parent (y,x)

Page 5: Machine Learning: Machine Learning:

5

Valentina Plekhanova Machine Learning: ILP 13

FOIL AlgorithmFOIL AlgorithmINPUT:INPUT: B, EB, E++, E, E--, H=, H=∅∅

R = p(XR = p(X11,,……,,XXnn)) ←←

WHILEWHILE EE++≠≠ ∅∅ DODO

WHILEWHILE There are examples in There are examples in EE –– , i.e. , i.e. ∃∃ e e ∈∈ E E -- , ,

i.e. that are still covered by i.e. that are still covered by HH∪∪ {R}{R} DODO

find the find the best Literal best Literal L L ((via via FOIL_GainFOIL_Gain)) to add this Literal to add this Literal L L to to RR

R R = = R R ←← LL

E E -- == E E -- \\ {{e e ∈∈ EE-- || that does not satisfy that does not satisfy R R }}

END END

H = H H = H ∪∪ {R}{R}

EE+ + = E= E+ + \\ {{e e ∈∈ E E + + || HH}}

i.e. {The examples in i.e. {The examples in EE+ + , that are covered by , that are covered by B,B, are removed}are removed}

ENDEND

OUTPUT:OUTPUT: HH

Valentina Plekhanova Machine Learning: ILP 14

FOIL AlgorithmFOIL AlgorithmConsider some ruleConsider some rule RR, and a candidate literal, and a candidate literal LL that might be that might be added to the body ofadded to the body of RR. Let. Let RR′′ be the new rule created by adding be the new rule created by adding literalliteral LL toto RR..

The valueThe value Foil_Gain (L, R)Foil_Gain (L, R) of addingof adding LL toto RR is defined asis defined as

Foil_Gain (L, R)=t { logFoil_Gain (L, R)=t { log2 2 [p[p1 1 / (p/ (p11+n+n11)])]--loglog2 2 [p[p0 0 / (p/ (p00+n+n00)] })] }

wherewhere pp00 is the number of positive bindings of ruleis the number of positive bindings of rule RR,, nn00 is the is the number of negative bindings ofnumber of negative bindings of RR,, pp11 and and nn11 -- for rulefor rule RR′′. .

tt is the number of positive bindings of ruleis the number of positive bindings of rule RR that are still that are still covered after adding literalcovered after adding literal LL to to RR.. Foil_GainFoil_Gain value has an value has an interpretation in terms of information theory (interpretation in terms of information theory ( --loglog22[p[p0 0 /(p/(p00+n+n00)])]is the entropy).is the entropy).

Valentina Plekhanova Machine Learning: ILP 15

FOIL AlgorithmFOIL Algorithm: : an Examplean ExampleRule1: daughter (X,Y) ←

TT11: : (Mary, Ann)(Mary, Ann) + p+ p11 = 2= 2 LL11 = female (X)= female (X)

(Eve, Tom)(Eve, Tom) + n+ n11 = 2 Foil_G= 2 Foil_Gain_Lain_L11 = = ……

(Tom, Ann)(Tom, Ann) -- tt11 = = …… LL22 = parent (Y,X)= parent (Y,X)

(Eve, Ann)(Eve, Ann) -- Foil_Gain_LFoil_Gain_L22 = = ……

Rule2: daughter (X,Y) ← female (X)

TT22: : (Mary, Ann)(Mary, Ann) + p+ p22 = 2= 2 LL22 = parent (Y,X)= parent (Y,X)

(Eve, Tom)(Eve, Tom) + n+ n22 = 1 Foil_G= 1 Foil_Gain_Lain_L22 = = ……

(Eve, Ann)(Eve, Ann) -- tt22 = = ……

Rule3: daughter (X,Y) ← female (X), parent (Y,X)

T3: T3: (Mary, Ann)(Mary, Ann) + p+ p33 = 2 Final rul= 2 Final rule e -- ……??

(Eve, Tom) (Eve, Tom) + n+ n33 = 0 = 0

tt33 = = ……

Page 6: Machine Learning: Machine Learning:

6

Valentina Plekhanova Machine Learning: ILP 16

Complete & ConsistentComplete & Consistent

Prior Prior satisfiablitysatisfiablity: : Before we take any hypothesis into account Before we take any hypothesis into account we cannot make any conclusions with respect to the negative we cannot make any conclusions with respect to the negative examples and the background knowledge. This is needed for the examples and the background knowledge. This is needed for the negative examples that have to conflict the background negative examples that have to conflict the background knowledge.knowledge.

Posterior Posterior satisfiabilitysatisfiability:: It means a negative example cannot be It means a negative example cannot be derived fromderived from Hypothesis Hypothesis and and Background Knowledge.Background Knowledge.

Valentina Plekhanova Machine Learning: ILP 17

Complete & ConsistentComplete & Consistent

Prior NecessityPrior Necessity:: Some positive examples may simply be a Some positive examples may simply be a conclusion from the background knowledge, but not all. conclusion from the background knowledge, but not all.

Posterior SufficiencyPosterior Sufficiency: To verify that all positive examples : To verify that all positive examples are covered by the background knowledge and the are covered by the background knowledge and the hypothesis. If the hypothesis satisfies this condition we call hypothesis. If the hypothesis satisfies this condition we call it complete.it complete.

Valentina Plekhanova Machine Learning: ILP 18

ID3 ID3 vsvs FOILFOIL

ID3:ID3:Learner learnsLearner learns attribute descriptions. descriptions. There are limitations, e.g. limited representational formalism.There are limitations, e.g. limited representational formalism.Limited capability of taking into account the available Limited capability of taking into account the available

background knowledge.background knowledge.

Foil:Foil:Object can be describedObject can be described structurally, i.e. in terms of their , i.e. in terms of their

components and relations among the components.components and relations among the components.Learner learnsLearner learns first-order relational descriptions.descriptions.The The given relations constitute theconstitute the background knowledge..