You are on page 1of 40

Module -3

Expert Systems in AI
Course teacher:
Dr. S. Syed Rafiammal
Assistant Professor, ECE department
BS Abdur Rahman Crescent Institute of Science and Technology
What is an Expert System?

• An expert system is a computer program that


is designed to solve complex problems and to
provide decision-making ability like a human
expert.
• It performs this by extracting knowledge from
its knowledge base using the reasoning and
inference rules according to the user queries.
Expert System

https://www.javatpoint.com/expert-systems-in-artificial-intelligence
Motive
• The system helps in decision making for
complex problems using both facts and
heuristics like a human expert.
• It is called so because it contains the expert
knowledge of a specific domain and can solve
any complex problem of that particular
domain.
• These systems are designed for a specific
domain, such as medicine, science, etc.
Components of Expert System

https://www.javatpoint.com/expert-
systems-in-artificial-intelligence
User Interface
• It is an interface that helps a non-expert
user to communicate with the expert system
to find a solution
• With the help of a user interface, the expert
system interacts with the user, takes queries as
an input in a readable format, and passes it to
the inference engine.
• After getting the response from the inference
engine, it displays the output to the user.
Inference Engine(Rules of Engine)
• The inference engine is known as the brain of the expert system as it
is the main processing unit of the system.
• It applies inference rules to the knowledge base to derive a
conclusion or deduce new information.
• It helps in deriving an error-free solution of queries asked by the user.
• With the help of an inference engine, the system extracts the
knowledge from the knowledge base.
There are two types of inference engine:
• Deterministic Inference engine: The conclusions drawn from this type
of inference engine are assumed to be true. It is based
on facts and rules.
• Probabilistic Inference engine: This type of inference engine contains
uncertainty in conclusions, and based on the probability.
Knowledge Base

• The knowledgebase is a type of storage that stores


knowledge acquired from the different experts of the
particular domain. It is considered as big storage of
knowledge. The more the knowledge base, the more
precise will be the Expert System.
• It is similar to a database that contains information and
rules of a particular domain or subject.
• One can also view the knowledge base as collections of
objects and their attributes. Such as a Lion is an object
and its attributes are it is a mammal, it is not a domestic
animal, etc.
Components of Knowledge Base
• Factual Knowledge: The knowledge which is
based on facts and accepted by knowledge
engineers comes under factual knowledge.
• Heuristic Knowledge: This knowledge is based
on practice, the ability to guess, evaluation,
and experiences.
Knowledge Representation & Acquisitions

• Knowledge Representation: It is used to


formalize the knowledge stored in the
knowledge base using the If-else rules.
• Knowledge Acquisitions: It is the process of
extracting, organizing, and structuring the
domain knowledge, specifying the rules to
acquire the knowledge from various experts,
and store that knowledge into the knowledge
base.
Example Scenario
• Suppose a patient comes to a medical clinic
with symptoms like fever, sore throat, and
swollen lymph nodes. The doctor, who is using
an expert system for assistance, inputs these
symptoms into the system. Here's how the
expert system might work:
Example Scenario- Solution
• Data Input Inference Engine Knowledge Base
Diagnosis Rule-Based Reasoning
Recommendations Explanations
Procedure:
1. The doctor enters the patient's symptoms into the expert
system through the user interface.
2. The inference engine starts to analyze the input
symptoms. It begins by asking questions or making
hypotheses. For instance, it might ask, "Is the patient
experiencing difficulty swallowing?" Based on the
responses, it narrows down the possibilities.
Procedure

• 3. The expert system consults its knowledge base, which contains


information about various diseases and their symptoms. It knows
that fever, sore throat, and swollen lymph nodes can be indicative
of several diseases, including strep throat, mononucleosis, and
tonsillitis.
• 4. The system applies rules and logical reasoning to the
information in the knowledge base. It might have rules like "If the
patient has a fever and swollen lymph nodes but no difficulty
swallowing, it could be mononucleosis.“
• 5. Based on the input symptoms, responses to questions, and the
application of rules, the expert system generates a preliminary
diagnosis. In this case, it suggests that the patient might have
mononucleosis.
Procedure

• 6. Recommendations: The expert system provides


treatment recommendations, which may include
rest, fluids, and antiviral medications. It may also
advise the doctor to run further tests for
confirmation.
• 7. Explanations: Importantly, expert systems can
provide explanations for their conclusions. It can
explain to the doctor why it arrived at the
diagnosis of mononucleosis, citing the specific
symptoms and rules it applied.
Examples
• DENDRAL: It was an artificial intelligence project that was made as a
chemical analysis expert system. It was used in organic chemistry to
detect unknown organic molecules with the help of their mass spectra
and knowledge base of chemistry.
• MYCIN: It was one of the earliest backward chaining expert systems
that was designed to find the bacteria causing infections like bacteria
and meningitis. It was also used for the recommendation of antibiotics
and the diagnosis of blood clotting diseases.
• PXDES: It is an expert system that is used to determine the type and
level of lung cancer. To determine the disease, it takes a picture from
the upper body, which looks like the shadow. This shadow identifies the
type and degree of harm.
• CaDeT: The CaDet expert system is a diagnostic support system that can
detect cancer at early stages.
Examples
• CLIPS: The C Language Integrated Production System (CLIPS) is a widely used open-source expert
system development tool. It provides a framework for building rule-based expert systems and has
applications in various fields, including aerospace and healthcare.
• XCON: XCON is a well-known expert system developed by Digital Equipment Corporation (DEC) in the
1980s. It was used for configuring computer systems based on customer requirements.
• PROSPECTOR: PROSPECTOR is an expert system used in the field of mineral exploration. It helps
geologists identify potential mining sites based on geological data and expert knowledge.
• CADUCEUS: CADUCEUS is an expert system developed for diagnosing certain medical conditions,
specifically blood disorders. It combines rule-based reasoning with probabilistic methods to make
diagnoses.
• Cyc: Cyc is a long-term project aimed at creating a comprehensive, common-sense knowledge base
that can be used to power various expert systems. It's been applied in areas like natural language
processing and automated reasoning.
• Watson: Developed by IBM, Watson is a more recent and well-known example of an expert system. It
gained fame for winning the quiz show Jeopardy! in 2011. Watson is used in various applications,
including healthcare (IBM Watson Health) and business analytics.
• DeepMind's AlphaFold: While not a traditional expert system, AlphaFold is an AI system that excels in
predicting the 3D structures of proteins, a problem that has stumped scientists for decades. It
demonstrates the power of AI and expert knowledge in a critical area of biology.
Examples
• Cyc: Cyc is a long-term project aimed at creating a comprehensive,
common-sense knowledge base that can be used to power various expert
systems. It's been applied in areas like natural language processing and
automated reasoning.

• Watson: Developed by IBM, Watson is a more recent and well-known


example of an expert system. It gained fame for winning the quiz show
Jeopardy! in 2011. Watson is used in various applications, including
healthcare (IBM Watson Health) and business analytics.

• DeepMind's AlphaFold: While not a traditional expert system, AlphaFold is


an AI system that excels in predicting the 3D structures of proteins, a
problem that has stumped scientists for decades. It demonstrates the
power of AI and expert knowledge in a critical area of biology.
Probability-based expert system
• A probability-based expert system is a type of artificial
intelligence system that uses probability theory and
statistical methods to make decisions or provide
recommendations.
• It combines expert knowledge with probabilistic
reasoning to handle uncertainty and make informed
choices.
• These systems are commonly used in various fields,
including medicine, finance, and engineering, where
decisions must be made in situations with incomplete or
uncertain information.
Expert System
Components of a Probability-Based Expert System

• Knowledge Base: This contains the domain-specific


information and rules provided by experts. It includes
facts, relationships, and conditional probabilities.
• Inference Engine: The inference engine is responsible
for reasoning and making decisions based on the
information in the knowledge base. It uses probabilistic
reasoning techniques to calculate the likelihood of
different outcomes.
• User Interface: This component allows users to interact
with the expert system, input data, and receive
recommendations or decisions.
Example 1: Medical Diagnosis Expert
System
Let's consider an example of a medical diagnosis expert system
that uses probabilities to help diagnose a patient's condition.
• Knowledge Base: The knowledge base contains information
about symptoms, diseases, and the likelihood of a patient
having a particular disease given their symptoms. For
instance, it might include the following rules:
• If the patient has a high fever AND a persistent cough, THEN
the probability of having the flu is 70%.
• If the patient has a rash AND joint pain, THEN the probability
of having a viral infection is 50%.
Inference Engine
• The inference engine takes patient input (symptoms) and
calculates the probabilities of various diseases.
• It combines these probabilities to determine the most likely
diagnosis. It may use techniques like Bayesian networks or
Markov models to perform these calculations.
• For example,
if a patient reports having a high fever and a persistent
cough, the inference engine might calculate the probability of
having the flu as 70%. If the patient also reports a rash and joint
pain, it would consider the probabilities of all relevant diseases
and assign the highest probability to the most likely diagnosis.
User Interface
• The user interface allows the patient or healthcare
provider to input the patient's symptoms. After processing
the input, the expert system would provide a ranked list of
possible diagnoses along with their associated
probabilities. It might say something like:
• Diagnosis 1: Influenza (70% probability)
• Diagnosis 2: Viral infection (50% probability)
• Diagnosis 3: Common cold (30% probability)
• The healthcare provider can then use this information to
make an informed decision about further testing or
treatment.
Conclusion
• In this example, the probability-based expert
system uses probabilistic reasoning to handle
the uncertainty associated with medical
diagnoses.
• It provides a quantitative assessment of the
likelihood of different outcomes, allowing for
more informed decision-making in complex
and uncertain situations.
Example 2: Autonomous Vehicle Decision-
Making Expert System
Knowledge Base:
• The knowledge base in an autonomous vehicle decision-making expert
system contains a vast amount of data related to road conditions,
traffic rules, vehicle performance, and potential hazards.
• It includes rules and probabilities associated with various driving
scenarios.
• For instance:
• Probability of pedestrians crossing the road at a crosswalk during
daylight hours.
• Rules for maintaining safe following distances behind other vehicles
under different weather conditions.
• Probabilities of encountering road construction or accidents on a
particular route.
Inference Engine
• The inference engine continuously processes sensor data from the
vehicle, including information from cameras, LiDAR, radar, and GPS.
• It combines this real-time data with the knowledge base to make
decisions about the vehicle's speed, lane changes, braking, and
other driving actions.
• For example,
if the LiDAR sensor detects a pedestrian at a crosswalk, the
inference engine calculates the probability of a collision and
determines if the vehicle should slow down or stop to avoid the
pedestrian. It takes into account factors such as the vehicle's speed,
the pedestrian's location, and the current weather and road
conditions.
Example 3: Investment Portfolio
Management Expert System
• Knowledge Base: The knowledge base in this expert system
contains financial data, historical market trends, and rules
for portfolio management.
For instance:
• Historical data on the performance of various asset classes
like stocks, bonds, and real estate.
• Rules for asset allocation, such as "If the investor has a high
risk tolerance, allocate 70% to stocks and 30% to bonds."
• Probabilities associated with market conditions, such as
"There is a 30% probability of a stock market downturn in
the next year."
Inference Engine:
• The inference engine takes input from the investor, including their
risk tolerance, investment goals, and current financial situation. It
then uses this information to make investment recommendations
based on probabilistic reasoning.
• For example, if an investor with a moderate risk tolerance and a
long-term investment horizon seeks advice, the inference engine
might recommend a portfolio allocation like this:
• Stocks: 60%
• Bonds: 30%
• Real Estate: 10%
• The engine calculates these recommendations by considering the
investor's risk tolerance and the historical performance data and
probabilistic market conditions.
Expert system Tools
• Expert system tools are software or platforms designed
to facilitate the development, deployment, and
management of expert systems.
• These tools provide a range of functionalities, including
knowledge representation, inference engines, user
interfaces, and sometimes machine learning capabilities.
• They simplify the process of building and maintaining
expert systems, making it easier for domain experts to
codify their knowledge and for organizations to leverage
that expertise.
List of some notable expert system tools:
• CLIPS: CLIPS (C Language Integrated Production System) is a widely
used open-source expert system development tool that provides a
rule-based inference engine and knowledge representation.
• Drools: Drools is a popular open-source rule engine written in Java.
It offers rule-based programming capabilities and is used for
building decision-management systems and expert systems.
• Jess: Jess (Java Expert System Shell) is another rule engine and
scripting environment for the Java platform. It is similar in
functionality to CLIPS and is used for rule-based programming.
• Prolog: Prolog is a logic programming language commonly used for
building expert systems based on rule-based reasoning and
knowledge representation.
Expert system tools
• Pyke: Pyke is a knowledge-based inference engine that
integrates with Python. It allows you to build rule-based
expert systems using Python's scripting capabilities.
• IBM Watson Knowledge Studio: IBM's Watson
Knowledge Studio provides tools for building machine
learning-based expert systems by annotating and training
data. It's especially useful for natural language
understanding applications.
• Exsys Corvid: Exsys Corvid is a commercial expert system
development tool that offers a range of features for
building decision support systems and expert systems.
Expert system tools
• NeuroRule: NeuroRule is a tool that combines neural
networks with expert systems. It's designed for applications
where both symbolic reasoning and neural network-based
learning are required.
• XCON: XCON (Expert Configurer) is a historic example of an
expert system that was developed by Digital Equipment
Corporation (DEC) for configuring VAX computer systems.
While not a contemporary tool, it's noteworthy in the history
of expert systems.
• OpenRules: OpenRules is an open-source business rules
management system that provides a rule engine for building
decision logic and expert systems.
Expert system tools
• Fuzzy Logic Tools: Various tools and libraries, such
as MATLAB's Fuzzy Logic Toolbox and scikit-fuzzy for
Python, offer support for building expert systems
that utilize fuzzy logic for handling uncertainty.
• Inference Engines in AI Platforms: Many AI
platforms and frameworks, such as TensorFlow,
PyTorch, and Kie, include components for building
rule-based expert systems or integrating rule-based
reasoning into machine learning applications.
Example
• An example of an expert system using an
inference engine in an AI platform can involve
utilizing rule-based reasoning within a
machine learning framework.
• In this example, we'll use Python and
TensorFlow/ Keras, which are popular AI
platforms, to build an expert system for
diagnosing plant diseases based on leaf
images.
Problem Statement: Develop an expert system
to diagnose plant diseases using leaf images.
• Steps to Create the Expert System:
• Data Collection: Collect a dataset of leaf images, where each image is
labeled with the type of disease or is healthy.
• Rule-Based Component: Define a set of rules that consider visual
symptoms of diseases. For instance:
if yellow_spots and curling_leaves:
diagnosis = "Yellow Leaf Curl Virus"
elif brown_spots and wilted_leaves:
diagnosis = "Fungal Infection"
else:
diagnosis = "Healthy"

• These rules are based on visual symptoms observed in the leaf images.
• Machine Learning Component: Use a neural network (in
this case, a convolutional neural network or CNN) to learn
from the images. Train the model on the labeled dataset to
classify leaf images into healthy or disease categories.
• Inference Engine: Implement an inference engine that
combines the output from the rule-based component and
the machine learning component. It can be as simple as
considering the rule-based diagnosis unless the confidence
of the neural network prediction is high.
if confidence >= 0.8:
diagnosis = neural_network_prediction
Example Python program for Rule based expert system
with machine learning

# Rule-Based Component
def rule_based_diagnosis(leaf_image):
# Implement rules to diagnose based on visual symptoms
# Example: Check for yellow spots, curling leaves, brown spots,
wilted leaves, etc.
if yellow_spots and curling_leaves:
return "Yellow Leaf Curl Virus"
elif brown_spots and wilted_leaves:
return "Fungal Infection"
else:
return "Healthy"
# Machine Learning Component (Neural Network)
def neural_network_diagnosis(leaf_image):
# Use a pre-trained CNN model or train one on the dataset
# Return the predicted class (disease or healthy)

# Inference Engine
def expert_system_diagnosis(leaf_image):
rule_based = rule_based_diagnosis(leaf_image)
neural_network, confidence = neural_network_diagnosis(leaf_image)

if confidence >= 0.8:


return neural_network
else:
return rule_based
# Load an image and perform diagnosis
leaf_image = load_image("sample_leaf.jpg")
diagnosis=expert_system_diagnosis(leaf_image)
print("Diagnosis:", diagnosis)
Conclusion
• In this example, we've combined a rule-based
approach (based on visual symptoms) and a
neural network-based approach (using
TensorFlow/Keras) within an inference engine.
• The expert system can provide a diagnosis
based on both rules and machine learning
predictions, with a confidence threshold to
decide which diagnosis to trust.

You might also like