0% found this document useful (0 votes)
70 views17 pages

Lab 1

The document discusses different approaches to implementing expert systems, including using the CLIPS and Experta frameworks. CLIPS is a rule-based programming language written in C, while Experta is a Python library inspired by CLIPS. The document explains how to create facts and rules in Experta, with facts representing basic information and rules containing left-hand and right-hand sides to describe conditions and actions.

Uploaded by

التير ند
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views17 pages

Lab 1

The document discusses different approaches to implementing expert systems, including using the CLIPS and Experta frameworks. CLIPS is a rule-based programming language written in C, while Experta is a Python library inspired by CLIPS. The document explains how to create facts and rules in Experta, with facts representing basic information and rules containing left-hand and right-hand sides to describe conditions and actions.

Uploaded by

التير ند
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Intelligent information

systems
“ lab1”
Expert Systems
How To Implement an expert system

⮚ CLIPS
⮚ Python
▪ a rule‑based programming language
Written in C

▪ CLIPS is an abbreviation to the C


Language Integrated Production System
CLIPS
▪ useful for creating expert systems and
other programs where a heuristic solution
is easier to implement and maintain than
an algorithmic solution
▪ Experta is a Python library for building expert systems
strongly inspired by CLIPS
Experta 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

Pyknow • 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
▪ To install Experta, run this command in your terminal:

Experta ▪ pip install experta


Installation
▪ Pip 🡪 python installer
package
▪ 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.


Facts
▪ from experta import *

▪ f = Fact(a=1, b=2)
▪ In contrast to dict, you can create a Fact without keys
(only values), and Fact will create a numeric index for
your values.

Facts
▪ 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)
▪ You can subclass Fact to express different kinds of data
or extend it with your custom functionality.

Facts class Alert(Fact):


"""The alert level."""
pass

class Status(Fact):
"""The system status."""
pass

f1 = Alert('red‘, ‘noise’)
f2 = Status('critical')
▪ In Experta a rule is a callable, decorated with Rule.
▪ @Rule

▪ Rules have two components, LHS (left-hand-side) and


Rules 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.
@Rule(Fact('animal', family='felinae')) # This is the LHS
def match_with_cats(): # This is the RHS
"""
Match with every `Fact` which:
Rules
* f[0] == 'animal'
* f['family'] == 'felinae'

"""
print("Meow!")
Rules

You might also like