This code is about using FOIL to realize rule inference for the given knowledge graph, and obtain new knowledge through "deduction". Note: this code was my work as a TA.
- Construct positive examples, negative examples and background knowledge
- Predicates are successively added to inference rules as prerequisite constraint predicates
- The FOIL gain value of the new inference rule was calculated based on positive example, negative example and background knowledge
- The optimal premise constraint predicate was selected based on the calculated FOIL gain value
- If the inference rule covers positive examples in the training sample set, but does not cover any negative examples, the learning ends.
Note: The algorithm cannot derive rules for all cases
- Input
5
Sibling(Ann,Mike)
Couple(David,James)
Mother(James,Ann)
Mother(James,Mike)
Father(David,Mike)
Father(x,y)
- Output
Couple(x,z) Ʌ Mother(z,y) → Father(x,y)
Father(David,Ann)
- Input
5
Father(Jack,Dell)
Father(Dell,Stephen)
Grandfather(Jack,Stephen)
Father(Dell,Seth)
Brother(Stephen,Seth)
Grandfather(x,y)
- Output
Father(x,z) Ʌ Father(z,y) → Grandfather(x,y)
Grandfather(Jack,Seth)