0% found this document useful (0 votes)
42 views

AI Notes

The document discusses the introduction to artificial intelligence including its goals, techniques, and applications. It covers topics such as machine learning, deep learning, natural language processing, robotics, expert systems, and more. The Turing test is also explained as a way to test machine intelligence.

Uploaded by

zoyasaiyyed46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

AI Notes

The document discusses the introduction to artificial intelligence including its goals, techniques, and applications. It covers topics such as machine learning, deep learning, natural language processing, robotics, expert systems, and more. The Turing test is also explained as a way to test machine intelligence.

Uploaded by

zoyasaiyyed46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 101

Kavayitri Bahinabai

Chaudhary North
Maharashtra
University ,Jalgaon

M.sc Information
Technology
Semester Ist (2023-2024)
Artificial Intelligence

1.Introduction (marks:18)
2. State space Search and heuristic
Search Techniques (marks:18)

3.Knowledge Representation
(marks:10)

4.Reasoning (marks:10)

5.Game Playing And planning (marks:10)

6. Machine Learning (marks:16)

1-Introduction
Overview and definition of AI techniques:
What is Artificial Intelligence?
According to the father of Artificial Intelligence, John McCarthy, it is “The science and
engineering of making intelligent machines, especially intelligent computer programs”.
Artificial Intelligence is a way of making a computer, a computer-controlled robot, or a
software think intelligently, in the similar manner the intelligent humans think.
AI is accomplished by studying how human brain thinks, and how humans learn, decide, and
work while trying to solve a problem, and then using the outcomes of this study as a basis of
developing intelligent software and systems.

Goals of AI
 To Create Expert Systems − The systems which exhibit intelligent behavior,
learn, demonstrate, explain, and advice its users.
 To Implement Human Intelligence in Machines − Creating systems that
understand, think, learn, and behave like humans.

What Contributes to AI?


Artificial intelligence is a science and technology based on disciplines such as Computer
Science, Biology, Psychology, Linguistics, Mathematics, and Engineering. A major thrust of
AI is in the development of computer functions associated with human intelligence, such as
reasoning, learning, and problem solving Out of the following areas, one or multiple areas
can contribute to build an intelligent system.

What is AI Technique?
In the real world, the knowledge has some unwelcomed properties −

 Its volume is huge, next to unimaginable.


 It is not well-organized or well-formatted.
 It keeps changing constantly.
AI Technique is a manner to organize and use the knowledge efficiently in such a way that −

 It should be perceivable by the people who provide it.


 It should be easily modifiable to correct errors.
 It should be useful in many situations though it is incomplete or inaccurate.
AI techniques elevate the speed of execution of the complex program it is equipped with.

Turing Test in AI
In 1950, Alan Turing introduced a test to check whether a machine can think like a
human or not, this test is known as the Turing Test. In this test, Turing proposed that
the computer can be said to be an intelligent if it can mimic human response under
specific conditions.

Turing Test was introduced by Turing in his 1950 paper, "Computing Machinery and
Intelligence," which considered the question, "Can Machine think?"

The Turing test is based on a party game "Imitation game," with some modifications. This
game involves three players in which one player is Computer, another player is human
responder, and the third player is a human Interrogator, who is isolated from other two
players and his job is to find that which player is machine among two of them.

Consider, Player A is a computer, Player B is human, and Player C is an interrogator.


Interrogator is aware that one of them is machine, but he needs to identify this on
the basis of questions and their responses.

The conversation between all players is via keyboard and screen so the result would
not depend on the machine's ability to convert words as speech.
The test result does not depend on each correct answer, but only how closely its
responses like a human answer. The computer is permitted to do everything possible
to force a wrong identification by the interrogator.

Interrogator: Are you a computer?

PlayerA (Computer): No

Interrogator: Multiply two large numbers such as (256896489*456725896)

Player A: Long pause and give the wrong answer.

In this game, if an interrogator would not be able to identify which is a machine and
which is human, then the computer passes the test successfully, and the machine is
said to be intelligent and can think like a human.

"In 1991, the New York businessman Hugh Loebner announces the prize
competition, offering a $100,000 prize for the first computer to pass the Turing test.
However, no AI program to till date, come close to passing an undiluted Turing test".

Advantages of the Turing Test in Artificial Intelligence:

1. Evaluating machine intelligence: The Turing Test provides a simple and


well-known method for evaluating the intelligence of a machine.
2. Setting a benchmark: The Turing Test sets a benchmark for artificial
intelligence research and provides a goal for researchers to strive towards.
3. Inspiring research: The Turing Test has inspired numerous studies and
experiments aimed at developing machines that can pass the test, which
has driven progress in the field of artificial intelligence.
4. Simple to administer: The Turing Test is relatively simple to administer
and can be carried

Disadvantages of the Turing Test in Artificial Intelligence:

1. Limited scope: The Turing Test is limited in scope, focusing primarily on


language-based conversations and not taking into account other important
aspects of intelligence, such as perception, problem-solving, and decision-
making.
2. Human bias: The results of the Turing Test can be influenced by the biases
and preferences of the human judge, making it difficult to obtain objective
and reliable results.
3. Not representative of real-world AI: The Turing Test may not be
representative of the kind of intelligence that machines need to
demonstrate in real-world applications.
Branches Of Artifical Intelligence
Artificial Intelligence can be used to solve real-world problems by implementing
the following processes/ techniques:

1. Machine Learning
2. Deep Learning
3. Natural Language Processing
4. Robotics
5. Expert Systems
6. Fuzzy Logic

Machine Learning:
Machine Learning is the science of getting machines to interpret, process and
analyze data in order to solve real-world problems.

Under Machine Learning there are three categories:

1. Supervised Learning
2. Unsupervised Learning
3. Reinforcement Learning

Deep Learning:
Deep Learning is the process of implementing Neural Networks on high
dimensional data to gain insights and form solutions. Deep Learning is an
advanced field of Machine Learning that can be used to solve more
advanced problems. Deep Learning is the logic behind the face
verification algorithm on Facebook, self-driving cars, virtual assistants like
Siri, Alexa and so on.

Natural Language Processing:


Natural Language Processing (NLP) refers to the science of drawing insights from
natural human language in order to communicate with machines and grow
businesses. Twitter uses NLP to filter out terroristic language in their tweets,
Amazon uses NLP to understand customer reviews and improve user
experience.
Robotics:
Robotics is a branch of Artificial Intelligence which focuses on different branches
and application of robots. AI Robots are artificial agents acting in a real-world
environment to produce results by taking accountable actions. Sophia the
humanoid is a good example of AI in robotics

Fuzzy Logic:
Fuzzy logic is a computing approach based on the principles of “degrees of truth”
instead of the usual modern computer logic i.e. boolean in nature. Fuzzy logic is
used in the medical fields to solve complex problems that involve decision making. They
are also used in automatic gearboxes, vehicle environment control and so on.

Expert Systems
An expert system is an AI-based computer system that learns and reciprocates
the decision-making ability of a human expert. Expert systems use if-then logical
notations to solve complex problems. It does not rely on conventional procedural
programming. Expert systems are mainly used in information management, medical
facilities, loan analysis, virus detection and so on.

Application of AI
Artificial Intelligence has various applications in today's society. It is becoming
essential for today's time because it can solve complex problems with an efficient
way in multiple industries, such as Healthcare, entertainment, finance, education, etc.
AI is making our daily life more comfortable and fast.

Following are some sectors which have the application of Artificial Intelligence:

1. 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.

2. 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.

3. 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.

4. 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.

5. 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.

6. 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.

7. AI in Travel & Transport

o AI is becoming highly demanding for travel industries. AI is capable of doing


various travel related works such as from making travel arrangement to
suggesting the hotels, flights, and best routes to the customers. Travel
industries are using AI-powered chatbots which can make human-like
interaction with customers for better and fast response.
8. 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.

9. 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.

10. 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.

11. 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.

12. 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.
13. 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.

Intelligent Agents:

What is an Agent?
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.

Intelligent Agents:
An intelligent agent is an autonomous entity which act upon an environment using
sensors and actuators for achieving goals. An intelligent agent may learn from the
environment to achieve their goals. A thermostat is an example of an intelligent
agent.

Following are the main four rules for an AI agent:

o Rule 1: An AI agent must have the ability to perceive the environment.


o Rule 2: The observation must be used to make decisions.
o Rule 3: Decision should result in an action.
o Rule 4: The action taken by an AI agent must be a rational action.

Structure of intelligent agents:


The IA structure consists of three main parts: architecture, agent function,
and agent program.

Agent = Architecture + Agent Program


1. Architecture: This refers to machinery or devices that consists of
actuators and sensors. The intelligent agent executes on this
machinery. Examples include a personal computer, a car, or a
camera.

2. Agent function: This is a function in which actions are mapped


from a certain percept sequence. Percept sequence refers to a history
of what the intelligent agent has perceived.

3. Agent program: This is an implementation or execution of the


agent function. The agent function is produced through the agent
program’s execution on the physical architecture.

Types of AI Agents:
Agents can be grouped into five classes based on their degree of perceived
intelligence and capability. All these agents can improve their performance and
generate better action over the time. These are given below:

o Simple Reflex Agent


o Model-based reflex agent
o Goal-based agents
o Utility-based agent
o Learning agent

1. Simple Reflex agent:


o The Simple reflex agents are the simplest agents. These agents take decisions
on the basis of the current percepts and ignore the rest of the percept history.
o These agents only succeed in the fully observable environment.
o The Simple reflex agent does not consider any part of percepts history during
their decision and action process.
o The Simple reflex agent works on Condition-action rule, which means it maps
the current state to action. Such as a Room Cleaner agent, it works only if
there is dirt in the room.
o Problems for the simple reflex agent design approach:
o They have very limited intelligence
o They do not have knowledge of non-perceptual parts of the current
state
o Mostly too big to generate and to store.
o Not adaptive to changes in the environment.

2. Model-based reflex agent


o The Model-based agent can work in a partially observable environment, and
track the situation.
o A model-based agent has two important factors:
o Model: It is knowledge about "how things happen in the world," so it is
called a Model-based agent.
o Internal State: It is a representation of the current state based on
percept history.
o These agents have the model, "which is knowledge of the world" and based
on the model they perform actions.
o Updating the agent state requires information about:
a. How the world evolves
b. How the agent's action affects the world

3. 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.
4. 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.
5. 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:

1. Learning element: It is responsible for making improvements by


learning from environment

2. Critic: Learning element takes feedback from critic which describes that
how well the agent is doing with respect to a fixed performance
standard.

3. Performance element: It is responsible for selecting external action

4. 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.

Autonomous Agents:
What is Autonomous AI?
An autonomous AI agent is a computer system that collects sensory input from its
surroundings and determines on its own how to tie the external stimuli to its
behaviors to achieve certain goals.
These autonomous assistants receive user input, split it down into smaller jobs with
the help of LLMs, and tackle them one at a time. The agents save the results and, if
necessary, employ them in the following rounds of the process. As a result, the top
10 autonomous AI agents can handle challenging jobs and have access to a variety
of fundamental models that aren’t only limited to language. For example, an agent
may decide on its own to use code, video, or speech models; search engines, or
calculating tools to do the work you’ve assigned to it.

1.AgentGPT

AgentGPT online is a self-driving AI platform that allows users to design and deploy
customizable self-driving AI agents directly in the browser. All you have to do is give
your AI agent a name and a purpose, and then watch as it embarks on an adventure
to attain the goal you provided. To fulfill its designated goal, the agent will
autonomously gain information, execute actions, communicate, and adapt.

2.Baby AGI
Baby AGI is an artificial intelligence-powered task management system. To generate,
prioritize, and execute tasks, the system makes use of the OpenAI and Pinecone APIs.
The attractiveness of Baby AGI lies in its capacity to perform challenges
autonomously based on the results of prior tasks while maintaining a set purpose. It
also efficiently prioritizes jobs.

3.Auto-GPT
Auto-GPT is an “AI agent” that will attempt to achieve a goal in natural language by
breaking it down into sub-tasks and utilizing the internet and other tools in an
automated loop. It makes use of OpenAI’s GPT-4 or GPT-3.5 APIs and is one of the
first applications to leverage GPT-4 to execute autonomous tasks.

4.Agent-LLM
An AI Automation Platform called Agent-LLM offers efficient AI instruction
management across several vendors. The agents have adaptive memory, and this
adaptable solution includes a robust plugin system that enables a wide variety of
commands, including web browsing. Agent-LLM is constantly evolving to enable
more AI providers and models, allowing for a broader range of applications.
5.JARVIS / HuggingGPT
Jarvis, also known as HuggingGPT, is a collaborative system made up of a Large
Language Model (LLM) as the central controller and a plethora of expert models as
collaborative executors provided by the Hugging Face Hub. This agent is capable of
using LLMs as well as other models.

6.Xircuits
The Xircuits toolbox includes everything you need to experiment with and build
Collaborative Large Language Model-based automatons (Agents) in the spirit of
BabyAGI and Auto-GPT. The toolkit includes BabyAGI agents by default, but it may
simply be customized to accept your unique prompts.

7.ChaosGPT
ChaosGPT, also known as the autonomous agent attempting to destroy humanity. It
has thus far failed miserably owing to a lack of access to weapons of mass
devastation. It is nevertheless intriguing to see its aspirations for world dominance,
especially given that its basic models are based on humanity’s collective thoughts
about the subject.

8.Micro-GPT
MicroGPT is a lightweight autonomous agent that works with GPT-3.5-Turbo and
GPT-4. It combines strong urging, a limited tool set, and short-term memory. Vector
storage for data augmentation will be introduced soon.

9.AutoGPT.js
AutoGPT. js is an open-source project aimed at bringing AutoGPT’s tremendous
features to your browser. AutoGPT. js provides increased accessibility and privacy by
operating directly in the browser.

10.SFighterAI
To defeat the last boss in “Street Fighter II: Special Champion Edition,” SFighterAI
provides an AI agent trained using deep reinforcement learning. The AI agent makes
judgments based exclusively on the RGB pixel values of the game screen, attaining a
100% victory rate in some cases.
*************************

2)State space search and heuristic search techniques

defining problem as a state space search:


A state space is a mathematical representation of a problem that
defines all possible states that the problem can be in. Furthermore,
in search algorithms, we use a state space to represent the current
state of the problem, the initial state, and the goal state.
production system:
The production system is a model of computation that can be applied to
implement search algorithms and model human problem solving. Such problem
solving knowledge can be packed up in the form of little quanta called
productions. A production is a rule consisting of a situation recognition part and
an action part. A production is a situation-action pair in which the left side is a
list of things to watch for and the right side is a list of things to do so. When
productions are used in deductive systems, the situation that trigger productions
are specified combination of facts. The actions are restricted to being assertion
of new facts deduced directly from the triggering combination. Production
systems may be called premise conclusion pairs rather than situation action pair.

Characteristics of production system:


There are mainly four characteristics of the production system in AI that is simplicity,
modifiability, modularity, and knowledge-intensive.

Simplicity

The production rule in AI is in the form of an ‘IF-THEN’ statement. Every rule in


the production system has a unique structure. It helps represent knowledge and
reasoning in the simplest way possible to solve real-world problems. Also, it
helps improve the readability and understanding of the production rules.

Modifiability

The feature of modifiability helps alter the rules as per requirements. Initially,
the skeletal form of the production system is created. We then gather the
requirements and make changes in the raw structure of the production system.
This helps in the iterative improvement of the production system.

Knowledge-intensive

The knowledge is represented in plain English sentences.


Production rules help make productive conclusions from
these sentences.
Disadvantages of production system:

1. Opacity: This problem is generated by the combination of production rules.


The opacity is generated because of less prioritization of rules. More priority
to a rule has the less opacity.
2. Inefficiency: During execution of a program several rules may active. A
well devised control strategy reduces this problem. As the rules of the
production system are large in number and they are hardly written in
hierarchical manner, it requires some forms of complex search through all
the production rules for each cycle of control program.

3. Absence of learning: Rule based production systems do not store the result
of the problem for future use. Hence, it does not exhibit any type of learning
capabilities. So for each time for a particular problem, some new solutions
may come.

4. Conflict resolution: The rules in a production system should not have


any type of conflict operations. When a new rule is added to a database, it
should ensure that it does not have any conflicts with the existing rules.

Hill Climbing:
Hill climbing is a simple optimization algorithm used in Artificial Intelligence (AI)
to find the best possible solution for a given problem. It belongs to the family of
local search algorithms and is often used in optimization problems where the goal is
to find the best solution from a set of possible solutions.

Hill Climbing is a heuristic search used for mathematical optimization


problems in the field of Artificial Intelligence.
Given a large set of inputs and a good heuristic function, it tries to find a sufficiently
good solution to the problem. This solution may not be the global optimal
maximum.

Advantages of Hill Climbing algorithm:

1. Hill Climbing is a simple and intuitive algorithm that is easy to understand


and implement.
2. It can be used in a wide variety of optimization problems, including those
with a large search space and complex constraints.
3. Hill Climbing is often very efficient in finding local optima, making it a
good choice for problems where a good solution is needed quickly.
4. The algorithm can be easily modified and extended to include additional
heuristics or constraints.

Disadvantages of Hill Climbing algorithm:

1. Hill Climbing can get stuck in local optima, meaning that it may not find
the global optimum of the problem.
2. The algorithm is sensitive to the choice of initial solution, and a poor
initial solution may result in a poor final solution.
3. Hill Climbing does not explore the search space very thoroughly, which
can limit its ability to find better solutions.
4. It may be less effective than other optimization algorithms, such as genetic
algorithms or simulated annealing, for certain types of problems.

Features of Hill Climbing:

1. Variant of generating and test algorithm:


It is a variant of generating and testing algorithms. The generate and test algorithm is
as follows :
Generate possible solutions.
Test to see if this is the expected solution.
If the solution has been found quit else go to step 1.
Hence we call Hill climbing a variant of generating and test algorithm as it takes the
feedback from the test procedure. Then this feedback is utilized by the generator in
deciding the next move in the search space.
2. Uses the Greedy approach:
At any point in state space, the search moves in that direction only which optimizes the cost of function with the hope of
finding the optimal solution at the end.

Types of Hill Climbing Algorithm:


o Simple hill Climbing:
o Steepest-Ascent hill-climbing:
o Stochastic hill Climbing:

1. Simple Hill Climbing:


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:

o Less time consuming


o Less optimal solution and the solution is not guaranteed

Algorithm for Simple Hill Climbing:

o Step 1: Evaluate the initial state, if it is goal state then return success and
Stop.
o Step 2: Loop Until a solution is found or there is no new operator left to
apply.
o Step 3: Select and apply an operator to the current state.
o Step 4: Check new state:

1. If it is goal state, then return success and quit.

2. Else if it is better than the current state then assign new state as a
current state.

3. Else if not better than the current state, then return to step2.

o Step 5: Exit.

2. Steepest-Ascent hill climbing:


The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This
algorithm examines all the neighbouring nodes of the current state and selects one
neighbour node which is closest to the goal state. This algorithm consumes more
time as it searches for multiple neighbours

Algorithm for Steepest-Ascent hill climbing:

o Step 1: Evaluate the initial state, if it is goal state then return success and stop,
else make current state as initial state.
o Step 2: Loop until a solution is found or the current state does not change.
1. Let SUCC be a state such that any successor of the current state will be
better than it.

2. For each operator that applies to the current state:

I. Apply the new operator and generate a new state.

II. Evaluate the new state.

III. If it is goal state, then return it and quit, else compare it to the
SUCC.

IV. If it is better than SUCC, then set new state as SUCC.

V. If the SUCC is better than the current state, then set current state
to SUCC.

o Step 5: Exit.

3. Stochastic hill climbing:


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.

Uninformed Search Algorithms:


Uninformed search is a class of general-purpose search algorithms which
operates in brute force-way. Uninformed search algorithms do not have
additional information about state or search space other than how to traverse
the tree, so it is also called blind search.

1. Breadth-first Search
2. Depth-first Search

1. Breadth-first Search:
o Breadth-first search is the most common search strategy for traversing a tree
or graph. This algorithm searches breadthwise in a tree or graph, so it is called
breadth-first search.
o BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.
o The breadth-first search algorithm is an example of a general-graph search
algorithm.
o Breadth-first search implemented using FIFO queue data structure.

Advantages:

4.8M
504
Package BFS will provide a solution if any solution exists.

o If there are more than one solutions for a given problem, then BFS will provide
the minimal solution which requires the least number of steps.

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.

Example:
In the below tree structure, we have shown the traversing of the tree using BFS
algorithm from the root node S to goal node K. BFS search algorithm traverse in
layers, so it will follow the path which is shown by the dotted arrow, and the
traversed path will be:

1. S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K
Time Complexity: Time Complexity of BFS algorithm can be obtained by the
number of nodes traversed in BFS until the shallowest Node. Where the d= depth of
shallowest solution and b is a node at every state.

T (b) = 1+b2+b3+.......+ bd= O (bd)

pace Complexity: Space complexity of BFS algorithm is given by the Memory size of
frontier which is O(bd).

Completeness: BFS is complete, which means if the shallowest goal node is at some
finite depth, then BFS will find a solution.

Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of


the node.

2. Depth-first Search
o Depth-first search isa recursive algorithm for traversing a tree or graph data
structure.
o 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.
o DFS uses a stack data structure for its implementation.
o The process of the DFS algorithm is similar to the BFS algorithm.
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.

Example:
In the below search tree, we have shown the flow of depth-first search, and it will
follow the order as:

Root node--->Left node ----> right node.

It will start searching from root node S, and traverse A, then B, then D and E, after
traversing E, it will backtrack the tree as E has no other successor and still goal node
is not found. After backtracking it will traverse node C and then G, and here it will
terminate as it found goal node.
Completeness: DFS search algorithm is complete within finite state space as it will
expand every node within a limited search tree.

Time Complexity: Time complexity of DFS will be equivalent to the node traversed
by the algorithm. It is given by:

T(n)= 1+ n2+ n3 +.........+ nm=O(nm)

Where, m= maximum depth of any node and this can be much larger than d
(Shallowest solution depth)

Space Complexity: DFS algorithm needs to store only single path from the root
node, hence space complexity of DFS is equivalent to the size of the fringe set, which
is O(bm).

Optimal: DFS search algorithm is non-optimal, as it may generate a large number of


steps or high cost to reach to the goal node.

Best-first Search Algorithm :


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.
1. f(n)= g(n).

Were, h(n)= estimated cost from node n to the goal.

The greedy best first algorithm is implemented by the priority queue.

Best first search algorithm:

o Step 1: Place the starting node into the OPEN list.


o Step 2: If the OPEN list is empty, Stop and return failure.
o Step 3: Remove the node n, from the OPEN list which has the lowest value of
h(n), and places it in the CLOSED list.
o Step 4: Expand the node n, and generate the successors of node n.
o Step 5: Check each successor of node n, and find whether any node is a goal
node or not. If any successor node is goal node, then return success and
terminate the search, else proceed to Step 6.
o Step 6: For each successor node, algorithm checks for evaluation function f(n),
and then check if the node has been in either OPEN or CLOSED list. If the
node has not been in both list, then add it to the OPEN list.
o Step 7: Return to Step 2.

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.

Example:
Consider the below search problem, and we will traverse it using greedy best-first
search. At each iteration, each node is expanded using evaluation function f(n)=h(n) ,
which is given in the below table.
In this search example, we are using two lists which are OPEN and CLOSED Lists.
Following are the iteration for traversing the above example.

Expand the nodes of S and put in the CLOSED list

Initialization: Open [A, B], Closed [S]

Iteration 1: Open [A], Closed [S, B]

Iteration 2: Open [E, F, A], Closed [S, B]


: Open [E, A], Closed [S, B, F]

Iteration 3: Open [I, G, E, A], Closed [S, B, F]


: Open [I, E, A], Closed [S, B, F, G]

Hence the final solution path will be: S----> B----->F---->


Time Complexity: The worst case time complexity of Greedy best first search is
O(bm).

Space Complexity: The worst case space complexity of Greedy best first search is
O(bm). Where, m is the maximum depth of the search space.

Complete: Greedy best-first search is also incomplete, even if the given state space
is finite.

Optimal: Greedy best first search algorithm is not optimal.

AO* algorithm:

he Depth-first search and Breadth-first search given earlier for OR trees or graphs
can be easily adopted by AND-OR graph. The main difference lies in the way
termination conditions are determined since all goals following an AND node must
be realized; whereas a single goal node following an OR node will do. So for this
purpose, we are using AO* algorithm.

Like A* algorithm here we will use two arrays and one heuristic function.

OPEN: It contains the nodes that have been traversed but yet not been marked
solvable or unsolvable.
CLOSE: It contains the nodes that have already been processed.
h(n): The distance from the current node to the goal node.

AO* Search Algorithm


Step 1: Place the starting node into OPEN.

Step 2: Compute the most promising solution tree say T0.

Step 3: Select a node n that is both on OPEN and a member of T0. Remove it from
OPEN and place it in CLOSE

Step 4: If n is the terminal goal node then leveled n as solved and leveled all the
ancestors of n as solved. If the starting node is marked as solved then success and
exit.
Step 5: If n is not a solvable node, then mark n as unsolvable. If starting node is
marked as unsolvable, then return failure and exit.

Step 6: Expand n. Find all its successors and find their h (n) value, push them into O
tep 7: Return to Step 2.

Step 8: Exit.

Advantages of AO* Star


 It is an optimal algorithm.
 If traverse according to the ordering of nodes.
 It can be used for both OR and AND graph.

Disadvantages of AO* Star


 Sometimes for unsolvable nodes, it can’t find the optimal path.
 Its complexity is than other algorithms.
PEN

Difference between the A* Algorithm and AO* algorithm:

 A* algorithm and AO* algorithm both works on the best first search.
 They are both informed search and works on given heuristics values.
 A* always gives the optimal solution but AO* doesn’t guarantee to give the
optimal solution.
 Once AO* got a solution doesn’t explore all possible paths but A* explores all
paths.
 When compared to the A* algorithm, the AO* algorithm uses less memory.
 opposite to the A* algorithm, the AO* algorithm cannot go into an endless loop.
 ***************************
3) knowledge Representation

What is knowledge representation?


Humans are best at understanding, reasoning, and interpreting knowledge. Human
knows things, which is knowledge and as per their knowledge they perform various
actions in the real world. But how machines do all these things comes under
knowledge representation and reasoning.

Knowledge management:
What is knowledge management? Knowledge management (KM) is the process of
identifying, organizing, storing and disseminating information within an organization.

Types of knowledge:
1. Declarative Knowledge:

o Declarative knowledge is to know about something.


o It includes concepts, facts, and objects.
o It is also called descriptive knowledge and expressed in declarativesentences.
o It is simpler than procedural language.

2. Procedural Knowledge

o It is also known as imperative knowledge.


o Procedural knowledge is a type of knowledge which is responsible for
knowing how to do something.
o It can be directly applied to any task.
o It includes rules, strategies, procedures, agendas, etc.
o Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:

o Knowledge about the other types of knowledge is called Meta-knowledge.


4. Heuristic knowledge:

o Heuristic knowledge is representing knowledge of some experts in a filed or


subject.
o Heuristic knowledge is rules of thumb based on previous experiences,
awareness of approaches, and which are good to work but not guaranteed.

5. Structural knowledge:

o Structural knowledge is basic knowledge to problem-solving.


o It describes relationships between various concepts such as kind of, part of,
and grouping of something.
o It describes the relationship that exists between concepts or objects.

Knowledge representation-bases and


structure:
What is Knowledge Representation in AI?

Knowledge representation is a fundamental concept in artificial


intelligence (AI) that involves creating models and structures to represent
information and knowledge in a way that intelligent systems can use. The goal
of knowledge representation is to enable machines to reason about the world
like humans, by capturing and encoding knowledge in a format that can be
easily processed and utilized by AI systems.

There are various approaches to knowledge representation in AI, including:

 Logical representation: This involves representing knowledge in a symbolic


logic or rule-based system, which uses formal languages to express and infer
new knowledge.
 Semantic networks: This involves representing knowledge through nodes
and links, where nodes represent concepts or objects, and links represent
their relationships.
 Frames: This approach involves representing knowledge in the form of
structures called frames, which capture the properties and attributes of
objects or concepts and the relationships between them.
 Ontologies: This involves representing knowledge in the form of a
formal, explicit specification of the concepts, properties, and relationships
between them within a particular domain.
 Neural networks: This involves representing knowledge in the form of
patterns or connections between nodes in a network, which can be used to
learn and infer new knowledge from data.

What to Represent:
Following are the kind of knowledge which needs to be represented in AI systems:

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

Structure of knowledge representation:

There are mainly four ways of knowledge representation which are given as follows:
1. Logical Representation
2. Semantic Network Representation
3. Frame Representation
4. Production Rules

1. Logical Representation
Logical representation is a language with some concrete rules which deals with
propositions and has no ambiguity in representation. Logical representation means
drawing a conclusion based on various conditions. This representation lays down
some important communication rules. It consists of precisely defined syntax and
semantics which supports the sound inference. Each sentence can be translated into
logics using syntax and semantics.

2. Semantic Network Representation


Semantic networks are alternative of predicate logic for knowledge representation. In
Semantic networks, we can represent our knowledge in the form of graphical
networks. This network consists of nodes representing objects and arcs which
describe the relationship between those objects. Semantic networks can categorize
the object in different forms and can also link those objects. Semantic networks are
easy to understand and can be easily extended.

3. Frame Representation
A frame is a record like structure which consists of a collection of attributes and its
values to describe an entity in the world. Frames are the AI data structure which
divides knowledge into substructures by representing stereotypes situations. It
consists of a collection of slots and slot values. These slots may be of any type and
sizes. Slots have names and values which are called facets.

5. Production Rules
Production rules system consist of (condition, action) pairs which mean, "If
condition then action". It has mainly three parts:

o 1)The set of production rules 2) Working


Memory 3)the recognize-act-cycle
First-Order Logic :
In the topic of Propositional logic, we have seen that how to represent statements
using propositional logic. But unfortunately, in propositional logic, we can only
represent the facts, which are either true or false. PL is not sufficient to represent the
complex sentences or natural language statements. The propositional logic has very
limited expressive power. Consider the following sentence, which we cannot
represent using PL logic.

o "Some humans are intelligent", or


o "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some


more powerful logic, such as first-order logic.

First-Order logic:
o First-order logic is another way of knowledge representation in artificial
intelligence. It is an extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language statements in a
concise way.
o 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.
o 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, colours, 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 colour, comes
between
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:

o Syntax
o Semantics

Syntax of First-Order logic:


The syntax of FOL determines which collection of symbols is a logical expression in
first-order logic. The basic syntactic elements of first-order logic are symbols. We
write statements in short-hand notation in FOL.

Basic Elements of First-order logic:


Following are the basic elements of FOL syntax:

Constant 1, 2, A, John, Mumbai, cat,....

Variables x, y, z, a, b,....

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃

Atomic sentences:

o Atomic sentences are the most basic sentences of first-order logic. These
sentences are formed from a predicate symbol followed by a parenthesis with
a sequence of terms.
o We can represent atomic sentences as Predicate (term1, term2, ......, term
n).

Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).


Chinky is a cat: => cat (Chinky).

Complex Sentences:
o Complex sentences are made by combining atomic sentences using
connectives.

First-order logic statements can be divided into two parts:

o Subject: Subject is the main part of the statement.


o Predicate: A predicate can be defined as a relation, which binds two atoms
together in a statement.

Consider the statement: "x is an integer.", it consists of two parts, the first part x is
the subject of the statement and second part "is an integer," is known as a predicate.

Quantifiers in First-order logic:


o A quantifier is a language element which generates quantification, and
quantification specifies the quantity of specimen in the universe of discourse.
o These are the symbols that permit to determine or identify the range and
scope of the variable in the logical expression. There are two types of
quantifier:

1. Universal Quantifier, (for all, everyone, everything)

2. Existential quantifier, (for some, at least one).

Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the
statement within its range is true for everything or every instance of a particular
thing.

The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.

Note: In universal quantifier we use implication "→".


If x is a variable, then ∀x is read as:

o For all x
o For each x
o For every x.

Example:
All man drink coffee.

Let a variable x which refers to a cat so all x can be represented in UOD as below:

∀x man(x) → drink (x, coffee).

It will be read as: There are all x where x is a man who drink coffee.

Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement
within its scope is true for at least one instance of something.

It is denoted by the logical operator ∃, which resembles as inverted E. When it is used


with a predicate variable then it is called as an existential quantifier.

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).

If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
o There exists a 'x.'
o For some 'x.'
o For at least one 'x.'

Example:
Some boys are intelligent.

∃x: boys(x) ∧ intelligent(x)

It will be read as: There are some x where x is a boy who is intelligent.

Points to remember:
o The main connective for universal quantifier ∀ is implication →.
o The main connective for existential quantifier ∃ is and ∧.

Properties of Quantifiers:
o In universal quantifier, ∀x∀y is similar to ∀y∀x.
o In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o ∃x∀y is not similar to ∀y∃x.

Some Examples of FOL using quantifier:

1. All birds fly.


In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.

∀x bird(x) →fly(x).

2. Every man respects his parent.


In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent)

3. Some boys play cricket.


In this question, the predicate is "play(x, y)," where x= boys, and y= game.
Since there are some boys so we will use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).

4. Not all students like both Mathematics and Science.


In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following
representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].

5. Only one student failed in Mathematics.


In this question, the predicate is "failed(x, y)," where x= student, and y=
subject.
Since there is only one student who failed in Mathematics, so we will use
following representation for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧
student(y) → ¬failed (x, Mathematics)].

Free and Bound Variables:


The quantifiers interact with variables which appear in a suitable way. There are two
types of variables in First-order logic which are given below:

Free Variable: A variable is said to be a free variable in a formula if it occurs outside


the scope of the quantifier.

Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.


Bound Variable: A variable is said to be a bound variable in a formula if it occurs
within the scope of the quantifier.

Example: ∀x [A (x) B( y)], here x and y are the bound variables.

Unification Algorithm:
o Unification is a process of making two different logical atomic expressions
identical by finding a substitution. Unification depends on the substitution
process.
o It takes two literals as input and makes them identical using substitution.
o Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 =
Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
o Example: Find the MGU for Unify{King(x), King(John)}

Let Ψ1 = King(x), Ψ2 = King(John),

Substitution θ = {John/x} is a unifier for these atoms and applying this substitution,
and both expressions will be identical.

o The UNIFY algorithm is used for unification, which takes two atomic sentences
and returns a unifier for those sentences (If any exist).
o Unification is a key component of all first-order inference algorithms.
o It returns fail if the expressions do not match with each other.
o The substitution variables are called Most General Unifier or MGU.

E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).

In this example, we need to make both above statements identical to each other. For
this, we will perform the substitution.

P(x, y)......... (i)


P(a, f(z))......... (ii)

o Substitute x with a, and y with f(z) in the first expression, and it will be
represented as a/x and f(z)/y.
o With both the substitutions, the first expression will be identical to the second
expression and the substitution set will be: [a/x, f(z)/y].
Conditions for Unification:
Following are some basic conditions for unification:

o Predicate symbol must be same, atoms or expression with different predicate


symbol can never be unified.
o Number of Arguments in both expressions must be identical.
o Unification will fail if there are two similar variables present in the same
expression.

Unification Algorithm:
Algorithm: Unify(Ψ1, Ψ2)

Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:


a) If Ψ1 or Ψ2 are identical, then return NIL.
b) Else if Ψ1is a variable,
a. then if Ψ1 occurs in Ψ2, then return FAILURE
b. Else return { (Ψ2/ Ψ1)}.
c) Else if Ψ2 is a variable,
a. If Ψ2 occurs in Ψ1 then return FAILURE,
b. Else return {( Ψ1/ Ψ2)}.
d) Else return FAILURE.
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then
return FAILURE.
Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return
FAILURE.
Step. 4: Set Substitution set(SUBST) to NIL.
Step. 5: For i=1 to the number of elements in Ψ1.
a) Call Unify function with the ith element of Ψ1 and ith element of
Ψ2, and put the result into S.
b) If S = failure then returns Failure
c) If S ≠ NIL then do,
a. Apply S to the remainder of both L1 and L2.
b. SUBST= APPEND(S, SUBST).
Step.6: Return SUBST.

Implementation of the Algorithm


Step.1: Initialize the substitution set to be empty.

Step.2: Recursively unify atomic sentences:


a. Check for Identical expression match.

b. If one expression is a variable v i, and the other is a term t i which does not
contain variable vi, then:

a. Substitute ti / vi in the existing substitutions

b. Add ti /vi to the substitution setlist.

c. If both the expressions are functions, then function name must be


similar, and the number of arguments must be the same in both the
expression.
4.Find the MGU of UNIFY(prime (11), prime(y))

Here, Ψ1 = {prime(11) , and Ψ2 = prime(y)}


S0 => {prime(11) , prime(y)}
SUBST θ= {11/y}

S1 => {prime(11) , prime(11)} , Successfully unified.


Unifier: {11/y}.
Frames:
the tl;dr
A frame is a collection of data describing a particular aspect of the world, including objects,
events, and relations between them.

What is a frame in AI?


A frame is a data structure that represents a "snapshot" of the world
at a particular moment in time. It contains all of the information that
an AI system needs to know about the world in order to make
decisions.

Frames are used extensively in AI systems, especially in those that


use artificial neural networks. This is because they provide a way to
store and manipulate information in a way that is similar to how the
human brain does it.

Frames are also used in other AI paradigms, such as rule-based


systems and decision trees. However, they are not as widely used
in these paradigms as they are in neural networks.

What are the benefits of using frames


in AI?
There are many benefits to using frames in AI. Frames provide a
structure for representing knowledge that can be used by AI
systems to reason about the world. They can also be used to store
and retrieve information from memory, and to make inferences
about new situations. Frames can also be used to represent plans
and goals, and to generate new actions.

What are some common frame types in


AI?
There are many different types of AI frames, but some of the most
common are:
1. The rule-based system: This type of AI uses a set of rules to
determine how to act in a given situation.

2. The decision tree: This type of AI uses a tree-like structure to


make decisions.

3. The neural network: This type of AI uses a network of


interconnected nodes to make decisions.

4. The genetic algorithm: This type of AI uses a process of evolution


to find solutions to problems.

5. The fuzzy logic system: This type of AI uses a set of rules that
are not precise to make decisions.

How are frames used in AI


applications?
Frames are used in AI applications to represent knowledge in a way
that is easy for computers to process. Frames are used to store
information about objects, events, and relationships. This
information can be used to reasoning and make decisions

Conceptual Dependency (CD)


Conceptual Dependency originally developed to represent knowledge acquired
from natural language input.

The goals of this theory are:

 To help in the drawing of inference from sentences.


 To be independent of the words used in the original input.
 That is to say: For any 2 (or more) sentences that are identical in meaning
there should be only one representation of that meaning.

It has been used by many programs that portend to understand English (MARGIE,
SAM, PAM). CD developed by Schank et al. as were the previous examples.

CD provides:
 a structure into which nodes representing information can be placed
 a specific set of primitives
 at a given level of granularity.

Sentences are represented as a series of diagrams depicting actions using both


abstract and real physical situations.

 The agent and the objects are represented


 The actions are built up from a set of primitive acts which can be modified
by tense.

Examples of Primitive Acts are:

ATRANS
-- Transfer of an abstract relationship. e.g. give.
PTRANS
-- Transfer of the physical location of an object. e.g. go.
PROPEL
-- Application of a physical force to an object. e.g. push.
MTRANS
-- Transfer of mental information. e.g. tell.
MBUILD
-- Construct new information from old. e.g. decide.
SPEAK
-- Utter a sound. e.g. say.
ATTEND
-- Focus a sense on a stimulus. e.g. listen, watch.
MOVE
-- Movement of a body part by owner. e.g. punch, kick.
GRASP
-- Actor grasping an object. e.g. clutch.
INGEST
-- Actor ingesting an object. e.g. eat.
EXPEL
-- Actor getting rid of an object from body. e.g. ????.

Six primitive conceptual categories provide building blocks which are the set of
allowable dependencies in the concepts in a sentence:

PP
-- Real world objects.
ACT
-- Real world actions.
PA
-- Attributes of objects.
AA
-- Attributes of actions.
T
-- Times.
LOC
-- Locations.

How do we connect these things together?

Consider the example:

John gives Mary a book

 Arrows indicate the direction of dependency. Letters above indicate certain


relationships:

o
-- object.
R
-- recipient-donor.
I
-- instrument e.g. eat with a spoon.
D
-- destination e.g. going home.

 Double arrows ( ) indicate two-way links between the actor (PP) and action
(ACT).
 The actions are built from the set of primitive acts (see above).
o These can be modified by tense etc.

The use of tense and mood in describing events is extremely


important and schank introduced the following modifiers:

p
-- past
f
-- future
t
-- transition
-- start transition

-- finished transition
k
-- continuing
?
-- interrogative
/
-- negative
delta
-- timeless
c
-- conditional
the absence of any modifier implies the present tense.

So the past tense of the above example:

John gave Mary a book becomes:

The has an object (actor), PP and action, ACT. I.e. PP ACT. The triplearrow (
) is also a two link but between an object, PP, and its attribute, PA. I.e. PP
PA.

It represents isa type dependencies. E.g

Dave lecturerDave is a lecturer.

Primitive states are used to describe many state descriptions such as height, health,
mental state, physical state.

There are many more physical states than primitive actions. They use a numeric
scale.

E.g. John height(+10) John is the tallest John height(< average) John is
short Frank Zappa health(-10) Frank Zappa is dead Dave mental_state(-
10) Dave is sad Vase physical_state(-10) The vase is broken

You can also specify things like the time of occurrence in the relation ship.
For Example: John gave Mary the book yesterday

Now let us consider a more complex sentence: Since smoking can kill you, I
stopped Lets look at how we represent the inference that smoking can kill:

 Use the notion of one to apply the knowledge to.


 Use the primitive act of INGESTing smoke from a cigarette to one.
 Killing is a transition from being alive to dead. We use triple arrows to
indicate a transition from one state to another.
 Have a conditional, c causality link. The triple arrow indicates dependency
of one concept on another.

To add the fact that I stopped smoking

 Use similar rules to imply that I smoke cigarettes.


 The qualification attached to this dependency indicates that the instance
INGESTing smoke has stopped.
Advantages of CD:

 Using these primitives involves fewer inference rules.


 Many inference rules are already represented in CD structure.
 The holes in the initial structure help to focus on the points still to be
established.

Disadvantages of CD:

 Knowledge must be decomposed into fairly low level primitives.


 Impossible or difficult to find correct set of primitives.
 A lot of inference may still be required.
 Representations can be complex even for relatively simple actions.
Consider:

Dave bet Frank five pounds that Wales would win the Rugby World Cup.

Complex representations require a lot of storage

Applications of CD:

MARGIE
(Meaning Analysis, Response Generation and Inference on English) --
model natural language understanding.
SAM
(Script Applier Mechanism) -- Scripts to understand stories. See next
section.
PAM
(Plan Applier Mechanism) -- Scripts to understand stories.

Schank et al. developed all of the above.

Scripts
A script is a structured representation describing a stereotyped sequence of events in a particular
context.
Scripts are used in natural language understanding systems to organize a knowledge base in terms
of the situations that the system should understand. Scripts use a frame-like structure to represent
the commonly occurring experience like going to the movies eating in a restaurant, shopping in a
supermarket, or visiting an ophthalmologist.
Thus, a script is a structure that prescribes a set of circumstances that could be expected to follow
on from one another.
Scripts are beneficial because:
 Events tend to occur in known runs or patterns.
 A
 to take place.
 Prerequisites exist upon events taking place.

Components of a script
The components of a script include:
 Entry condition: These are basic condition which must be fulfilled before events in the
script can occur.
 Results: Condition that will be true after events in script occurred.
 Props: Slots representing objects involved in events
 Roles: These are the actions that the individual participants perform.
 Track: Variations on the script. Different tracks may share components of the same
scripts.
 Scenes: The sequence of events that occur.
Describing a script, special symbols of actions are used. These are:
Symbol Meaning Example
ATRANS transfer a relationship give
transfer physical location of an
PTRANS go
object
PROPEL apply physical force to an object push
MOVE move body part by owner kick
GRASP grab an object by an actor hold
INGEST taking an object by an animal eat drink
EXPEL expel from animal’s body cry
MTRANS transfer mental information tell
MBUILD mentally make new information decide
conceptualize or think about an
CONC think
idea
SPEAK produce sound say
ATTEND focus sense organ listen
Example:-Script for going to the bank to withdraw money.
SCRIPT : Withdraw money
TRACK : Bank
PROPS : Money
Counter
Form
Token
Roles : P= Customer
E= Employee
C= Cashier
Entry conditions: P has no or less money.
The bank is open.
Results : P has more money.
Scene 1: Entering
P PTRANS P into the Bank
P ATTEND eyes to E
P MOVE P to E
Scene 2: Filling form
P MTRANS signal to E
E ATRANS form to P
P PROPEL form for writing
P ATRANS form to P
E ATRANS form to P
Scene 3: Withdrawing money
P ATTEND eyes to counter
P PTRANS P to queue at the counter
P PTRANS token to C
C ATRANS money to P
Scene 4: Exiting the bank
P PTRANS P to out of bank

Less general than frames.

M semantic network:
the tl;dr
A semantic network is a graphical representation of how words are related to each other.

What is a semantic network?


In artificial intelligence, a semantic network is a knowledge
representation technique for organizing and storing knowledge.
Semantic networks are a type of graphical model that shows the
relationships between concepts, ideas, and objects in a way that is
easy for humans to understand. The nodes in a semantic network
are concepts, and the edges between nodes represent the
relationships between those concepts. Semantic networks are used
to represent both simple and complex knowledge structures.

What are the benefits of using a


semantic network?
A semantic network is a graphical representation of relationships
between concepts, ideas, or objects. It can be used to represent
knowledge in many different domains, including AI.

There are many benefits to using a semantic network in AI. First, it


can help to organize and structure knowledge in a way that is easy
for machines to understand. Second, it can provide a way to
represent complex relationships between concepts in a way that is
easy for humans to understand. Finally, it can help to improve the
performance of AI systems by providing a way to represent
knowledge in a more efficient way.

How can a semantic network be used


to represent knowledge?
A semantic network is a graphical representation of relationships
between concepts. It can be used to represent knowledge in AI by
mapping out the relationships between different concepts and
ideas. This can help AI systems to better understand and reason
about complex problems. Semantic networks can also be used to
visualize data and knowledge, which can be helpful for human
users of AI systems.

How can a semantic network be used


to reasoning?
A semantic network is a graphical representation of relationships
between concepts. It can be used to reason about those concepts
by looking at the connections between them. For example, if you
wanted to know whether a particular animal was a mammal, you
could consult a semantic network to see if it was connected to the
concept of mammals. If it was, then you could reasonably conclude
that the animal was a mammal.

What are some of the challenges


associated with using semantic
networks?
There are a few challenges associated with using semantic
networks in AI. One challenge is that they can be difficult to create.
Another challenge is that they can be difficult to interpret.
Additionally, they can be computationally expensive.

 ay not be suitable to represent all kinds of knowledge


**************************

4) Reasoning
What is Reasoning:
The reasoning is the mental process of deriving logical conclusion and making
predictions from available knowledge, facts, and beliefs. Or we can say, "Reasoning
is a way to infer facts from existing data." It is a general process of thinking
rationally, to find valid conclusions.

In artificial intelligence, the reasoning is essential so that the machine can also think
rationally as a human brain, and can perform like a human.

Types of Reasoning
In artificial intelligence, reasoning can be divided into the following categories:

Backward Skip 10sPlay VideoForward Skip 10s

o Deductive reasoning
o Inductive reasoning
o Abductive reasoning
o Common Sense Reasoning
o Monotonic Reasoning
o Non-monotonic Reasoning

Note: Inductive and deductive reasoning are the forms of propositional logic.
1. Deductive reasoning:
Deductive reasoning is deducing new information from logically related known
information. It is the form of valid reasoning, which means the argument's conclusion
must be true when the premises are true.

Deductive reasoning is a type of propositional logic in AI, and it requires various rules
and facts. It is sometimes referred to as top-down reasoning, and contradictory to
inductive reasoning.

In deductive reasoning, the truth of the premises guarantees the truth of the
conclusion.

Deductive reasoning mostly starts from the general premises to the specific
conclusion, which can be explained as below example.

Example:

Premise-1: All the human eats veggies

Premise-2: Suresh is human.

Conclusion: Suresh eats veggies.

The general process of deductive reasoning is given below:

2. Inductive Reasoning:
Inductive reasoning is a form of reasoning to arrive at a conclusion using limited sets
of facts by the process of generalization. It starts with the series of specific facts or
data and reaches to a general statement or conclusion.

Inductive reasoning is a type of propositional logic, which is also known as cause-


effect reasoning or bottom-up reasoning.

In inductive reasoning, we use historical data or various premises to generate a


generic rule, for which premises support the conclusion.
In inductive reasoning, premises provide probable supports to the conclusion, so the
truth of premises does not guarantee the truth of the conclusion.

Example:

Premise: All of the pigeons we have seen in the zoo are white.

Conclusion: Therefore, we can expect all the pigeons to be white.

3. Abductive reasoning:
Abductive reasoning is a form of logical reasoning which starts with single or
multiple observations then seeks to find the most likely explanation or conclusion for
the observation.

Abductive reasoning is an extension of deductive reasoning, but in abductive


reasoning, the premises do not guarantee the conclusion.

Example:

Implication: Cricket ground is wet if it is raining

Axiom: Cricket ground is wet.

Conclusion It is raining.

4. Common Sense Reasoning


Common sense reasoning is an informal form of reasoning, which can be gained
through experiences.

Common Sense reasoning simulates the human ability to make presumptions about
events which occurs on every day.

It relies on good judgment rather than exact logic and operates on heuristic
knowledge and heuristic rules.

Example:
1. One person can be at one place at a time.
2. If I put my hand in a fire, then it will burn.

The above two statements are the examples of common sense reasoning which a
human mind can easily understand and assume.

5. Monotonic Reasoning:
In monotonic reasoning, once the conclusion is taken, then it will remain the same
even if we add some other information to existing information in our knowledge
base. In monotonic reasoning, adding knowledge does not decrease the set of
prepositions that can be derived.

To solve monotonic problems, we can derive the valid conclusion from the available
facts only, and it will not be affected by new facts.

Monotonic reasoning is not useful for the real-time systems, as in real time, facts get
changed, so we cannot use monotonic reasoning.

Monotonic reasoning is used in conventional reasoning systems, and a logic-based


system is monotonic.

Any theorem proving is an example of monotonic reasoning.

Example:

o Earth revolves around the Sun.

It is a true fact, and it cannot be changed even if we add another sentence in


knowledge base like, "The moon revolves around the earth" Or "Earth is not round,"
etc.

Advantages of Monotonic Reasoning:

o In monotonic reasoning, each old proof will always remain valid.


o If we deduce some facts from available facts, then it will remain valid for
always.

Disadvantages of Monotonic Reasoning:

o We cannot represent the real world scenarios using Monotonic reasoning.


o Hypothesis knowledge cannot be expressed with monotonic reasoning, which
means facts should be true.
o Since we can only derive conclusions from the old proofs, so new knowledge
from the real world cannot be added.

Non-monotonic Reasoning:
In Non-monotonic reasoning, some conclusions may be invalidated if we add some
more information to our knowledge base.

Logic will be said as non-monotonic if some conclusions can be invalidated by


adding more knowledge into our knowledge base.

Non-monotonic reasoning deals with incomplete and uncertain models.

"Human perceptions for various things in daily life, "is a general example of non-
monotonic reasoning.

Example: Let suppose the knowledge base contains the following knowledge:

o Birds can fly


o Penguins cannot fly
o Pitty is a bird

So from the above sentences, we can conclude that Pitty can fly.

However, if we add one another sentence into knowledge base "Pitty is a penguin",
which concludes "Pitty cannot fly", so it invalidates the above conclusion.

Advantages of Non-monotonic reasoning:

o For real-world systems such as Robot navigation, we can use non-monotonic


reasoning.
o In Non-monotonic reasoning, we can choose probabilistic facts or can make
assumptions.

Disadvantages of Non-monotonic Reasoning:

o In non-monotonic reasoning, the old facts may be invalidated by adding new


sentences.
o It cannot be used for theorem proving.
Fuzzy Logic:

Fuzzy Logic is a form of many-valued logic in which the truth values of


variables may be any real number between 0 and 1, instead of just the
traditional values of true or false. It is used to deal with imprecise or uncertain
information and is a mathematical method for representing vagueness and
uncertainty in decision-making Fuzzy Logic is used in a wide range of
applications, such as control systems, image processing, natural language
processing, medical diagnosis, and artificial intelligence.

ARCHITECTURE
Its Architecture contains four parts :
 RULE BASE: It contains the set of rules and the IF-THEN conditions
provided by the experts to govern the decision-making system, on the
basis of linguistic information. Recent developments in fuzzy theory offer
several effective methods for the design and tuning of fuzzy controllers.
Most of these developments reduce the number of fuzzy rules.
 FUZZIFICATION: It is used to convert inputs i.e. crisp numbers into
fuzzy sets. Crisp inputs are basically the exact inputs measured by sensors
and passed into the control system for processing, such as temperature,
pressure, rpm’s, etc.
 INFERENCE ENGINE: It determines the matching degree of the current
fuzzy input with respect to each rule and decides which rules are to be
fired according to the input field. Next, the fired rules are combined to
form the control actions.
 DEFUZZIFICATION: It is used to convert the fuzzy sets obtained by the
inference engine into a crisp value. There are several defuzzification
methods available and the best-suited one is used with a specific expert
system to reduce the error.
Definition: A graph that defines how each point in the input space is mapped to
membership value between 0 and 1. Input space is often referred to as the universe
of discourse or universal set (u), which contains all the possible elements of concern
in each particular application.
There are largely three types of fuzzifiers:
 Singleton fuzzifier
 Gaussian fuzzifier
 Trapezoidal or triangular fuzzifier
What is Fuzzy Control?
 It is a technique to embody human-like thinkings into a control system.
 It may not be designed to give accurate reasoning but it is designed to give
acceptable reasoning.
 It can emulate human deductive thinking, that is, the process people use to
infer conclusions from what they know.
 Any uncertainties can be easily dealt with the help of fuzzy logic.
Advantages of Fuzzy Logic System
 This system can work with any type of inputs whether it is imprecise,
distorted or noisy input information.
 The construction of Fuzzy Logic Systems is easy and understandable.
 Fuzzy logic comes with mathematical concepts of set theory and the
reasoning of that is quite simple.
 It provides a very efficient solution to complex problems in all fields of
life as it resembles human reasoning and decision-making.
 The algorithms can be described with little data, so little memory is
required.
Disadvantages of Fuzzy Logic Systems
 Many researchers proposed different ways to solve a given problem
through fuzzy logic which leads to ambiguity. There is no systematic
approach to solve a given problem through fuzzy logic.
 Proof of its characteristics is difficult or impossible in most cases because
every time we do not get a mathematical description of our approach.
 As fuzzy logic works on precise as well as imprecise data so most of the
time accuracy is compromised.
Application
 It is used in the aerospace field for altitude control of spacecraft and
satellites.
 It has been used in the automotive system for speed control, traffic
control.
 It is used for decision-making support systems and personal evaluation in
the large company business.
 It has application in the chemical industry for controlling the pH, drying,
chemical distillation process.
 Fuzzy logic is used in Natural language processing and various intensive
applications in Artificial Intelligence.
 Fuzzy logic is extensively used in modern control systems such as expert
systems.
 Fuzzy Logic is used with Neural Networks as it mimics how a person
would make decisions, only much faster. It is done by Aggregation of data
and changing it into more meaningful data by forming partial truths as
Fuzzy sets.

Bayes' Rule:
Bayes' Rule is the most important rule in data science. It is the
mathematical rule that describes how to update a belief, given some
evidence. In other words – it describes the act of learning.

The equation itself is not too complex:

The equation: Posterior = Prior x (Likelihood over Marginal probability)


There are four parts:

 Posterior probability (updated probability after the evidence


is considered)
 Prior probability (the probability before the evidence is
considered)
 Likelihood (probability of the evidence, given the belief is
true)
 Marginal probability (probability of the evidence, under any
circumstance)
Bayes' Rule can answer a variety of probability questions, which
help us (and machines) understand the complex world we live in.

It is named after Thomas Bayes, an 18th century English theologian


and mathematician. Bayes originally wrote about the concept, but it
did not receive much attention during his lifetime.

French mathematician Pierre-Simon Laplace independently


published the rule in his 1814 work Essai philosophique sur les
probabilités.
Today, Bayes' Rule has numerous applications, from statistical
analysis to machine learning.

This article will explain Bayes' Rule in plain language.

Conditional probability
The first concept to understand is conditional probability.
You may already be familiar with probability in general. It lets you
reason about uncertain events with the precision and rigour of
mathematics.
Conditional probability is the bridge that lets you talk about how
multiple uncertain events are related. It lets you talk about how the
probability of an event can vary under different conditions.

For example, consider the probability of winning a race, given the


condition you didn't sleep the night before. You might expect this
probability to be lower than the probability you'd win if you'd had a
full night's sleep.
Or, consider the probability that a suspect committed a crime, given
that their fingerprints are found at the scene. You'd expect the
probability they are guilty to be greater, compared with had their
fingerprints not been found.

The notation for conditional probability is usually:

P(A|B)
Which is read as "the probability of event A occurring, given event
B occurs".

An important thing to remember is that conditional probabilities


are not the same as their inverses.
That is, the "probability of event A given event B" is not the same
thing as the "probability of event B, given event A".

To remember this, take the following example:

The probability of clouds, given it is raining (100%) is not the same


as the probability it is raining, given there are clouds.
(Insert joke about British weather).
Bayes' Rule in detail
Bayes' Rule tells you how to calculate a conditional probability with
information you already have.

It is helpful to think in terms of two events – a hypothesis (which


can be true or false) and evidence (which can be present or absent).

However, it can be applied to any type of events, with any number


of discrete or continuous outcomes.

Bayes' Rule lets you calculate the posterior (or "updated")


probability. This is a conditional probability. It is the probability of
the hypothesis being true, if the evidence is present.
Think of the prior (or "previous") probability as your belief in
the hypothesis before seeing the new evidence. If you had a strong
belief in the hypothesis already, the prior probability will be large.
The prior is multiplied by a fraction. Think of this as the "strength"
of the evidence. The posterior probability is greater when the top
part (numerator) is big, and the bottom part (denominator) is small.

The numerator is the likelihood. This is another conditional


probability. It is the probability of the evidence being present, given
the hypothesis is true.
This is not the same as the posterior!

Remember, the "probability of the evidence being present given the


hypothesis is true" is not the same as the "probability of the
hypothesis being true given the evidence is present".

Now look at the denominator. This is the marginal probability of


the evidence. That is, it is the probability of the evidence being
present, whether the hypothesis is true or false. The smaller the
denominator, the more "convincing" the evidence.
Worked example of Bayes' Rule
Here's a simple worked example.

Your neighbour is watching their favourite football (or soccer)


team. You hear them cheering, and want to estimate the probability
their team has scored.

Step 1 – write down the posterior probability of a goal, given


cheering
Step 2 – estimate the prior probability of a goal as 2%
Step 3 – estimate the likelihood probability of cheering, given
there's a goal as 90% (perhaps your neighbour won't celebrate if
their team is losing badly)
Step 4 – estimate the marginal probability of cheering – this could
be because:
 a goal has been scored (2% of the time, times 90%
probability)
 or any other reason, such as the other team missing a penalty
or having a player sent off (98% of the time, times perhaps 1%
probability)
Now, piece everything together:

Use cases for Bayes' Rule and next steps


Bayes' Rule has use cases in many areas:

 Understanding probability problems (including those in


medical research)
 Statistical modelling and inference
 Machine learning algorithms (such as Naive Bayes,
Expectation Maximisation)
 Quantitative modelling and forecasting
Next, you'll discover how Bayes' Rule can be used to quantify
uncertainty and model real world problems. Then, how to reason
about "probabilities of probabilities".

The final step will cover how various computational tricks let you
make use of Bayes' Rule to solve non-trivial problems.

Bayesian networks:
A Bayesian network is a type of graphical model that uses probability to determine
the occurrence of an event. It is also known as a belief network or a causal network.
It consists of directed cyclic graphs (DCGs) and a table of conditional probabilities to
find out the probability of an event happening. It contains nodes and edges, where
edges connect the nodes. The graph is acyclic - meaning there is no direct path
where one node can reach another. The table of probability, on the other hand,
shows the likelihood that a random variable will take on certain values.
The above image illustrates a directed acyclic graph. There are five nodes, namely,
a, b, c, d, and e. From the above graph, we can get the following information:

1. Node a is the parent of node b, c, and e, and node b, c, and e are the child nodes of
node a.
2. Node b and c are the parent nodes of d.
3. Node e is the child node of nodes d, c, and a.

It is important to note the relationships between the nodes. Bayesian networks fall
under probabilistic graphical techniques; hence, probability plays a crucial role in
defining the relationship among these nodes.

There are two types of probabilities that you need to be fully aware of in Bayesian
networks:

1. Joint probability

Joint probability is a probability of two or more events happening together. For


example, the joint probability of two events A and B is the probability that both events
occur, P(A∩B).

2. Conditional probability

Conditional probability defines the probability that event B will occur, given that event
A has already occurred. There are two ways joint probability can be represented:

The conditional probability distribution of each node is represented by a table called


the "node table". It contains two columns, one for each possible state of the parent
node (or "parent random variable") and one for each possible state of the child node
(or "child random variable").
The rows in this table correspond to all possible combinations of parent and child
states. In order to find out how likely it is that a certain event will happen, we need to
sum up the probabilities from all paths of that event.

Links act as causal dependencies that define the relationship between the nodes.
Both Chris and Martin call when there is an alarm.

Let’s write the probability distribution function formula for the above five nodes.

Now, let's look at the observed values for each of the nodes with the table of
probabilities:

Node B:

Node E:

Node A:
Node C:

Node M:

Based on the above observed values, the conditional values can be derived and,
therefore, the probability distribution can be calculated.

Conditional values for the above nodes are:

Node A:

Node C:
Node M:

What is the probability of both Chris and Martin calling, but neither a burglary nor an
earthquake has occurred?

To calculate the joint distribution, we use the formula:

“P[B,E,A,C,M] = P[C | A] P[M | A] P[A | B, E] P[B | E] P[E]”


Applications of Bayesian networks in AI:
1. Spam filtering: A spam filter is a program that helps in detecting unsolicited and
spam mails. Bayesian spam filters check whether a mail is spam or not. They use
filtering to learn from spam and ham messages.
2. Biomonitoring: This involves the use of indicators to quantify the concentration of
chemicals in the human body. Blood or urine is used to measure the same.
3. Information retrieval: Bayesian networks assist in information retrieval for
research, which is a constant process of extracting information from databases. It
works in a loop. Hence, we have to continuously reconsider and redefine our
research problem to avoid data overload.
4. Image processing: A form of signal processing, image processing uses
mathematical operations to convert images into digital format. Once images are
converted, their quality can be enhanced with more operations. The input image
doesn’t necessarily have to be in the form of an image; it could be a photograph or a
video frame.
5. Gene regulatory network: A Bayesian network is an algorithm that can be applied
to gene regulatory networks in order to make predictions about the effects of genetic
variations on cellular phenotypes. Gene regulatory networks are a set of
mathematical equations that describe the interactions between genes, proteins, and
metabolites. They are used to study how genetic variations affect the development of
a cell or organism.

6. Turbo code: Turbo codes are a type of error correction code capable of achieving
very high data rates and long distances between error correcting nodes in a
communications system.
***************************

5) Game Playing and Planning

Mini-Max Algorithm:
o Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-making and game

theory. It provides an optimal move for the player assuming that opponent is also playing optimally.

o Mini-Max algorithm uses recursion to search through the game-tree.

o Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers, tic-tac-toe, go, and

various tow-players game. This Algorithm computes the minimax decision for the current state.

o In this algorithm two players play the game, one is called MAX and other is called MIN.

o Both the players fight it as the opponent player gets the minimum benefit while they get the maximum

benefit.

o Both Players of the game are opponent of each other, where MAX will select the maximized value and

MIN will select the minimized value.


o The minimax algorithm performs a depth-first search algorithm for the exploration of the complete

game tree.

o The minimax algorithm proceeds all the way down to the terminal node of the tree, then backtrack the

tree as the recursion.

Pseudo-code for Min Max Algorithm:

Working of Min-Max Algorithm:


o The working of the minimax algorithm can be easily described using an
example. Below we have taken an example of game-tree which is representing
the two-player game.
o In this example, there are two players one is called Maximizer and other is
called Minimizer.
o Maximizer will try to get the Maximum possible score, and Minimizer will try
to get the minimum possible score.
o This algorithm applies DFS, so in this game-tree, we have to go all the way
through the leaves to reach the terminal nodes.
o At the terminal node, the terminal values are given so we will compare those
value and backtrack the tree until the initial state occurs. Following are the
main steps involved in solving the two-player game tree:

Step-1: In the first step, the algorithm generates the entire game-tree and apply the
utility function to get the utility values for the terminal states. In the below tree
diagram, let's take A is the initial state of the tree. Suppose maximizer takes first turn
which has worst-case initial value =- infinity, and minimizer will take next turn which
has worst-case initial value = +infinity.

Step 2: Now, first we find the utilities value for the Maximizer, its initial value is -∞,
so we will compare each value in terminal state with initial value of Maximizer and
determines the higher nodes values. It will find the maximum among the all.

For node D max(-1,- -∞) => max(-1,4)= 4

o For Node E max(2, -∞) => max(2, 6)= 6


o For Node F max(-3, -∞) => max(-3,-5) = -3
o For node G max(0, -∞) = max(0, 7) = 7
Step 3: In the next step, it's a turn for minimizer, so it will compare all nodes value
with +∞, and will find the 3rd layer node values.

o For node B= min(4,6) = 4


o For node C= min (-3, 7) = -3

Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all
nodes value and find the maximum value for the root node. In this game tree, there
are only 4 layers, hence we reach immediately to the root node, but in real games,
there will be more than 4 layers.

o For node A max(4, -3)= 4

That was the complete workflow of the minimax two player game.

Properties of Mini-Max algorithm:


o Complete- Min-Max algorithm is Complete. It will definitely find a solution (if exist),
in the finite search tree.
o Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.
o Time complexity- As it performs DFS for the game-tree, so the time complexity of
Min-Max algorithm is O(bm), where b is branching factor of the game-tree, and m is
the maximum depth of the tree.
o Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS
which is O(bm).
Limitation of the minimax Algorithm:
The main drawback of the minimax algorithm is that it gets
really slow for complex games such as Chess, go, etc. This type
of games has a huge branching factor, and the player has lots of
choices to decide. This limitation of the minimax algorithm can
be improved from which we have discussed in the next topic.
Alpha-Beta Algorithm:

o Alpha-beta pruning is a modified version of the minimax algorithm. It is an


optimization technique for the minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game
states it has to examine are exponential in depth of the tree. Since we cannot
eliminate the exponent, but we can cut it to half. Hence there is a technique
by which without checking each node of the game tree we can compute the
correct minimax decision, and this technique is called pruning. This involves
two threshold parameter Alpha and beta for future expansion, so it is
called alpha-beta pruning. It is also called as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it
not only prune the tree leaves but also entire sub-tree.
o The two-parameter can be defined as:

1. Alpha: The best (highest-value) choice we have found so far at any


point along the path of Maximizer. The initial value of alpha is -∞.

2. Beta: The best (lowest-value) choice we have found so far at any point
along the path of Minimizer. The initial value of beta is +∞.

o The Alpha-beta pruning to a standard minimax algorithm returns the same


move as the standard algorithm does, but it removes all the nodes which are
not really affecting the final decision but making algorithm slow. Hence by
pruning these nodes, it makes the algorithm fast.

Note: To better understand this topic, kindly study the minimax algorithm.

Condition for Alpha-beta pruning:


The main condition which required for alpha-beta pruning is:

1. α>=β

Key points about alpha-beta pruning:


o The Max player will only update the value of alpha.
o The Min player will only update the value of beta.
o While backtracking the tree, the node values will be passed to upper nodes
instead of values of alpha and beta.
o We will only pass the alpha, beta values to the child nodes.

Pseudo-code for Alpha-beta Pruning:


1. function minimax(node, depth, alpha, beta, maximizingPlayer) is
2. if depth ==0 or node is a terminal node then
3. return static evaluation of node
4.
5. if MaximizingPlayer then // for Maximizer Player
6. maxEva= -infinity
7. for each child of node do
8. eva= minimax(child, depth-1, alpha, beta, False)
9. maxEva= max(maxEva, eva)
10. alpha= max(alpha, maxEva)
11. if beta<=alpha
12. break
13. return maxEva
14.
15. else // for Minimizer player
16. minEva= +infinity
17. for each child of node do
18. eva= minimax(child, depth-1, alpha, beta, true)
19. minEva= min(minEva, eva)
20. beta= min(beta, eva)
21. if beta<=alpha
22. break
23. return minEva
Working of Alpha-Beta Pruning:
Let's take an example of two-player search tree to understand the working of Alpha-
beta pruning

Step 1: At the first step the, Max player will start first move from node A where α= -
∞ and β= +∞, these value of alpha and beta passed down to node B where again α=
-∞ and β= +∞, and Node B passes the same value to its child D.

Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α
is compared with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at
node D and node value will also 3.

Step 3: Now algorithm backtrack to node B, where the value of β will change as this
is a turn of Min, Now β= +∞, will compare with the available subsequent nodes
value, i.e. min (∞, 3) = 3, hence at node B now α= -∞, and β= 3.
In the next step, algorithm traverse the next successor of Node B which is node E,
and the values of α= -∞, and β= 3 will also be passed.

Step 4: At node E, Max will take its turn, and the value of alpha will change. The
current value of alpha will be compared with 5, so max (-∞, 5) = 5, hence at node E
α= 5 and β= 3, where α>=β, so the right successor of E will be pruned, and
algorithm will not traverse it, and the value at node E will be 5.

Step 5: At next step, algorithm again backtrack the tree, from node B to node A. At
node A, the value of alpha will be changed the maximum available value is 3 as max
(-∞, 3)= 3, and β= +∞, these two values now passes to right successor of A which is
Node C.

At node C, α=3 and β= +∞, and the same values will be passed on to node F.

Step 6: At node F, again the value of α will be compared with left child which is 0,
and max(3,0)= 3, and then compared with right child which is 1, and max(3,1)= 3 still
α remains 3, but the node value of F will become 1.
Step 7: Node F returns the node value 1 to node C, at C α= 3 and β= +∞, here the
value of beta will be changed, it will compare with 1 so min (∞, 1) = 1. Now at C, α=3
and β= 1, and again it satisfies the condition α>=β, so the next child of C which is G
will be pruned, and the algorithm will not compute the entire sub-tree G.

Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3.
Following is the final game tree which is the showing the nodes which are computed
and nodes which has never computed. Hence the optimal value for the maximizer is
3 for this example.

Move Ordering in Alpha-Beta pruning:


The effectiveness of alpha-beta pruning is highly dependent on the order in which
each node is examined. Move order is an important aspect of alpha-beta pruning.

It can be of two types:


o Worst ordering: In some cases, alpha-beta pruning algorithm does not prune
any of the leaves of the tree, and works exactly as minimax algorithm. In this
case, it also consumes more time because of alpha-beta factors, such a move
of pruning is called worst ordering. In this case, the best move occurs on the
right side of the tree. The time complexity for such an order is O(b m).
o Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of
pruning happens in the tree, and best moves occur at the left side of the tree.
We apply DFS hence it first search left of the tree and go deep twice as
minimax algorithm in the same amount of time. Complexity in ideal ordering
is O(bm/2

Goal Stack Planning:


Introduction :

Planning is process of determining various actions that often lead to a solution.

Planning is useful for non-decomposable problems where subgoals often interact.

Goal Stack Planning (in short GSP) is the one of the simplest planning algorithm
that is designed to handle problems having compound goals. And it utilizes STRIP
as a formal language for specifying and manipulating the world with which it is
working.

This approach uses a Stack for plan generation. The stack can contain Sub-goal
and actions described using predicates. The Sub-goals can be solved one by one in
any order.

Goal Stack Planning Algorithm:


Step-1: Push the original goal on the stack. Repeat until the stack is empty
Step-2: If the stack top is a compound goal, push its unsatisfied subgoals on the stack.

Step-3: If the stack top is a single unsatisfied goal. It replaces it with an action that
makes it
satisfied and push the action’s precondition on the stack.
Step-4: If stack top is an action, pop it from the stack, execute it and change the
knowledge base by the action’s effects.

Step-5: If stack top is a satisfying goal, pop it from the stack.


← PreviousNext →

Algorithm:
Push the Goal state in to the Stack
Push the individual Predicates of the Goal State into the Stack

Loop till the Stack is empty

Pop an element E from the stack

IF E is a Predicate

IF E is True then

Do Nothing

ELSE

Push the relevant action into the Stack

Push the individual predicates of the Precondition of the action into the Stack

Else IF E is an Action
Apply the action to the current State.

Add the action ‘a’ to the plan

Example :

The below example is from block world domain.

Lets start here with the example above, the initial state is our current description of
our world. The Goal state is what we have to achieve. The following list of actions
can be applied to the various situation in our problem.

First step is to push the goal into the stack.

Next push the individual predicates of the goal into the stack.
Now pop an element out from the stack

The popped element is indicated with a strike-through in the above diagram. The
element is ON(B,D) which is a predicate and it is not true in our current world. So
the next step is to push the relevant action which could achieve the subgoal
ON(B,D) in to the stack.

Now again push the precondition of the action Stack(B,D) into the stack.

The preconditions are highlighted with red and the actions are marked with Bold.
Now coming to the point we have to make the precondition to become true in order
to apply the action. Here we need to note an interesting thing about the
preconditions that, it can be pushed into the stack in any order but in certain
situations we have to make some exception and that is clearly seen in the above
diagram. The HOLDING(B) is pushed first and CLEAR(D) is pushed next
indicating that the HOLDING subgoal has to be done second comparing with the
CLEAR. Because we are considering the block world with single arm robot and
everything that we usually do here is depending on the robotic arm if we first
achieve HOLDING(D) then we have to undo the subgoal in order the achieve some
other subgoal. So if our compound goal has HOLDING (x) subgoal, achieve it at
the end.

*****************************

6) Machine Learning

What is Machine Learning?


Machine Learning is a branch of artificial intelligence that develops algorithms by
learning the hidden patterns of the datasets used it to make predictions on new
similar type data, without being explicitly programmed for each task.
Traditional Machine Learning combines data with statistical tools to predict an
output that can be used to make actionable insights.
Machine learning is used in many different applications, from image and speech
recognition to natural language processing, recommendation systems, fraud
detection, portfolio optimization, automated task, and so on. Machine learning
models are also used to power autonomous vehicles, drones, and robots, making
them more intelligent and adaptable to changing environments.
Why is machine learning important?
Machine learning is important because it gives enterprises a view of trends
in customer behavior and business operational patterns, as well as
supports the development of new products. Many of today's leading
companies, such as Facebook, Google and Uber, make machine learning a
central part of their operations. Machine learning has become a significant
competitive differentiator for many companies.

Types of Machine Learning:


Based on the methods and way of learning, machine learning is divided into mainly four
types, which are:

1. Supervised Machine Learning


2. Unsupervised Machine Learning
3. Semi-Supervised Machine Learning
4. Reinforcement Learning

In this topic, we will provide a detailed description of the types of Machine Learning along
with their respective algorithms:

1. Supervised Machine Learning:


As its name suggests, Supervised machine learning is based on supervision. It means
in the supervised learning technique, we train the machines using the "labelled"
dataset, and based on the training, the machine predicts the output. Here, the
labelled data specifies that some of the inputs are already mapped to the output.
More preciously, we can say; first, we train the machine with the input and
corresponding output, and then we ask the machine to predict the output using the
test dataset.

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.

Categories of Supervised Machine Learning


Supervised machine learning can be classified into two types of problems, which are
given below:

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.

Some popular classification algorithms are given below:

o Random Forest Algorithm


o Decision Tree Algorithm
o Logistic Regression Algorithm
o Support Vector Machine Algorithm

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.

Some popular Regression algorithms are given below:

o Simple Linear Regression Algorithm


o Multivariate Regression Algorithm
o Decision Tree Algorithm
o Lasso Regression

Advantages and Disadvantages of Supervised


Learning
Advantages:

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 These algorithms are not able to solve complex tasks.


o It may predict the wrong output if the test data is different from the training
data.
o It requires lots of computational time to train the algorithm.

Applications of Supervised Learning


Some common applications of Supervised Learning are given below:

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.

2. Unsupervised Machine Learning


Unsupervised learning is different from the Supervised learning technique; as its
name suggests, there is no need for supervision. It means, in unsupervised machine
learning, the machine is trained using the unlabeled dataset, and the machine
predicts the output without any supervision.

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

Categories of Unsupervised Machine Learning


Unsupervised Learning can be further classified into two types, which are given
below:

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.

Some of the popular clustering algorithms are given below:

o K-Means Clustering algorithm


o Mean-shift algorithm
o DBSCAN Algorithm
o Principal Component Analysis
o Independent Component Analysis

2) Association:

ssociation 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.

Advantages and Disadvantages of Unsupervised


Learning Algorithm
Advantages:

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.
Applications of Unsupervised Learning

o Network Analysis: Unsupervised learning is used for identifying plagiarism


and copyright in document network analysis of text data for scholarly articles.
o Recommendation Systems: Recommendation systems widely use
unsupervised learning techniques for building recommendation applications
for different web applications and e-commerce websites.
o Anomaly Detection: Anomaly detection is a popular application of
unsupervised learning, which can identify unusual data points within the
dataset. It is used to discover fraudulent transactions.
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.

To overcome the drawbacks of supervised learning and unsupervised learning


algorithms, the concept of Semi-supervised learning is introduced. The main aim
of semi-supervised learning is to effectively use all the available data, rather than
only labelled data like in supervised learning. Initially, similar data is clustered along
with an unsupervised learning algorithm, and further, it helps to label the unlabeled
data into labelled data. It is because labelled data is a comparatively more expensive
acquisition than unlabeled data.

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.

Advantages and disadvantages of Semi-supervised


Learning
Advantages:

o It is simple and easy to understand the algorithm.


o It is highly efficient.
o It is used to solve drawbacks of Supervised and Unsupervised Learning
algorithms.

Disadvantages:

o Iterations results may not be stable.


o We cannot apply these algorithms to network-level data.
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.

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.
A reinforcement learning problem can be formalized using Markov Decision
Process(MDP). In MDP, the agent constantly interacts with the environment and
performs actions; at each action, the environment responds and generates a new
state.

Categories of Reinforcement Learning


Reinforcement learning is categorized mainly into two types of methods/algorithms:

o Positive Reinforcement Learning: Positive reinforcement learning specifies


increasing the tendency that the required behaviour would occur again by
adding something. It enhances the strength of the behaviour of the agent and
positively impacts it.
o Negative Reinforcement Learning: Negative reinforcement learning works
exactly opposite to the positive RL. It increases the tendency that the specific
behaviour would occur again by avoiding the negative condition.

Real-world Use cases of Reinforcement Learning

o Video Games:
RL algorithms are much popular in gaming applications. It is used to gain
super-human performance. Some popular games that use RL algorithms
are AlphaGO and AlphaGO Zero.
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.
o Helps in achieving long term results.

Disadvantage

o RL algorithms are not preferred for simple problems.


o RL algorithms require huge data and computations.
o Too much reinforcement learning can lead to an overload of states which can
weaken the results.

The curse of dimensionality limits reinforcement learning for real physical system.

(KNN) Algorithm K-Nearest Neighbor:

What is K-Nearest Neighbors Algorithm?


K-Nearest Neighbours is one of the most basic yet essential classification algorithms
in Machine Learning. It belongs to the supervised learning domain and finds intense
application in pattern recognition, data mining, and intrusion detection.
It is widely disposable in real-life scenarios since it is non-parametric, meaning, it
does not make any underlying assumptions about the distribution of data (as opposed
to other algorithms such as GMM, which assume a Gaussian distribution of the
given data). We are given some prior data (also called training data), which
classifies coordinates into groups identified by an attribute.
As an example, consider the following table of data points containing two features:
Now, given another set of data points (also called testing data), allocate these points
to a group by analyzing the training set. Note that the unclassified points are marked
as ‘White’.

Distance Metrics Used in KNN Algorithm


As we know that the KNN algorithm helps us identify the nearest points or the
groups for a query point. But to determine the closest groups or the nearest points for
a query point we need some metric. For this purpose, we use below distance metrics:
 Euclidean Distance
 Manhattan Distance
 Minkowski Distance

Euclidean Distance

This is nothing but the cartesian distance between the two points which are in the
plane/hyperplane. Euclidean distance can also be visualized as the length of the
straight line that joins the two points which are into consideration. This metric helps
us calculate the net displacement done between the two states of an object.

Manhattan Distance

This distance metric is generally used when we are interested in the total distance
traveled by the object instead of the displacement. This metric is calculated by
summing the absolute difference between the coordinates of the points in n-
dimensions.

Minkowski Distance
We can say that the Euclidean, as well as the Manhattan distance, are special cases
of the Minkowski distance.

From the formula above we can say that when p = 2 then it is the same as the
formula for the Euclidean distance and when p = 1 then we obtain the formula for
the Manhattan distance.
The above-discussed metrics are most common while dealing with a Machine
Learning problem but there are other distance metrics as well like Hamming
Distance which come in handy while dealing with problems that require overlapping
comparisons between two vectors whose contents can be boolean as well as string
values.
Applications of the KNN Algorithm
 Data Preprocessing – While dealing with any Machine Learning problem
we first perform the EDA part in which if we find that the data contains
missing values then there are multiple imputation methods are available as
well. One of such method is KNN Imputer which is quite effective ad
generally used for sophisticated imputation methodologies.
 Pattern Recognition – KNN algorithms work very well if you have
trained a KNN algorithm using the MNIST dataset and then performed the
evaluation process then you must have come across the fact that the
accuracy is too high.
 Recommendation Engines – The main task which is performed by a
KNN algorithm is to assign a new query point to a pre-existed group that
has been created using a huge corpus of datasets. This is exactly what is
required in the recommender systems to assign each user to a particular
group and then provide them recommendations based on that group’s
preferences.

Advantages of the KNN Algorithm:

 Easy to implement as the complexity of the algorithm is not that high.


 Adapts Easily – As per the working of the KNN algorithm it stores all the
data in memory storage and hence whenever a new example or data point
is added then the algorithm adjusts itself as per that new example and has
its contribution to the future predictions as well.
 Few Hyperparameters – The only parameters which are required in the
training of a KNN algorithm are the value of k and the choice of the
distance metric which we would like to choose from our evaluation metric.

Disadvantages of the KNN Algorithm:
 Does not scale – As we have heard about this that the KNN algorithm is
also considered a Lazy Algorithm. The main significance of this term is
that this takes lots of computing power as well as data storage. This makes
this algorithm both time-consuming and resource exhausting.
 Curse of Dimensionality – There is a term known as the peaking
phenomenon according to this the KNN algorithm is affected by the curse
of dimensionality which implies the algorithm faces a hard time
classifying the data points properly when the dimensionality is too high.
 Prone to Overfitting – As the algorithm is affected due to the curse of
dimensionality it is prone to the problem of overfitting as well. Hence
generally feature selection as well as dimensionality reduction techniques
are applied to deal with this problem.

*******************************

You might also like