enn tyugu1 algorithms of artificial intelligence lecture 5: learning e. tyugu

27
Enn Tyugu 1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Upload: arron-freeman

Post on 06-Jan-2018

220 views

Category:

Documents


0 download

DESCRIPTION

Enn Tyugu3 Parametric learning A.3.1: class learner: var decision, p,q,a:num; rel encouragement: p,q,decision -> p,q begin if decision==1 -> p:=p+a*q;q:=1-p || decision==0 -> q:=q+a*p;p:=1-q fi end; discouragement: p,q,decision -> p,q begin if decision==1 -> q:=q+a*p;p:=1-q || decision==0 -> p:=p+a*q;q:=1-p fi end; init a:=0.05;

TRANSCRIPT

Page 1: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 1

Algorithms of Artificial Intelligence

Lecture 5: LearningE. Tyugu

Page 2: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 2

LearningLearning is improving a knowledge system by extending or rearranging

its knowledge base or by improving the inference engine. This is one of the most interesting problems of artificial intelligence which is still very little understood. Machine learning comprises computational methods for acquiring new knowledge, new skills and new ways to organize existing knowledge (EAI).

Different levels of learning (D. Michie) - weak learning is improving problem solving abilities by using

examples; - strong learning criterion requires additionally an ability to present the new (learned) knowledge explicitly in the form which is

understandable for a third party, i.e. for other actors besides the learner and teacher - very strong learning is strong learning together with the requirement that the acquired knowledge must be operational for a third party.

Page 3: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 3

Parametric learningA.3.1:class learner:

var decision, p,q,a:num;relencouragement: p,q,decision -> p,q begin if decision==1 -> p:=p+a*q;q:=1-p ||decision==0 ->q:=q+a*p;p:=1-q fi end;discouragement: p,q,decision -> p,q begin if decision==1 ->q:=q+a*p;p:=1-q ||decision==0 -> p:=p+a*q;q:=1-p fi end;init a:=0.05;

Page 4: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 4

Adaptive automatonA.3.2:class linAutom:

varstate,maxstate:num;relencouragement: state,maxstate -> state{ if abs(state) < maxstate ->state:=state+sign(state)}discouragement: state,maxstate -> state{ if abs(state) > 1 thenstate:=state - sign(state) elsestate:=state-2*sign(state)fi};

initmaxstate:=7;

Page 5: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 5

Hypotheses spaceA part of the search space for objects with three properties. Inclusion of concepts(hypotheses) is shown by lines connecting the vectors. Examples are the vectors without *.

Page 6: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 6

A hypotheses space for classification of cells

. . .

. . .. . .

. . . . . .

. . .

......

. . ....

...

. . .

. . .

Page 7: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 7

Specific to general concept learning

1. For each h H that does not match a positive exampe p, replace h with the most specific generalization(s) of h that will match p. 2. Remove from H all hypotheses that match a previously observed

negative instance n N since they are overly general.

3. Remove from consideration all hypotheses that are more specific than some other hypothesis in H.

Step 1 is usually accomplished by finding all mappings between p and h.

If n is a new negative instance, then the algorithm proceeds in the following way:1. Add n to the set of negative instances N.2. Remove from H all hypotheses that match n since they are overly general.

Page 8: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 8

Examples

-

+

N2

P3

P1

P2

N1 -

+

+

Page 9: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 9

A case of specific to general concept learning

(P )1

P P

P P

2 2

3 3 N 1

N 2-

+

N2

P3

P1

P2

N1 -

+

+

Page 10: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 10

Algorithm of specific to general concept learning

The algorithm uses functions:MinGen(p,h) -- set of the most specific generalizations of h

which cover p;Prune(H,N) -- the set of hypotheses from H which are not

covered by any negative instance from N;Match(p,h) -- the predicate which is true iff h covers p.

The predicaate y<x means that the hypothesis x covers the hypothesis y.

The algorithm is represented by three functions AddPositive, AddNegative and Prune

Page 11: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 11

Algorithm of specific to general concept learning

A.3.3: AddPositive(p,H,N) = if empty(H) then H:={p} fi; for h H do

if NoMatch(p,h) then dH:=MinGen(p,h);dH:=Prune(dH,N);for x dH do for y H do

if y < x then H:=H\

{y}fi

odod;H:=H dH\{h}

fi od

Page 12: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 12

Algorithm of specific to general concept learning

continuedA.3.4: AddNegative(n,N) = N:=N {n};

Prune(H,n)

Prune(x,y) = for h x dofor n y do

if Match(n,h) then x:=x \{h} fi

odod

Page 13: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 13

Let H be the current set of hypotheses and P be the set of positive examples. If a negative

example appears, then the algorithm proceeds in the following way:

1. Each hypothesis in H that matches a negative example will be replaced by its most general specialization(s) that will not match the negative instance.

2. All hypotheses which are more general than some other hypotheses will be removed.3. The hypotheses which fail to match all positive examples will be removed,

since they are overly specific.

The first step can be accomplished by finding differences between the negative example

and positive examples associated with the hypothesis.

If a positive example appears, then the algorithm does the following:

1. The positive example will be added to the set P of positive examples.2. All hypotheses which fail to match the new positive example will be removed

from the set H of hypotheses.

General to specific concept learning

Page 14: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 14

Algorithm of general to specific concept learning

Spec(n,h) -- set of the most general specializations of h that do not match n.Prune(dH,P) -- removes from dH all hypotheses that fail to match some positive example in P. Match(n,h) -- a predicate which is true if the hypothesis h covers the example

n.

A.3.5: AddNegative(n,H) = for h H do

if Match(n,h) then dH:=Spec(n,h);dH:=prune(dH,P);for x dH do

for y H do if x < y then dH:=dH \ {y} fi

ododH:=H dH\ {h} fi od

A.3.6: AddPositive(p,P) = P:=P {p}; Prune(H,{p})

Page 15: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 15

Inductive inference Let us have a problem where the goal is to learn a primitive recursive function from examples that are pairs of arguments and function values. This is an inductive inference problem, where one has to generalize on the basis of partial information.

Primitive recursive functions are put together from very simple pieces. For instance, we can take the constant 0 (zero), operation +1 (plus one) and an iterator I that prescribes a repetition of

computations described as one argument of I the number of times given as its

another argument. This set of building blocks is sufficient to build a

description of any primitive recursive function.

Page 16: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 16

Inductive inference The set of all primitive recursive functions is

enumerable. This means that one can start building these functions in some regular way, starting from those which have the simplest (shortest) descriptions and continue the process as long as needed to reach the description of any particular primitive recursive function. Besides that, the primitive recursive functions are total functions -- when applied to any natural number, they will give the answer.

Theorem: There exists an algorithm which, for any given sequence of pairs (x1,y1), (x2,y2), ... , (xn,yn), constructs a primitive recursive function which computes values y1, y2, ... , yn from arguments x1, x2, ... , xn respectively.

Page 17: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 17

Inductive inference The following is a general description of an algorithm of

inductive inference which uses the function nextfun(f) for getting the function next to the given function f, and the function firstfun() for taking the first function under consideration:

A.3.7: f:=firstfun(); L: do for i to n doif f(xi) yi then nextfun(f); continue L fi; od; success(f); od

Page 18: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 18

Learning with an oracleexamples -- examples for learningknown -- background knowledgegeneralize(e,k) -- generalizes examples e by using background

knowledge kand produces a new hypothesisinstantiate(h,e) -- uses facts from examples e and builds a new

instance of the hypothesis hask_oracle(i) -- asks an oracle whether the instance i is correct.

A.3.8:do hypthesis:=generalize(examples,known);instance:=instantiate(hypothesis,examples);accept:=askoracle(instance);if accept then success(hypothesis) fi od

Page 19: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 19

Inductive logic programming Let us consider the resolution step shown in figure. If the literals are

propositional variables, then we can reconstruct the clause A<-B from the resolvent B and the premise A, and also we can reconstruct the clause A from B and A<-B. One can do it even with predicates and in the presence of unification. Both ways are used in learning. This is using a resolution in the reverse way, i.e. inverting the resolution. The clause B has the role of an example, whereas one of the premises which is given represents the background information known in advance. Applying this kind of reasoning, one is able to learn (to extend) theories represented in the form of Horn clauses. This is called inductive logic programming.A A -> B

B However, the search can be done over more background knowledge. The

hypothesis space is a set of clauses, i.e. the hypothesis language is very expressive.

Page 20: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 20

Unifitseerimisega ILP

As ja A <- B` järgi B leidmiseks tuleb analüüsida A ja As erinevusi, tuletada neist s ning rakendada selle pöördtehet B`-le.

Page 21: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 21

Unifitseerimisega ILP (järg)

   

Teatud juhtudel on võimalik leida ka kadunudliteraali L (ja selle predikaati!). Selleks peavad olema käepärast kaks resolventi: A B1 ja A B2.

Page 22: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 22

Example Background knowledge: Positive examples:parent(pam,bob) female(pam) hasDaughter(tom) parent(tom,bob) female(liz) hasDaughter(bob)parent(tom,liz) female(ann)parent(bob,ann) female(pat) Negative examples:parent(bob,pat) hasDaughter(pam)parent(pat,jim) hasDaughter(jim)

Correct hypothesis:hasDaughter(X) :- parent(X,Y), female(Y)

Page 23: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 23

Genetic algorithmsA genetic algorithm can be explained in biological terms. The goal of the algorithm is to develop by evolution objects which are good in some sense. The objects are presented by their codes which are called chromosomes. The algorithm is presented by means of the following four components:

1. method of encoding of objects on chromosomes;2. fitness function -- evaluation function of chromosomes;3. method of initialization of chromosomes;4. mechanism of reproduction which consists of • selection of chromosomes for reproduction, • crossover and • mutation mechanisms.

Page 24: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 24

Genetic algorithmA.3.9: for i:= to MaxGenes do

GenePool[i]:=CreateRandomGene();od;for Generation 1 to MaxGenerations do

for i:=1 to MaxGenes do

FitnessValue[i]:=EvaluateGene(Genepool[i])od;Normalize(FitnessValue);SelectPairs();Crossover();Mutation(MutationProbability)

od

Page 25: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 25

ExampleFind an algorithm for solving the system of equations:

ax + by = cdx + ey = f, where ae - bd =1.

Fitness function:1fitness = ----------------------------------------------1 + (ax + by - c)^2 + (dx + ey - f)^2

The latter is a specific case of

1fitness = .1 + (currentvalue - correctvalue)2

Page 26: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 26

Example of crossover

-+

*de c

a e

*+

*

b f

d

+

-a

b

Crossover = cut and swap

Page 27: Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 5: Learning E. Tyugu

Enn Tyugu 27

Bibliography

• Muggleton, S., Buntine, W. (1988) Machine invention of First-Order Predicates by Inverting Resolution. Proc. 5th International Conference on Machine Learning. Morgan Kauffmann.