Artificial Intelligence: Unit-I
Artificial Intelligence: Unit-I
UNIT-I
1. AI :-
• It is a branch of computer science by which we can create intelligent machines
which can behave like a human, think like humans, and able to make decisions.
3. AI Approaches :-
• Reactive machines : These machines are the most basic form of AI
applications. Examples of reactive machines are Deep Blue, IBM's chess-
playing supercomputer, and the same computer that defeated the then-grand
master of the world. AI teams do not use training sets to feed the machines or
store subsequent data for future references. Based on the move made by the
opponent, the machine decides/predicts the next move.
• Limited memory : These machines belong to the Category II category of AI
applications, and Self-propelled cars are the perfect example. Over time, these
machines are fed with data and trained on the speed and direction of other cars, lane
markings, traffic lights, curves of roads, and other important factors.
• Theory of mind : It is where we are struggling to make this concept work. However,
we are not there yet. Theory of mind is the concept where bots will understand and
react to human emotions, thoughts. If AI-powered machines are always mingling and
moving around with us, then understanding human behavior is imperative. And then,
it is necessary to react to such behaviors accordingly.
• Self-awareness : These machines are an extension of class III type AI, and it is a step
ahead of understanding human emotions. It is the stage where AI teams build
machines with self-awareness factors programmed into them. When someone is
honking the horn from behind, the machines must sense the emotion, and only then
do they understand what it feels like when they horn someone from behind.
4. AI Techniques :-
• Machine Learning : where models learn from experience and evolve their precision
and delivery over a period
• Data Mining : where statistics and artificial intelligence are used for the analysis of
large data sets to discover helpful information
• Machine Vision : where the system can use imaging-based automatic inspection and
analysis for guidance, decisions, automatic inspection, process control, etc.
• Natural Language Processing or NLP : where machines can understand and respond
to text or voice data
• Robotics : where expert systems can perform tasks like a human.
5. Branches of AI :-
• Machine Learning :-
➢ In terms of advanced technology, one of the most demanding fields is Machine
Learning.
➢ Machine Learning is the technique that gives computers the potential to learn
without being programmed.
➢ Moreover, depending on the types of data available, data professionalists
select types of machine learning (algorithms) for what they want to predict
from data,
✓ Supervised Learning: In this type of learning, data experts feed
labelled training data to algorithms and define variables to algorithms
for accessing and finding correlations. Both the input and output of the
algorithm are particularized/defined.
✓ Unsupervised Learning: This type of learning include algorithms that
train on unlabelled data, an algorithm analyzes datasets to draw
meaningful correlations or inferences. For example, one method is
cluster analysis that uses exploratory data analysis to obtain hidden or
grouping patterns or groups in datasets.
✓ Reinforcement Learning: For teaching a computer machine to fulfil a
multi-step process for which there are clearly defined
rules, reinforcement learning is practised. Here, programmers design an
algorithm to perform a task and give it positive and negative signal to
act as algorithm execute to complete the task. Sometimes, the algorithm
even determines on its own what action to take to go ahead.
• Neural Network :-
➢ Incorporating cognitive science and machines to perform tasks, the neural
network is a branch of artificial intelligence that makes use of neurology.
➢ In simple terms, a neural network is a set of algorithms that are used to find
the elemental relationships across the bunches of data via the process that
imitates the human brain operating process.
➢ A neural network refers to a system of neurons that are original or artificial in
nature, where artificial neurons are known as perceptrons.
• Robotics :-
➢ Robotics is an interdisciplinary field of science and engineering incorporated
with mechanical engineering, electrical engineering, computer science, and
many others.
➢ Robotics determines the designing, producing, operating, and usage of robots.
It deals with computer systems for their control, intelligent outcomes, and
information transformation.
• Expert Systems :-
➢ Expert systems were considered amid the first successful model of AI software.
➢ For the first time, they were designed in the 1970s and after that escalated in
the 1980s.
➢ An expert system refers to a computer system that mimics the decision-making
intelligence of a human expert.
➢ It conducts this by deriving knowledge from its knowledge base by
implementing reasoning and insights rules in terms with the user queries.
➢ The effectiveness of the expert system completely relies on the expert’s
knowledge accumulated in a knowledge base.
➢ The more the information collected in it, the more the system enhances its
efficiency.
➢ For example, the expert system provides suggestions for spelling and errors in
Google Search Engine.
• Fuzzy Logic :-
➢ Fuzzy logic is a technique that represents and modifies uncertain information
by measuring the degree to which the hypothesis is correct.
➢ Fuzzy logic is convenient and flexible to implement machine learning
techniques and assist in imitating human thought logically.
➢ It is simply the generalization of the standard logic where a concept exhibits a
degree of truth between 0.0 to 1.0.
➢ If the concept is completely true, standard logic is 1.0 and 0.0 for the
completely false concept.
➢ But in fuzzy logic, there is also an intermediate value too which is partially true
and partially false.
• Natural Language Processing :-
➢ In layman words, NLP is the part of computer science and AI that can help in
communicating between computer and human by natural language.
➢ It is a technique of computational processing of human languages.
➢ It enables a computer to read and understand data by mimicking human
natural language.
➢ NLP is a method that deals in searching, analyzing, understanding and deriving
information from the text form of data.
➢ A common example of NLP is spam detection, computer algorithms can check
whether an email is a junk or not by looking at the subject of a line, or text of
an email.
6. Applications of AI :-
• AI in Astronomy:
o Artificial Intelligence can be very useful to solve complex universe problems. AI
technology can be helpful for understanding the universe such as how it works, origin,
etc.
• AI in Healthcare:
o In the last, five to ten years, AI becoming more advantageous for the healthcare
industry and going to have a significant impact on this industry.
o Healthcare Industries are applying AI to make a better and faster diagnosis than
humans. AI can help doctors with diagnoses and can inform when patients are
worsening so that medical help can reach to the patient before hospitalization.
• AI in Gaming:
o AI can be used for gaming purpose. The AI machines can play strategic games like
chess, where the machine needs to think of a large number of possible places.
• AI in Finance:
o AI and finance industries are the best matches for each other. The finance industry is
implementing automation, chatbot, adaptive intelligence, algorithm trading, and
machine learning into financial processes.
• AI in Data Security:
o The security of data is crucial for every company and cyber-attacks are growing very
rapidly in the digital world. AI can be used to make your data more safe and secure.
Some examples such as AEG bot, AI2 Platform,are used to determine software bug and
cyber-attacks in a better way.
• AI in Social Media:
o Social Media sites such as Facebook, Twitter, and Snapchat contain billions of user
profiles, which need to be stored and managed in a very efficient way. AI can organize
and manage massive amounts of data. AI can analyze lots of data to identify the latest
trends, hashtag, and requirement of different users.
• AI in Automotive Industry:
o Some Automotive industries are using AI to provide virtual assistant to their user for
better performance. Such as Tesla has introduced TeslaBot, an intelligent virtual
assistant.
o Various Industries are currently working for developing self-driven cars which can make
your journey more safe and secure.
• AI in Robotics:
o Artificial Intelligence has a remarkable role in Robotics. Usually, general robots are
programmed such that they can perform some repetitive task, but with the help of AI,
we can create intelligent robots which can perform tasks with their own experiences
without pre-programmed.
o Humanoid Robots are best examples for AI in robotics, recently the intelligent
Humanoid robot named as Erica and Sophia has been developed which can talk and
behave like humans.
• AI in Entertainment:
o We are currently using some AI based applications in our daily life with some
entertainment services such as Netflix or Amazon. With the help of ML/AI algorithms,
these services show the recommendations for programs or shows.
• AI in Agriculture:
o Agriculture is an area which requires various resources, labor, money, and time for best
result. Now a day's agriculture is becoming digital, and AI is emerging in this field.
Agriculture is applying AI as agriculture robotics, solid and crop monitoring, predictive
analysis. AI in agriculture can be very helpful for farmers.
• AI in E-commerce:
o AI is providing a competitive edge to the e-commerce industry, and it is becoming
more demanding in the e-commerce business. AI is helping shoppers to discover
associated products with recommended size, color, or even brand.
• AI in education:
o AI can automate grading so that the tutor can have more time to teach. AI chatbot can
communicate with students as a teaching assistant.
o AI in the future can be work as a personal virtual tutor for students, which will be
accessible easily at any time and any place.
7. Agents :-
• An agent can be anything that perceiveits environment through sensors and act upon
that environment through actuators. An Agent runs in the cycle
of perceiving, thinking, and acting. An agent can be:
o Human-Agent: A human agent has eyes, ears, and other organs which work for
sensors and hand, legs, vocal tract work for actuators.
o Robotic Agent: A robotic agent can have cameras, infrared range finder, NLP for
sensors and various motors for actuators.
o Software Agent: Software agent can have keystrokes, file contents as sensory input
and act on those inputs and display output on the screen.
Before moving forward, we should first know about sensors, effectors, and
actuators.
o Sensor: Sensor is a device which detects the change in the environment and sends the
information to other electronic devices. An agent observes its environment through
sensors.
o Actuators: Actuators are the component of machines that converts energy into
motion. The actuators are only responsible for moving and controlling a system. An
actuator can be an electric motor, gears, rails, etc.
o Effectors: Effectors are the devices which affect the environment. Effectors can be
legs, wheels, arms, fingers, wings, fins, and display screen.
8. Types of AI Agents :-
• Goal-based agents:
o The knowledge of the current state environment is not always sufficient to decide for an agent
to what to do.
o The agent needs to know its goal which describes desirable situations.
o Goal-based agents expand the capabilities of the model-based agent by having the "goal"
information.
o They choose an action, so that they can achieve the goal.
o These agents may have to consider a long sequence of possible actions before deciding
whether the goal is achieved or not. Such considerations of different scenario are called
searching and planning, which makes an agent proactive.
• Utility-based agents:
o These agents are similar to the goal-based agent but provide an extra component of
utility measurement which makes them different by providing a measure of success
at a given state.
o Utility-based agent act based not only goals but also the best way to achieve the goal.
o The Utility-based agent is useful when there are multiple possible alternatives, and an
agent has to choose in order to perform the best action.
o The utility function maps each state to a real number to check how efficiently each
action achieves the goals.
• Learning Agents:
o A learning agent in AI is the type of agent which can learn from its past experiences,
or it has learning capabilities.
o It starts to act with basic knowledge and then able to act and adapt automatically
through learning.
o A learning agent has mainly four conceptual components, which are:
a. Learning element: It is responsible for making improvements by
learning from environment
b. Critic: Learning element takes feedback from critic which describes
that how well the agent is doing with respect to a fixed performance
standard.
c. Performance element: It is responsible for selecting external action
d. Problem generator: This component is responsible for suggesting
actions that will lead to new and informative experiences.
o Hence, learning agents are able to learn, analyze performance, and look for new ways
to improve the performance.
11.Features of Environment :-
• Fully observable vs Partially Observable:
o If an agent sensor can sense or access the complete state of an environment at each
point of time then it is a fully observable environment, else it is partially observable.
o A fully observable environment is easy as there is no need to maintain the internal
state to keep track history of the world.
o An agent with no sensors in all environments then such an environment is called
as unobservable.
• Deterministic vs Stochastic:
o If an agent's current state and selected action can completely determine the next state
of the environment, then such environment is called a deterministic environment.
o A stochastic environment is random in nature and cannot be determined completely
by an agent.
o In a deterministic, fully observable environment, agent does not need to worry about
uncertainty.
• Episodic vs Sequential:
o In an episodic environment, there is a series of one-shot actions, and only the current
percept is required for the action.
o However, in Sequential environment, an agent requires memory of past actions to
determine the next best actions.
• Single-agent vs Multi-agent
o If only one agent is involved in an environment, and operating by itself then such an
environment is called single agent environment.
o However, if multiple agents are operating in an environment, then such an
environment is called a multi-agent environment.
o The agent design problems in the multi-agent environment are different from single
agent environment.
• Static vs Dynamic:
o If the environment can change itself while an agent is deliberating then such
environment is called a dynamic environment else it is called a static environment.
o Static environments are easy to deal because an agent does not need to continue
looking at the world while deciding for an action.
o However for dynamic environment, agents need to keep looking at the world at each
action.
o Taxi driving is an example of a dynamic environment whereas Crossword puzzles are
an example of a static environment.
• Discrete vs Continuous:
o If in an environment there are a finite number of percepts and actions that can be
performed within it, then such an environment is called a discrete environment else it
is called continuous environment.
o A chess gamecomes under discrete environment as there is a finite number of moves
that can be performed.
o A self-driving car is an example of a continuous environment.
• Known vs Unknown:
o Known and unknown are not actually a feature of an environment, but it is an agent's
state of knowledge to perform an action.
o In a known environment, the results for all actions are known to the agent. While in
unknown environment, agent needs to learn how it works in order to perform an
action.
o It is quite possible that a known environment to be partially observable and an
Unknown environment to be fully observable.
• Accessible vs Inaccessible:
o If an agent can obtain complete and accurate information about the state's
environment, then such an environment is called an Accessible environment else it is
called inaccessible.
o An empty room whose state can be defined by its temperature is an example of an
accessible environment.
o Information about an event on earth is an example of Inaccessible environment.
12.Rational Agent :-
• A rational agent is an agent which has clear preference, models uncertainty, and acts
in a way to maximize its performance measure with all possible actions.
• A rational agent is said to perform the right things.
• AI is about creating rational agents to use for game theory and decision theory for
various real-world scenarios.
• For an AI agent, the rational action is most important because in AI reinforcement
learning algorithm, for each best possible action, agent gets the positive reward and
for each wrong action, an agent gets a negative reward.
• Rational agents in AI is very similar to intelligent agent.
13.Rationality :-
14.Structure of an AI Agent :-
• The task of AI is to design an agent program which implements the agent
function.
• The structure of an intelligent agent is a combination of architecture and
agent program. It can be viewed as:
Agent = Architecture + Agent program
Following are the main three terms involved in the structure of an AI agent:
15.PEAS :-
o P: Performance measure
o E: Environment
o A: Actuators
o S: Sensors
Here performance measure is the objective for the success of an agent's behavior.
UNIT-II
Advantages:
Disadvantages:
o It requires lots of memory since each level of the tree must be saved into
memory to expand the next level.
o BFS needs lots of time if the solution is far away from the root node.
Depth-first Search:
• Depth-first search isa recursive algorithm for traversing a tree or graph data
structure.
• It is called the depth-first search because it starts from the root node and follows
each path to its greatest depth node before moving to the next path.
• DFS uses a stack data structure for its implementation.
• The process of the DFS algorithm is similar to the BFS algorithm.
Note: Backtracking is an algorithm technique for finding all possible solutions using
recursion.
Advantage:
o DFS requires very less memory as it only needs to store a stack of the nodes on the
path from root node to the current node.
o It takes less time to reach to the goal node than BFS algorithm (if it traverses in the
right path).
Disadvantage:
o There is the possibility that many states keep re-occurring, and there is no guarantee
of finding the solution.
o DFS algorithm goes for deep down searching and sometime it may go to the infinite
loop.
o Standard failure value: It indicates that problem does not have any solution.
o Cut off failure value: It defines no solution for the problem within a given depth limit.
Advantages:
Disadvantages:
o Uniform cost search is optimal because at every state the path with the least cost is
chosen.
Disadvantages:
o It does not care about the number of steps involve in searching and only concerned
about path cost. Due to which this algorithm may be stuck in an infinite loop.
• The iterative deepening algorithm is a combination of DFS and BFS algorithms. This
search algorithm finds out the best depth limit and does it by gradually increasing the
limit until a goal is found.
• This algorithm performs depth-first search up to a certain "depth limit", and it keeps
increasing the depth limit after each iteration until the goal node is found.
• This Search algorithm combines the benefits of Breadth-first search's fast search and
depth-first search's memory efficiency.
• The iterative search algorithm is useful uninformed search when search space is large,
and depth of goal node is unknown.
Advantages:
o It combines the benefits of BFS and DFS search algorithm in terms of fast search and
memory efficiency.
Disadvantages:
o The main drawback of IDDFS is that it repeats all the work of the previous phase.
• Bidirectional search algorithm runs two simultaneous searches, one form initial state
called as forward-search and other from goal node called as backward-search, to find
the goal node.
• Bidirectional search replaces one single search graph with two small subgraphs in
which one starts the search from an initial vertex and other starts from goal vertex.
The search stops when these two graphs intersect each other.
Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Advantages:
Note : Heuristic is a function which is used in Informed Search, and it finds the most
promising path. It takes the current state of the agent as its input and produces the
estimation of how close agent is from the goal. The heuristic method, however, might not
always give the best solution, but it guaranteed to find a good solution in reasonable time.
Heuristic function estimates how close a state is to the goal. It is represented by h(n), and it
calculates the cost of an optimal path between the pair of states. The value of the heuristic
function is always positive.
• Greedy best-first search algorithm always selects the path which appears best at that
moment.
• It is the combination of depth-first search and breadth-first search algorithms.
• It uses the heuristic function and search. Best-first search allows us to take the
advantages of both algorithms.
• With the help of best-first search, at each step, we can choose the most promising
node.
• In the best first search algorithm, we expand the node which is closest to the goal
node and the closest cost is estimated by heuristic function, i.e.
Advantages:
o Best first search can switch between BFS and DFS by gaining the advantages of both
the algorithms.
o This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
o It can behave as an unguided depth-first search in the worst case scenario.
o It can get stuck in a loop as DFS.
o This algorithm is not optimal.
A* Search Algorithm:
Advantages:
o A* search algorithm is the best algorithm than other search algorithms.
o A* search algorithm is optimal and complete.
o This algorithm can solve very complex problems.
Disadvantages:
o It does not always produce the shortest path as it mostly based on heuristics and
approximation.
o A* search algorithm has some complexity issues.
o The main drawback of A* is memory requirement as it keeps all generated nodes in
the memory, so it is not practical for various large-scale problems.
Points to remember:
o A* algorithm returns the path which occurred first, and it does not search for all
remaining paths.
o The efficiency of A* algorithm depends on the quality of heuristic.
o A* algorithm expands all nodes which satisfy the condition f(n)<="" li="">
o Admissible: the first condition requires for optimality is that h(n) should be an
admissible heuristic for A* tree search. An admissible heuristic is optimistic in nature.
o Consistency: Second required condition is consistency for only A* graph-search.
If the heuristic function is admissible, then A* tree search will always find the least cost path.
Time Complexity: The time complexity of A* search algorithm depends on heuristic function,
and the number of nodes expanded is exponential to the depth of solution d. So the time
complexity is O(b^d), where b is the branching factor.
• Hill climbing algorithm is a local search algorithm which continuously moves in the
direction of increasing elevation/value to find the peak of the mountain or best
solution to the problem. It terminates when it reaches a peak value where no neighbor
has a higher value.
• Hill climbing algorithm is a technique which is used for optimizing the mathematical
problems. One of the widely discussed examples of Hill climbing algorithm is Traveling-
salesman Problem in which we need to minimize the distance traveled by the
salesman.
• It is also called greedy local search as it only looks to its good immediate neighbor state
and not beyond that.
• A node of hill climbing algorithm has two components which are state and value.
• Hill Climbing is mostly used when a good heuristic is available.
• In this algorithm, we don't need to maintain and handle the search tree or graph as it
only keeps a single current state.
Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only
evaluates the neighbor node state at a time and selects the first one which optimizes current
cost and set it as a current state. It only checks it's one successor state, and if it finds better
than the current state, then move else be in the same state. This algorithm has the following
features:
The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm
examines all the neighboring nodes of the current state and selects one neighbor node which
is closest to the goal state. This algorithm consumes more time as it searches for multiple
neighbors
Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this
search algorithm selects one neighbor node at random and decides whether to choose it as a
current state or examine another state.
1. Local Maximum: A local maximum is a peak state in the landscape which is better than
each of its neighboring states, but there is another state also present which is higher than the
local maximum.
Solution: Backtracking technique can be a solution of the local maximum in state space
landscape. Create a list of the promising path so that the algorithm can backtrack the search
space and explore other paths as well.
2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of
the current state contains the same value, because of this algorithm does not find any best
direction to move. A hill-climbing search might be lost in the plateau area.
Solution: The solution for the plateau is to take big steps or very little steps while searching,
to solve the problem. Randomly select a state which is far away from the current state so it is
possible that the algorithm could find non-plateau region.
3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher than
its surrounding areas, but itself has a slope, and cannot be reached in a single move.
Solution: With the use of bidirectional search, or by moving in different directions, we can
improve this problem.
Simulated Annealing:
A hill-climbing algorithm which never makes a move towards a lower value guaranteed to be
incomplete because it can get stuck on a local maximum. And if algorithm applies a random
walk, by moving a successor, then it may complete but not efficient. Simulated Annealing is
an algorithm which yields both efficiency and completeness.
Genetic Algorithm :-
• A Genetic algorithm is a local search technique used in computing to find true or
approximate solutions to optimization and state space search problems.
• This algorithm is a class of evolutionary algorithms that uses techniques like
inheritance, mutation, selection, and crossover inspired by evolutionary biology.
• The idea is taken from natural selection. i.e. Favourable traits become common and
unfavorable traits become uncommon in successive generations.
• The solution is given by the survival of the fittest(Best solution).
Beam Search :-
• Beam search is a heuristic search algorithm that explores a graph by expanding the
most optimistic node in a limited set.
• Beam search is an optimization of best-first search that reduces its memory
requirements.
• Best-first search is a graph search that orders all partial solutions according to some
heuristic. But in beam search, only a predetermined number of best partial solutions
are kept as candidates. Therefore, it is a greedy algorithm.
• Beam search uses breadth-first search to build its search tree. The beam width can
either be fixed or variable.
• If no solution is found, the beam is widened, and the procedure is repeated.
A beam search is most often used to maintain tractability in large systems with insufficient
memory to store the entire search tree. For example,
o In general, the Beam Search Algorithm is not complete. Despite these disadvantages,
beam search has found success in the practical areas of speech recognition, vision,
planning, and machine learning.
o The main disadvantages of a beam search are that the search may not result in an
optimal goal and may not even reach a goal at all after given unlimited time and
memory when there is a path from the start node to the goal node.
o The beam search algorithm terminates for two cases: a required goal node is reached,
or a goal node is not reached, and there are no nodes left to be explored.
o A more accurate heuristic function and a larger beam width can improve Beam
Search's chances of finding the goal.
UNIT- III
1. Knowledge-Based Agent in Artificial intelligence :-
• An intelligent agent needs knowledge about the real world for taking decisions
and reasoning to act efficiently.
• Knowledge-based agents are those agents who have the capability of maintaining an
internal state of knowledge, reason over that knowledge, update their knowledge
after observations and take actions. These agents can represent the world with some
formal representation and act intelligently.
• Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system.
Knowledge-base is required for updating knowledge for an agent to learn with experiences
and take action as per the knowledge.
➢ Inference system
Inference means deriving new sentences from old. Inference system allows us to add a new
sentence to the knowledge base. A sentence is a proposition about the world. Inference
system applies logical rules to the KB to deduce new information.
Inference system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as:
The Forward-chaining algorithm starts from known facts, triggers all rules whose premises
are satisfied, and add their conclusion to the known facts. This process repeats until the
problem is solved.
Properties of Forward-Chaining:
Following are three operations which are performed by KBA in order to show the intelligent
behavior:
1. TELL: This operation tells the knowledge base what it perceives from the environment.
2. ASK: This operation asks the knowledge base what action it should perform.
3. Perform: It performs the selected action.
A knowledge-based agent can be viewed at different levels which are given below:
i. Knowledge level
Knowledge level is the first level of knowledge-based agent, and in this level, we need to
specify what the agent knows, and what the agent goals are. With these specifications, we
can fix its behavior. For example, suppose an automated taxi agent needs to go from a station
A to station B, and he knows the way from A to B, so this comes at the knowledge level.
At this level, we understand that how the knowledge representation of knowledge is stored.
At this level, sentences are encoded into different logics. At the logical level, an encoding of
knowledge into logical sentences occurs. At the logical level we can expect to the automated
taxi agent to reach to the destination B.
This is the physical representation of logic and knowledge. At the implementation level agent
perform actions as per logical and knowledge level. At this level, an automated taxi agent
actually implement his knowledge and logic so that he can reach to the destination.
5. Knowledge Representation :-
o Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence
which concerned with AI agents thinking and how thinking contributes to intelligent
behavior of agents.
o It is responsible for representing information about the real world so that a computer
can understand and can utilize this knowledge to solve the complex real world
problems such as diagnosis a medical condition or communicating with humans in
natural language.
o It is also a way which describes how we can represent knowledge in artificial
intelligence. Knowledge representation is not just storing data into some database,
but it also enables an intelligent machine to learn from that knowledge and
experiences so that it can behave intelligently like a human.
6. What to Represent:
o Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o Knowledge-Base: The central component of the knowledge-based agents is the
knowledge base. It is represented as KB. The Knowledgebase is a group of the
Sentences (Here, sentences are used as a technical term and not identical with the
English language).
i. Declarative Knowledge:
iii. Meta-knowledge:
v. Structural knowledge:
1. 1. Representational Accuracy : KR system should have the ability to represent all kind
of required knowledge.
2. 2. Inferential Adequacy : KR system should have ability to manipulate the
representational structures to produce new knowledge corresponding to existing
structure.
3. 3. Inferential Efficiency : The ability to direct the inferential knowledge mechanism
into the most productive directions by storing appropriate guides.
4. 4. Acquisitional Efficiency : The ability to acquire the new knowledge easily using
automatic methods.
9. AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behavior:
o Perception
o Learning
o Knowledge Representation and Reasoning
o Planning
o Execution
The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence. AI system has Perception component by which it
retrieves information from its environment. It can be visual, audio or another form of sensory
input. The learning component is responsible for learning from data captured by Perception
comportment. In the complete cycle, the main components are knowledge representation
and Reasoning. These two components are involved in showing the intelligence in machine-
like humans. These two components are independent with each other but also coupled
together. The planning and execution depend on analysis of Knowledge representation and
reasoning.
There are mainly four approaches to knowledge representation, which are given below:
11.First-Order logic :-
• First-order logic is another way of knowledge representation in artificial intelligence.
It is an extension to propositional logic.
• FOL is sufficiently expressive to represent the natural language statements in a concise
way.
• First-order logic is also known as Predicate logic or First-order predicate logic. First-
order logic is a powerful language that develops information about the objects in a
more easy way and can also express the relationship between those objects.
• First-order logic (like natural language) does not only assume that the world contains
facts like propositional logic but also assumes the following things in the world:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus,
o Relations: It can be unary relation such as: red, round, is adjacent, or n-any
relation such as: the sister of, brother of, has color, comes between
o Function: Father of, best friend, third inning of, end of, ......
• As a natural language, first-order logic also has three main parts:
o Syntax : Specifies the symbols in the language about how they can be
combined to form sentences. The facts about the world are represented as
sentences in logic.
o Semantics : Specifies how to assign a truth value to a sentence based on
its meaning in the world. It Specifies what facts a sentence refers to.
A fact is a claim about the world, and it may be TRUE or FALSE.
o Inference Procedure : Specifies methods for computing new sentences from
the existing sentences.
12. KR using Rules :-
• Knowledge representation using rules in AI involves expressing knowledge about
the world in the form of logical rules.
• These rules typically consist of an antecedent (also known as the condition or
premise) and a consequent (also known as the action or conclusion). They specify
conditions under which certain actions or conclusions can be inferred.
• Rules-based knowledge representation is often used in expert systems, which are
AI systems designed to mimic the decision-making capabilities of human experts
in specific domains.
• The knowledge in expert systems is encoded as a set of rules that can be applied
to solve problems or provide advice in the domain of expertise.
In this example, we have two rules. Rule 1 states that if it is raining, the action to be taken
is to take an umbrella. Rule 2 states that if it is both cold and raining, the action to be
taken is to wear a coat.
To represent and utilize this knowledge, an AI system can match the conditions in the
rules with the available information or input. If the conditions are satisfied, the system
can apply the corresponding actions or draw conclusions. For instance, if the system
determines that it is both cold and raining, it can infer that wearing a coat is necessary
based on Rule 2.
Rules can be combined using logical connectives like AND, OR, and NOT to express more
complex relationships and conditions. They can also involve variables to represent
unknown or generic entities.
Rules-based knowledge representation offers a clear and intuitive way to encode and
reason with domain-specific knowledge. However, as the number of rules increases or
when rules interact in complex ways, it can become challenging to manage and reason
with the knowledge effectively. Therefore, other knowledge representation formalisms,
such as ontologies and probabilistic models, are also used in AI to address the limitations
of rules-based approaches in certain scenarios.
13. Symbolic AI :-
• Symbolic AI is an approach that trains Artificial Intelligence (AI) the same way
human brain learns.
• It learns to understand the world by forming internal symbolic representations of
its “world”.
• Symbols play a vital role in the human thought and reasoning process. We learn
both objects and abstract concepts, then create rules for dealing with these
concepts. These rules can be formalized in a way that captures everyday
knowledge.
• Symbolic AI mimics this mechanism and attempts to explicitly represent human
knowledge through human-readable symbols and rules that enable the
manipulation of those symbols.
• Symbolic AI entails embedding human knowledge and behavior rules into
computer programs.
• Siri and other digital assistants use Symbolic AI to understand natural language and provide
responses.
• Medical diagnosis systems use Symbolic AI to provide recommendations to doctors based on
patient symptoms (as demonstrated earlier).
• Autonomous cars use Symbolic AI to make decisions based on the environment, such as
recognizing stop signs and traffic lights.
• Computer vision systems use Symbolic AI to recognize objects and patterns in images.
19.Statistical Reasoning :-
• Statistical reasoning, also known as statistical AI or machine learning.
• It is an approach that focuses on learning patterns and making predictions from
data through statistical techniques.
• It involves the use of algorithms that can automatically learn from examples or
data without being explicitly programmed with rules.
• Statistical reasoning systems learn from training data to identify patterns,
relationships, and statistical regularities in the data.
• These systems use statistical models, such as neural networks, decision trees, or
support vector machines, to generalize from the training data and make
predictions or decisions on new, unseen data.
• Statistical reasoning is well-suited for tasks such as pattern recognition,
classification, regression, clustering, and reinforcement learning.
• It can handle large amounts of data and can capture complex patterns and
relationships, but it may lack explainability and interpretability compared to
symbolic reasoning.
20.Applications of Statistical Reasoning :-
❖ Image and Object Recognition: Statistical reasoning techniques, particularly deep
learning algorithms, have revolutionized image and object recognition tasks.
Convolutional neural networks (CNNs) are used to learn and recognize patterns,
features, and objects within images. Applications include facial recognition, object
detection, image classification, and autonomous vehicles.
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.
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.
❖ 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.
❖ 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.
❖ 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
❖ Not affected by emotions: These systems are not affected by human emotions such
as fatigue, anger, depression, anxiety, etc.. Hence the performance remains constant.
❖ High security: These systems provide high security to resolve any query.
❖ 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.
❖ 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 Provide decision-making capabilities: It provides the capability of decision making in
any domain, such as for making any financial decision, decisions in medical science,
etc.
o Demonstrate a device: It is capable of demonstrating any new products such as its
features, specifications, how to use that product, etc.
o Problem-solving: It has problem-solving capabilities.
o Explaining a problem: It is also capable of providing a detailed description of an input
problem.
o Interpreting the input: It is capable of interpreting the input given by the user.
o Predicting results: It can be used for the prediction of a result.
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 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.
o MYCIN: It was one of the earliest backward chaining expert systems that was designed
to find the bacteria causing infections like bacteraemia and meningitis. It was also
used for the recommendation of antibiotics and the diagnosis of blood clotting
diseases.
o 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.
o CaDeT: The CaDet expert system is a diagnostic support system that can detect cancer
at early stages.
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.
The generic components of a shell : the knowledge acquisition, the knowledge Base,
the reasoning, the explanation and the user interface are shown below. The
knowledge base and reasoning engine are the core components.
▪ Knowledge Base - A store of factual and heuristic knowledge. Expert system tool
provides one or more knowledge representation schemes for expressing
knowledge about the application domain. Some tools use both Frames (objects)
and IF-THEN rules. In PROLOG the knowledge is represented as logical statements.
▪ Reasoning Engine - Inference mechanisms for manipulating the symbolic
information and knowledge in the knowledge base form a line of reasoning in
solving a problem. The inference mechanism can range from simple modus ponens
backward chaining of IF-THEN rules to Case-Based reasoning.
▪ Knowledge Acquisition subsystem - A subsystem to help experts in build
knowledge bases. However, collecting knowledge, needed to solve problems and
build the knowledge base, is the biggest bottleneck in building expert systems.
▪ Explanation subsystem - A subsystem that explains the system's actions. The
explanation can range from how the final or intermediate solutions were arrived
at justifying the need for additional data.
▪ User Interface - A means of communication with the user. The user interface is
generally not a part of the expert system technology. It was not given much
attention in the past. However, the user interface can make a critical difference in
the pe eived utility of an Expert system.
The given figure illustrates the typical diagram of Biological Neural Network.
The typical Artificial Neural Network looks something like the given figure.
• Dendrites from Biological Neural Network represent inputs in Artificial Neural
Networks, cell nucleus represents Nodes, synapse represents Weights, and Axon
represents Output
Input Layer:As the name suggests, it accepts inputs in several different formats provided
by the programmer.
Hidden Layer:The hidden layer presents in-between input and output layers. It performs
all the calculations to find hidden features and patterns.
Output Layer:The input goes through a series of transformations using the hidden layer,
which finally results in output that is conveyed using this layer.
The artificial neural network takes input and computes the weighted sum of the inputs
and includes a bias. This computation is represented in the form of a transfer function.
❖ Parallel processing capability : Artificial neural networks have a numerical value that
can perform more than one task simultaneously.
❖ Storing data on the entire network : Data that is used in traditional programming is
stored on the whole network, not on a database. The disappearance of a couple of
pieces of data in one place doesn't prevent the network from working.
❖ Capability to work with incomplete knowledge : After ANN training, the information
may produce output even with inadequate data. The loss of performance here relies
upon the significance of missing data.
❖ Having a memory distribution : For ANN is to be able to adapt, it is important to
determine the examples and to encourage the network according to the desired
output by demonstrating these examples to the network. The succession of the
network is directly proportional to the chosen instances, and if the event can't appear
to the network in all its aspects, it can produce false output
❖ Having fault tolerance:Extortion of one or more cells of ANN does not prohibit
it from generating output, and this feature makes the network fault-tolerance.
✓ Inputs: The neuron receives inputs from other neurons or directly from the external
environment. Each input is associated with a weight, which determines its
significance in the neuron's computation.
✓ Weights: Each input to the neuron is multiplied by a weight. The weights reflect the
strength or importance of the corresponding inputs in the neuron's computation.
These weights can be adjusted during the training process to optimize the neuron's
performance.
✓ Summation Function: The weighted inputs are summed together using a summation
function. The purpose of this function is to combine the inputs with their respective
weights.
✓ Activation Function: The summation result is then passed through an activation
function, which introduces non-linearity into the neuron's output. The activation
function helps determine whether the neuron should "fire" (produce an output
signal) based on the inputs it receives. The activation function is a critical component
of the artificial neuron model
✓ Bias: A bias term is often added to the neuron's computation. It acts as an additional
input that can shift the activation function's threshold, allowing for more flexibility in
the neuron's response.
✓ Output: The output of the neuron is the result of the activation function applied to
the weighted inputs and bias. This output is then propagated to other neurons in the
network as input.
Overall, the artificial neuron model provides a simplified representation of how individual
neurons in a neural network process inputs, apply weights, and produce outputs. When
combined in layers and interconnected, these artificial neurons form powerful neural
networks capable of learning and making predictions.
Neural networks learn through a process called training, where they adjust their internal
parameters (weights and biases) to minimize the difference between their predicted
outputs and the desired outputs. There are several learning methods or algorithms used
in neural networks. Let's explore a few of them:
• Perceptrons are acyclic in nature. The sum of the product of weights and the inputs
is calculated in each node.
• The input layer transmits the signals to the output layer. The output layer performs
computations.
• Perceptron can learn only a linear function and requires less training output.
• The output can be represented in one or two values(0 or 1).
Advantages of Single-layered Neural Network
• Single layer neural networks are easy to set up and train them as there is absence of
hidden layers
• It has explicit links to statistical models
Disadvantages of Single-layered Neural Network
• It can work better only for linearly separable data.
• Single layer neural network has low accuracy as compared to multi-layer neural
network.
24.Genetic Algorithm :-
• A genetic algorithm is an adaptive heuristic search algorithm inspired by "Darwin's
theory of evolution in Nature." It is used to solve optimization problems in machine
learning.
• It is one of the important algorithms as it helps solve complex problems that would
take a long time to solve. Genetic algorithms are based on the ideas of natural
selection and genetics.
• They are commonly used to generate high-quality solutions for optimization
problems and search problems.
• Genetic algorithms simulate the process of natural selection which means those
species who can adapt to changes in their environment are able to survive and
reproduce and go to next generation. In simple words, they simulate “survival of the
fittest” among individual of consecutive generation for solving a problem.
25.Encoding
• In a genetic algorithm (GA), encoding refers to the representation of candidate
solutions or individuals in a problem space.
• It involves encoding the problem variables or characteristics into a format that can
be manipulated and evolved through genetic operations such as crossover and
mutation.
26.Encoding Methods :-
The choice of encoding scheme greatly influences the performance and efficiency of
a genetic algorithm. Here are a few common encoding methods used in genetic
algorithms:
➢ Binary Encoding: Binary encoding represents each variable or attribute of an
individual as a string of binary bits. Each bit in the string corresponds to a specific
attribute or gene. This encoding is useful for problems with discrete or Boolean
variables.
➢ Integer Encoding: Integer encoding represents each variable as an integer value
within a predefined range. The range of integers represents the possible values that
the variable can take. This encoding is suitable for problems with discrete or integer
variables.
➢ Real-Valued Encoding: Real-valued encoding represents each variable as a floating-
point or real number within a predefined range. The range of real values represents
the possible values that the variable can take. This encoding is suitable for problems
with continuous variables.
➢ Permutation Encoding: Permutation encoding is used for problems involving
permutations, such as the traveling salesman problem. Each individual is
represented as a sequence of integers, where each integer represents a unique
element or position.
➢ Tree Encoding: Tree encoding is used when the solution structure is best
represented as a tree or hierarchical structure. Each individual is encoded as a tree,
with nodes representing different components or attributes of the solution.
Once the encoding is defined, the genetic algorithm can operate on the encoded individuals
by applying genetic operators like crossover (recombination) and mutation. These
operators manipulate the encoded representations to create new individuals and generate
diversity in the population, enabling the algorithm to search for optimal or near-optimal
solutions to the problem at hand.
Eg.
✓ Mutation Operator: The key idea is to insert random genes in offspring to
maintain the diversity in the population to avoid premature convergence.
For example –
28.Basic genetic algorithms :-
• Basic genetic algorithms (GAs) are a class of optimization algorithms inspired by the
process of natural selection and evolution.
• They mimic the process of natural evolution to search for optimal or near-optimal
solutions to a given problem.
❖ Selection: Individuals are selected from the population based on their fitness values.
The selection process is typically biased towards individuals with higher fitness,
allowing them to have a higher chance of being chosen for reproduction.
❖ Reproduction: The selected individuals are used to create offspring for the next
generation. This is done through genetic operators such as crossover and mutation.
Crossover involves combining genetic material from two parent individuals to create
new individuals, while mutation introduces random changes in the genetic material.
❖ Replacement: The new offspring replace a portion of the existing population. The
specific replacement strategy can vary, such as replacing the least fit individuals or
using elitism to preserve the best individuals from the previous generation.
❖ Solution Extraction: Once the termination condition is met, the algorithm returns
the best individual(s) found during the optimization process as the solution(s) to the
problem.
29.How Genetic Algorithm Work?
1. Initialization : The process of a genetic algorithm starts by generating the set of individuals,
which is called population. Here each individual is the solution for the given problem. An
individual contains or is characterized by a set of parameters called Genes. Genes are
combined into a string and generate chromosomes, which is the solution to the problem. One
of the most popular techniques for initialization is the use of random binary strings.
2. Fitness Assignment : Fitness function is used to determine how fit an individual is? It means
the ability of an individual to compete with other individuals. In every iteration, individuals
are evaluated based on their fitness function. The fitness function provides a fitness score to
each individual. This score further determines the probability of being selected for
reproduction. The high the fitness score, the more chances of getting selected for
reproduction.
3. Selection : The selection phase involves the selection of individuals for the reproduction of
offspring. All the selected individuals are then arranged in a pair of two to increase
reproduction. Then these individuals transfer their genes to the next generation.
4. Reproduction : After the selection process, the creation of a child occurs in the
reproduction step. In this step, the genetic algorithm uses two variation operators that are
applied to the parent population. The two operators involved in the reproduction phase are
given below:
o Crossover: The crossover plays a most significant role in the reproduction phase of
the genetic algorithm. In this process, a crossover point is selected at random within
the genes. Then the crossover operator swaps genetic information of two parents
from the current generation to produce a new individual representing the offspring.
The genes of parents are exchanged among themselves until the crossover point is
met. These newly generated offspring are added to the population. This process is
also called or crossover. Types of crossover styles available:
o One point crossover
o Two-point crossover
o Livery crossover
o Inheritable Algorithms crossover
o Mutation
The mutation operator inserts random genes in the offspring (new child) to maintain
the diversity in the population. It can be done by flipping some bits in the
chromosomes.
Mutation helps in solving the issue of premature convergence and enhances
diversification. The below image shows the mutation process:
Types of mutation styles available,
o Flip bit mutation
o Gaussian mutation
o Exchange/Swap mutation
5. Termination : After the reproduction phase, a stopping criterion is applied as a base for
termination. The algorithm terminates after the threshold fitness solution is reached. It will
identify the final solution as the best solution in the population.