AI_Notes_Unit-5
AI_Notes_Unit-5
Even Planning is an important part of Artificial Intelligence which deals with the tasks and
domains of a particular problem. Planning is considered the logical side of acting.
Everything we humans do is with a definite goal in mind, and all our actions are oriented towards
achieving our goal. Similarly, Planning is also done for Artificial Intelligence.
For example, Planning is required to reach a particular destination. It is necessary to find the
best route in Planning, but the tasks to be done at a particular time and why they are done are
also very important.
ADVERTISEMENT
That is why Planning is considered the logical side of acting. In other words, Planning is about
deciding the tasks to be performed by the artificial intelligence system and the system's
functioning under domain-independent conditions.
What is a Plan?
We require domain description, task specification, and goal description for any planning system.
A plan is considered a sequence of actions, and each action has its preconditions that must be
satisfied before it can act and some effects that can be positive or negative.
So, we have Forward State Space Planning (FSSP) and Backward State Space
Planning (BSSP) at the basic level.
1. Forward State Space Planning (FSSP)
FSSP behaves in the same way as forwarding state-space search. It says that given an initial state
S in any domain, we perform some necessary actions and obtain a new state S' (which also
contains some new terms), called a progression. It continues until we reach the target position.
Action should be taken in this matter.
So for an efficient planning system, we need to combine the features of FSSP and BSSP,
which gives rise to target stack planning which will be discussed in the next article.
Execution of the plan is about choosing a sequence of tasks with a high probability of
accomplishing a specific task.
o The non-interlaced planners of the early 1970s were unable to solve this problem. Therefore it is
considered odd.
o When two sub-goals, G1 and G2, are given, a non-interleaved planner either produces a plan for
G1 that is combined with a plan for G2 or vice versa.
o In the block-world problem, three blocks labeled 'A', 'B', and 'C' are allowed to rest on a flat surface.
The given condition is that only one block can be moved at a time to achieve the target.
The start position and target position are shown in the following diagram.
o Choose the best rule to apply the next rule based on the best available guess.
o Apply the chosen rule to calculate the new problem condition.
o Find out when a solution has been found.
o Detect dead ends so they can be discarded and direct system effort in more useful
directions.
o Find out when a near-perfect solution is found.
1. Start by pushing the original target onto the stack. Repeat this until the pile is
empty. If the stack top is a mixed target, push its unsatisfied sub-targets onto the
stack.
2. If the stack top is a single unsatisfied target, replace it with action and push the
action precondition to the stack to satisfy the condition.
iii. If the stack top is an action, pop it off the stack, execute it and replace the knowledge
base with the action's effect.
Non-linear Planning
This Planning is used to set a goal stack and is included in the search space of all possible
sub-goal orderings. It handles the goal interactions by the interleaving method.
It takes a larger search space since all possible goal orderings are considered.
Algorithm
Benefits of AI Planning
Numerous advantages of AI planning contribute to the efficacy and efficiency of
artificial intelligence systems. Some key benefits include:
• Resource Allocation: With the help of AI planning, resources can be
distributed in the best way possible, ensuring that they are used effectively
to accomplish the desired objectives.
• Better Decision-Making: AI planning aids in making knowledgeable
judgments by taking a variety of aspects and restrictions into account. It
helps AI systems to weigh several possibilities and decide on the best
course of action.
• Automation of Complex Tasks: AI planning automates complicated tasks
that would otherwise need a lot of human work. It makes it possible for AI
systems to manage complex procedures and optimize them for better
results.
Applications of AI Planning
AI planning is used in many different fields, demonstrating its adaptability and
efficiency. A few significant applications are:
• Robotics: To enable autonomous robots to properly navigate their
surroundings, carry out activities, and achieve goals, planning is crucial.
• Gaming: AI planning is essential to the gaming industry because it enables
game characters to make thoughtful choices and design difficult and
interesting gameplay scenarios.
• Logistics: To optimize routes, timetables, and resource allocation and
achieve effective supply chain management, AI planning is widely utilized in
logistics.
• Healthcare: AI planning is used in the industry to better the quality and
effectiveness of healthcare services by scheduling patients, allocating
resources, and planning treatments.
Challenges in AI Planning
While AI planning has many advantages, many issues need to be resolved. Typical
challenges include:
• Complexity: Due to the wide state space, multiple possible actions, and
interdependencies between them, planning in complicated domains can be
difficult.
• Uncertainty: One of the biggest challenges in AI planning is overcoming
uncertainty. Actions' results might not always be anticipated, thus the
planning system needs to be able to deal with such ambiguous situations.
• Scalability: Scalability becomes a significant barrier as the complexity and
scale of planning problems rise. Large-scale issues must be effectively
handled via planning systems.
A simple planning agent create and use plans based on the following assumptions:
• Atomic time: each action is indivisible
• No concurrent actions allowed
• Deterministic actions: result of each actions is completely determined by the
definition of the action, and there is no uncertainty in performing it in the
world.
• Agent is the sole cause of change in the world.
• Agent is omniscient: has complete knowledge of the state of the world
a. First, evaluate the difference between Initial State and final State.
b. Select the various operators which can be applied for each difference.
c. Apply the operator at each difference, which reduces the difference between the current
state and goal state.
Operator Subgoaling
In the MEA process, we detect the differences between the current state and goal state. Once
these differences occur, then we can apply an operator to reduce the differences. But sometimes
it is possible that an operator cannot be applied to the current state. So we create the subproblem
of the current state, in which operator can be applied, such type of backward chaining in which
operators are selected, and then sub goals are set up to establish the preconditions of the operator
is called Operator Subgoaling.
o Step 1: Compare CURRENT to GOAL, if there are no differences between both then
return Success and Exit.
o Step 2: Else, select the most significant difference and reduce it by doing the
following steps until the success or failure occurs.
a. Select a new operator O which is applicable for the current difference, and if there
is no such operator, then signal failure.
b. Attempt to apply operator O to CURRENT. Make a description of two states.
i) O-Start, a state in which O?s preconditions are satisfied.
ii) O-Result, the state that would result if O were applied In O-start.
c. If
(First-Part <------ MEA (CURRENT, O-START)
And
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then signal Success and return
the result of combining FIRST-PART, O, and LAST-PART.
The above-discussed algorithm is more suitable for a simple problem and not adequate for
solving complex problems.
Solution:
To solve the above problem, we will first find the differences between initial states and goal
states, and for each difference, we will generate a new state and will apply the operators. The
operators we have for this problem are:
o Move
o Delete
o Expand
1. Evaluating the initial state: In the first step, we will evaluate the initial state and will
compare the initial and Goal state to find the differences between both states.
2. Applying Delete operator: As we can check the first difference is that in goal state there is
no dot symbol which is present in the initial state, so, first we will apply the Delete operator to
remove this dot.
3. Applying Move Operator: After applying the Delete operator, the new state occurs which
we will again compare with goal state. After comparing these states, there is another difference
that is the square is outside the circle, so, we will apply the Move Operator.
4. Applying Expand Operator: Now a new state is generated in the third step, and we will
compare this state with the goal state. After comparing the states there is still one difference
which is the size of the square, so, we will apply Expand operator, and finally, it will generate
the goal state.
How does the Means-Ends Analysis work?
Let’s learn how it works.
• Measures the current state and identifies the problems and pain
• Splits the goals into sub-goals and sub-goals into further sub-
achieve it.
and expect it to produce the end results. We can use these algorithms as
every step can have test cases built for it, and the program can undergo
error, past experience, and judgmental methods, which may not always
When completing tasks, people use heuristics to save time and can
tolerate a few errors. In planned activity (e.g., Organization Planning), we
study and capture the status at a macro level and a possible micro
level.
• Step 2: Capture the deficiency in the current state and avenues for
improvements (wish list) and define the goal state (to-be state).
Define the to-be state at a macro level and a possible micro level.
• Step 3: Compare the Current and Goal states; if they are at the
• Step 4: List the differences between the current and goal states at
step-5.
• Step 7: Implement the changes and measure the results with the
planned goals.
phycology use cases to deploy the MEA algorithm step selectively and
Based on the methods and way of learning, machine learning is divided into mainly four types,
which are:
4. Reinforcement Learning
In this topic, we will provide a detailed description of the types of Machine Learning along with
their respective algorithms:
Let's understand supervised learning with an example. Suppose we have an input dataset of cats
and dog images. So, first, we will provide the training to the machine to understand the images,
such as the shape & size of the tail of cat and dog, Shape of eyes, colour, height
(dogs are taller, cats are smaller), etc. After completion of training, we input the picture of
a cat and ask the machine to identify the object and predict the output. Now, the machine is well
trained, so it will check all the features of the object, such as height, shape, colour, eyes, ears,
tail, etc., and find that it's a cat. So, it will put it in the Cat category. This is the process of how
the machine identifies the objects in Supervised Learning.
The main goal of the supervised learning technique is to map the input variable(x)
with the output variable(y). Some real-world applications of supervised learning are Risk
Assessment, Fraud Detection, Spam filtering, etc.
o Classification
o Regression
a) Classification
Classification algorithms are used to solve the classification problems in which the output
variable is categorical, such as "Yes" or No, Male or Female, Red or Blue, etc. The
classification algorithms predict the categories present in the dataset. Some real-world examples
of classification algorithms are Spam Detection, Email filtering, etc.
b) Regression
Regression algorithms are used to solve regression problems in which there is a linear
relationship between input and output variables. These are used to predict continuous output
variables, such as market trends, weather prediction, etc.
o Lasso Regression
o Since supervised learning work with the labelled dataset so we can have an exact idea about the
classes of objects.
o These algorithms are helpful in predicting the output on the basis of prior experience.
Disadvantages:
o It may predict the wrong output if the test data is different from the training data.
o Image Segmentation:
Supervised Learning algorithms are used in image segmentation. In this process, image
classification is performed on different image data with pre-defined labels.
o Medical Diagnosis:
Supervised algorithms are also used in the medical field for diagnosis purposes. It is done by using
medical images and past labelled data with labels for disease conditions. With such a process, the
machine can identify a disease for the new patients.
o Fraud Detection - Supervised Learning classification algorithms are used for identifying fraud
transactions, fraud customers, etc. It is done by using historic data to identify the patterns that can
lead to possible fraud.
o Spam detection - In spam detection & filtering, classification algorithms are used. These
algorithms classify an email as spam or not spam. The spam emails are sent to the spam folder.
o Speech Recognition - Supervised learning algorithms are also used in speech recognition. The
algorithm is trained with voice data, and various identifications can be done using the same, such
as voice-activated passwords, voice commands, etc.
In unsupervised learning, the models are trained with the data that is neither classified nor
labelled, and the model acts on that data without any supervision.
The main aim of the unsupervised learning algorithm is to group or categories the
unsorted dataset according to the similarities, patterns, and differences. Machines
are instructed to find the hidden patterns from the input dataset.
Let's take an example to understand it more preciously; suppose there is a basket of fruit images,
and we input it into the machine learning model. The images are totally unknown to the model,
and the task of the machine is to find the patterns and categories of the objects.
So, now the machine will discover its patterns and differences, such as colour difference,
shape difference, and predict the output when it is tested with the test dataset.
o Clustering
o Association
1) Clustering
The clustering technique is used when we want to find the inherent groups from the data.
It is a way to group the objects into a cluster such that the objects with the most
similarities remain in one group and have fewer or no similarities with the objects of other
groups. An example of the clustering algorithm is grouping the customers by their
purchasing behaviour.
o Mean-shift algorithm
o DBSCAN Algorithm
2) Association
Association rule learning is an unsupervised learning technique, which finds interesting relations
among variables within a large dataset. The main aim of this learning algorithm is to find the
dependency of one data item on another data item and map those variables accordingly so that it
can generate maximum profit. This algorithm is mainly applied in Market Basket analysis,
Web usage mining, continuous production, etc.
Some popular algorithms of Association rule learning are Apriori Algorithm, Eclat, FP-
growth algorithm.
o These algorithms can be used for complicated tasks compared to the supervised ones because
these algorithms work on the unlabeled dataset.
o Unsupervised algorithms are preferable for various tasks as getting the unlabeled dataset is easier
as compared to the labelled dataset.
Disadvantages:
o The output of an unsupervised algorithm can be less accurate as the dataset is not labelled, and
algorithms are not trained with the exact output in prior.
o Working with Unsupervised learning is more difficult as it works with the unlabelled dataset that
does not map with the output.
o Singular Value Decomposition: Singular Value Decomposition or SVD is used to extract particular
information from the database. For example, extracting information of each user located at a
particular location.
3. Semi-Supervised Learning
Semi-Supervised learning is a type of Machine Learning algorithm that lies
between Supervised and Unsupervised machine learning. It represents the intermediate
ground between Supervised (With Labelled training data) and Unsupervised learning (with no
labelled training data) algorithms and uses the combination of labelled and unlabeled datasets
during the training period.
Although Semi-supervised learning is the middle ground between supervised and unsupervised
learning and operates on the data that consists of a few labels, it mostly consists of unlabeled
data. As labels are costly, but for corporate purposes, they may have few labels. It is completely
different from supervised and unsupervised learning as they are based on the presence & absence
of labels.
We can imagine these algorithms with an example. Supervised learning is where a student is
under the supervision of an instructor at home and college. Further, if that student is self-
analysing the same concept without any help from the instructor, it comes under unsupervised
learning. Under semi-supervised learning, the student has to revise himself after analyzing the
same concept under the guidance of an instructor at college.
o It is highly efficient.
Disadvantages:
o Accuracy is low.
4. Reinforcement Learning
Reinforcement learning works on a feedback-based process, in which an AI agent
(A software component) automatically explore its surrounding by hitting & trail,
taking action, learning from experiences, and improving its performance. Agent gets
rewarded for each good action and get punished for each bad action; hence the goal of
reinforcement learning agent is to maximize the rewards.
In reinforcement learning, there is no labelled data like supervised learning, and agents learn
from their experiences only.
ADVERTISEMENT
The reinforcement learning process is similar to a human being; for example, a child learns
various things by experiences in his day-to-day life. An example of reinforcement learning is to
play a game, where the Game is the environment, moves of an agent at each step define states,
and the goal of the agent is to get a high score. Agent receives feedback in terms of punishment
and rewards.
Due to its way of working, reinforcement learning is employed in different fields such as Game
theory, Operation Research, Information theory, multi-agent systems.
o Resource Management:
The "Resource Management with Deep Reinforcement Learning" paper showed that how to use RL
in computer to automatically learn and schedule resources to wait for different jobs in order to
minimize average job slowdown.
o Robotics:
RL is widely being used in Robotics applications. Robots are used in the industrial and
manufacturing area, and these robots are made more powerful with reinforcement learning. There
are different industries that have their vision of building intelligent robots using AI and Machine
learning technology.
o Text Mining
Text-mining, one of the great applications of NLP, is now being implemented with the help of
Reinforcement Learning by Salesforce company.
Advantages and Disadvantages of Reinforcement Learning
Advantages
o It helps in solving complex real-world problems which are difficult to be solved by general
techniques.
o The learning model of RL is similar to the learning of human beings; hence most accurate results
can be found.
Disadvantage
The curse of dimensionality limits reinforcement learning for real physical systems.
The expert system is a part of AI, and the first ES was developed in the year 1970, which
was the first successful approach of artificial intelligence. It solves the most complex issue
as an expert by extracting the knowledge stored in its knowledge base. The system helps
in decision making for compsex 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.
The performance of an expert system is based on the expert's knowledge stored in its
knowledge base. The more knowledge stored in the KB, the more that system improves
its performance. One of the common examples of an ES is a suggestion of spelling errors
while typing in the Google search box.
Below is the block diagram that represents the working of an expert system:
Note: It is important to remember that an expert system is not used to replace the
human experts; instead, it is used to assist the human in making a complex decision.
These systems do not have human capabilities of thinking and work on the basis of
the knowledge base of the particular domain.
o High Performance: The expert system provides high performance for solving any
type of complex problem of a specific domain with high efficiency and accuracy.
o Understandable: It responds in a way that can be easily understandable by the
user. It can take input in human language and provides the output in the same
way.
o Reliable: It is much reliable for generating an efficient and accurate output.
o Highly responsive: ES provides the result for any complex query within a very
short period of time.
o User Interface
o Inference Engine
o Knowledge Base
1. User Interface
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. In other words, it is an interface that
helps a non-expert user to communicate with the expert system to find a solution.
o With the help of an inference engine, the system extracts the knowledge from the knowledge base.
o Deterministic Inference engine: The conclusions drawn from this type of inference engine are
assumed to be true. It is based on facts and rules.
o Probabilistic Inference engine: This type of inference engine contains uncertainty in conclusions,
and based on the probability.
o Forward Chaining: It starts from the known facts and rules, and applies the inference rules to add
their conclusion to the known facts.
o Backward Chaining: It is a backward reasoning method that starts from the goal and works
backward to prove the known facts.
3. Knowledge Base
o 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.
o It is similar to a database that contains information and rules of a particular domain or subject.
o 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.
o Factual Knowledge: The knowledge which is based on facts and accepted by knowledge engineers
comes under factual knowledge.
o Heuristic Knowledge: This knowledge is based on practice, the ability to guess, evaluation, and
experiences.
Here, we will explain the working of an expert system by taking an example of MYCIN ES.
Below are some steps to build an MYCIN:
o Firstly, ES should be fed with expert knowledge. In the case of MYCIN, human experts specialized
in the medical field of bacterial infection, provide information about the causes, symptoms, and
other knowledge in that domain.
o The KB of the MYCIN is updated successfully. In order to test it, the doctor provides a new problem
to it. The problem is to identify the presence of the bacteria by inputting the details of a patient,
including the symptoms, current condition, and medical history.
o The ES will need a questionnaire to be filled by the patient to know the general information about
the patient, such as gender, age, etc.
o Now the system has collected all the information, so it will find the solution for the problem by
applying if-then rules using the inference engine and using the facts stored within the KB.
o In the end, it will provide a response to the patient by using the user interface.
1. Expert: The success of an ES much depends on the knowledge provided by human experts. These
experts are those persons who are specialized in that specific domain.
2. Knowledge Engineer: Knowledge engineer is the person who gathers the knowledge from the
domain experts and then codifies that knowledge to the system according to the formalism.
3. End-User: This is a particular person or a group of people who may not be experts, and working
on the expert system needs the solution or advice for his queries, which are complex.
Why Expert System?
Before using any technology, we must have an idea about why to use that technology and hence
the same for the ES. Although we have human experts in every field, then what is the need to
develop a computer-based system. So below are the points that are describing the need of the ES:
1. No memory Limitations: It can store as much data as required and can memorize it at the time of its
application. But for human experts, there are some limitations to memorize all things at every time.
2. High Efficiency: If the knowledge base is updated with the correct knowledge, then it provides a highly
efficient output, which may not be possible for a human.
3. Expertise in a domain: There are lots of human experts in each domain, and they all have different
skills, different experiences, and different skills, so it is not easy to get a final output for the query. But if
we put the knowledge gained from human experts into the expert system, then it provides an efficient
output by mixing all the facts and knowledge
4. Not affected by emotions: These systems are not affected by human emotions such as fatigue, anger,
depression, anxiety, etc.. Hence the performance remains constant.
5. High security: These systems provide high security to resolve any query.
6. Considers all the facts: To respond to any query, it checks and considers all the available facts and
provides the result accordingly. But it is possible that a human expert may not consider some facts due to
any reason.
7. Regular updates improve the performance: If there is an issue in the result provided by the expert
systems, we can improve the performance of the system by updating the knowledge base.
o Advising: It is capable of advising the human being for the query of any domain from the particular
ES.
o Demonstrate a device: It is capable of demonstrating any new products such as its features,
specifications, how to use that product, etc.
o Interpreting the input: It is capable of interpreting the input given by the user.
o Diagnosis: An ES designed for the medical field is capable of diagnosing a disease without using
multiple components as it already contains various inbuilt medical tools.
o They can be used for risky places where the human presence is not safe.
o The performance of these systems remains steady as it is not affected by emotions, tension, or
fatigue.
o Like a human being, it cannot produce a creative output for different scenarios.
o For each domain, we require a specific ES, which is one of the big limitations.