Intelligent information
systems
“ lab1”
Expert Systems
How To Implement an expert system
 CLIPS
 Python
CLIPS
 a rule based programming language
‑
Written in C
 CLIPS is an abbreviation to the C
Language Integrated Production System
 useful for creating expert systems and
other programs where a heuristic solution
is easier to implement and maintain than
an algorithmic solution
Experta
Pyknow
 Experta is a Python library for building expert systems
strongly inspired by CLIPS
the goal of making it easy for the CLIPS programmer to
transfer all of his/her knowledge to this platform.
Difference between CLIPS and Experta
• CLIPS is a programming language, Experta is a Python
library.
• CLIPS is written in C, Experta in Python
• In CLIPS you add facts using assert, in Python we
use declare instead
Experta
Installation
 To install Experta, run this command in your terminal:
 pip install experta
 Pip  python installer
package
Facts
 Facts are the basic unit of information of Experta. They
are used by the system to reason about the problem.
 The class Fact is a subclass of dict.
 from experta import *
 f = Fact(a=1, b=2)
Facts
 In contrast to dict, you can create a Fact without keys
(only values), and Fact will create a numeric index for
your values.
 f2 = Fact('x','y','z')
 You can mix autonumeric values with key-values, but
autonumeric must be declared first:
f3 = Fact('x','y','z',a=1,b=2)
Facts
 You can subclass Fact to express different kinds of data
or extend it with your custom functionality.
class Alert(Fact):
"""The alert level."""
pass
class Status(Fact):
"""The system status."""
pass
f1 = Alert('red‘, ‘noise’)
f2 = Status('critical')
Rules
 In Experta a rule is a callable, decorated with Rule.
 @Rule
 Rules have two components, LHS (left-hand-side) and
RHS (right-hand-side).
 The LHS describes (using patterns) the conditions on
which the rule should be executed (or fired).
 The RHS is the set of actions to perform when the rule
is fired.
Rules
@Rule(Fact('animal', family='felinae')) # This is the LHS
def match_with_cats(): # This is the RHS
"""
Match with every `Fact` which:
* f[0] == 'animal'
* f['family'] == 'felinae'
"""
print("Meow!")
Rules
lab 1 intelligent information systems .pptx

lab 1 intelligent information systems .pptx

  • 1.
  • 2.
  • 5.
    How To Implementan expert system  CLIPS  Python
  • 6.
    CLIPS  a rulebased programming language ‑ Written in C  CLIPS is an abbreviation to the C Language Integrated Production System  useful for creating expert systems and other programs where a heuristic solution is easier to implement and maintain than an algorithmic solution
  • 7.
    Experta Pyknow  Experta isa Python library for building expert systems strongly inspired by CLIPS the goal of making it easy for the CLIPS programmer to transfer all of his/her knowledge to this platform. Difference between CLIPS and Experta • CLIPS is a programming language, Experta is a Python library. • CLIPS is written in C, Experta in Python • In CLIPS you add facts using assert, in Python we use declare instead
  • 8.
    Experta Installation  To installExperta, run this command in your terminal:  pip install experta  Pip  python installer package
  • 9.
    Facts  Facts arethe basic unit of information of Experta. They are used by the system to reason about the problem.  The class Fact is a subclass of dict.  from experta import *  f = Fact(a=1, b=2)
  • 10.
    Facts  In contrastto dict, you can create a Fact without keys (only values), and Fact will create a numeric index for your values.  f2 = Fact('x','y','z')  You can mix autonumeric values with key-values, but autonumeric must be declared first: f3 = Fact('x','y','z',a=1,b=2)
  • 12.
    Facts  You cansubclass Fact to express different kinds of data or extend it with your custom functionality. class Alert(Fact): """The alert level.""" pass class Status(Fact): """The system status.""" pass f1 = Alert('red‘, ‘noise’) f2 = Status('critical')
  • 14.
    Rules  In Expertaa rule is a callable, decorated with Rule.  @Rule  Rules have two components, LHS (left-hand-side) and RHS (right-hand-side).  The LHS describes (using patterns) the conditions on which the rule should be executed (or fired).  The RHS is the set of actions to perform when the rule is fired.
  • 15.
    Rules @Rule(Fact('animal', family='felinae')) #This is the LHS def match_with_cats(): # This is the RHS """ Match with every `Fact` which: * f[0] == 'animal' * f['family'] == 'felinae' """ print("Meow!")
  • 16.