Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:learning_predicate [2019/06/27 15:50] |
pl:prolog:pllib:learning_predicate [2019/06/27 15:50] (aktualna) |
| ====== Learning predicate ====== |
| {{tag>family hyphotesis learning}} |
| ===== Description ===== |
| A definition of the problem of learning predicate has_daughter. |
| |
| **Source**: PROLOG programming for artificial intelligence, 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7. |
| ===== Download ===== |
| Program source code: {{learning_predicate.pl}} |
| ===== Listing ===== |
| <code prolog> |
| % Figure 19.1 A definition of the problem of learning predicate has_daughter. |
| |
| |
| % Learning from family relations |
| |
| % Background knowledge |
| |
| backliteral( parent(X,Y), [X,Y]). % A background literal with vars. [X,Y] |
| |
| backliteral( male(X), [X]). |
| |
| backliteral( female(X), [X]). |
| |
| prolog_predicate( parent(_,_)). % Goal parent(_,_) executed directly by Prolog |
| prolog_predicate( male(_)). |
| prolog_predicate( female(_)). |
| |
| parent( pam, bob). |
| parent( tom, bob). |
| parent( tom, liz). |
| parent( bob, ann). |
| parent( bob, pat). |
| parent( pat, jim). |
| parent( pat, eve). |
| |
| female( pam). |
| male( tom). |
| male( bob). |
| female( liz). |
| female( ann). |
| female( pat). |
| male( jim). |
| female( eve). |
| |
| % Positive examples |
| |
| ex( has_daughter(tom)). % Tom has a daughter |
| ex( has_daughter(bob)). |
| ex( has_daughter(pat)). |
| |
| % Negative examples |
| |
| nex( has_daughter(pam)). % Pam doen't have a daughter |
| nex( has_daughter(jim)). |
| |
| start_hyp( [ [has_daughter(X)] / [X] ] ). % Starting hypothesis |
| </code> |
| ===== Comments ===== |
| |