AI Lectures
AI Lectures
UNIT I
INTRODUCTIO
Page 1
lOMoAR cPSD| 31245499
This approach focuses on building artificial intelligence systems that can act like humans.
The goal is to create systems that can perform tasks such as recognizing speech, recognizing
images, and controlling robots in a human-like manner.
This approach is mainly used in computer vision and robotics, where the goal is to create
systems that can perceive and interact with the physical world in a human-like manner.
Examples:
Page 2
lOMoAR cPSD| 31245499
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.
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.
Player A (Computer): No
Player B (Human) : No
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.
Features required for a machine to pass the Turing test:
Natural language processing: NLP is required to communicate with Interrogator in
general human language like English.
Knowledge representation: To store and retrieve information during the test.
Automated reasoning: To use previously stored information to answer the questions.
Machine learning: To adapt new changes and can detect generalized patterns.
Vision: To recognize the interrogator actions and other objects during a test.
Examples:
a. Siri, Alexa, and Google Assistant: Virtual assistants that can understand and respond to
natural language input from users.
b. Chatbots: AI systems that can have conversations with humans using natural language
processing techniques.
c. Emotion recognition systems: AI systems that can detect emotions in human speech and
facial expressions.
Examples:
a. Autonomous agents: AI systems that can make decisions and take actions to achieve their
goals in an efficient and effective manner. Autonomous intelligence is artificial intelligence
(AI) that can act without human intervention, input, or direct supervision. It's considered the
most advanced type of artificial intelligence. Examples may include smart manufacturing
robots, self-driving cars, or care robots for the elderly.
c. Game AI: AI systems that can play games such as chess, Go, or poker and make decisions
based on the rules and objectives of the game.
1.3 IMPORTANCE AND PURPOSE OF ARTIFICIAL INTELLIGENCE
Before Learning about Artificial Intelligence, we should know that what is the importance
of AI and why should we learn it. Following are some main reasons to learn about AI:
With the help of AI, you can create such software or devices which can solve real-
world problems very easily and with accuracy such as health issues, marketing, traffic
issues, etc.
With the help of AI, you can create your personal virtual Assistant, such as Cortana,
Google Assistant, Siri, etc.
Page 5
lOMoAR cPSD| 31245499
With the help of AI, you can build such Robots which can work in an environment
where survival of humans can be at risk.
AI opens a path for other new technologies, new devices, and new Opportunities.
Proving a theorem
Playing chess
Plan some surgical operation
Driving a car in traffic
5. Creating some system which can exhibit intelligent behavior, learn new things by
itself, demonstrate, explain, and can advise to its user.
To create the AI first we should know that how intelligence is composed, so the
Intelligence is an intangible part of our brain which is a combination of Reasoning, learning,
problem-solving perception, language understanding, etc. To achieve the above factors
for a machine or software Artificial Intelligence requires the following discipline:
Page 6
lOMoAR cPSD| 31245499
Page 7
lOMoAR cPSD| 31245499
Page 8
lOMoAR cPSD| 31245499
1.3.5 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:
AI in Astronomy
Artificial Intelligence can be very useful to solve complex universe problems. AI
technology can be helpful for understanding the universe such as how it works, origin,
etc.
AI in Healthcare
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.
Healthcare Industries are applying AI to make a better and faster diagnosis than
humans. AI can help doctors with diagnoses and can inform when patients are
worsening so that medical help can reach to the patient before hospitalization.
AI in Gaming
AI can be used for gaming purpose. The AI machines can play strategic games like
chess, where the machine needs to think of a large number of possible places.
AI in Finance
AI and finance industries are the best matches for each other. The finance industry is
implementing automation, chatbot, adaptive intelligence, algorithm trading, and
machine learning into financial processes.
AI in Data Security
The security of data is crucial for every company and cyber-attacks are growing very
rapidly in the digital world. AI can be used to make your data more safe and secure.
Some examples such as AEG bot, AI2 Platform, are used to determine software bug
and cyber-attacks in a better way.
AI in Social Media
Social Media sites such as Facebook, Twitter, and Snap chat 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, hash tag, and requirement of different users.
Page 9
lOMoAR cPSD| 31245499
AI in Travel &Transport
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.
AI in Automotive Industry
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.
Various Industries are currently working for developing self-driven cars which can
make your journey more safe and secure.
AI in Robotics
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.
Humanoid Robots are best examples for AI in robotics, recently the intelligent
Humanoid robot named as Erica and Sophia has been developed which can talk and
behave like humans.
AI in Entertainment
We are currently using some AI based applications in our daily life with some
entertainment services such as Netflix or Amazon. With the help of ML/AI
algorithms, these services show the recommendations for programs or shows.
AI in Agriculture
Agriculture is an area which requires various resources, labor, money, and time for
best result. Now a day's agriculture is becoming digital, and AI is emerging in this
field. Agriculture is applying AI as agriculture robotics, solid and crop monitoring,
predictive analysis. AI in agriculture can be very helpful for farmers.
AI in E-commerce
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.
Page
10
lOMoAR cPSD| 31245499
AI in education
AI can automate grading so that the tutor can have more time to teach. AI chatbot can
communicate with students as a teaching assistant.
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.
1.4 HISTORY AND FUTURE OF ARTIFICIAL INTELLIGENCE
Artificial Intelligence is not a new word and not a new technology for researchers.
This technology is much older than you would imagine. Even there are the myths of
Mechanical men in Ancient Greek and Egyptian Myths. Following are some milestones in the
history of AI which defines the journey from the AI generation to till date development.
Page
11
lOMoAR cPSD| 31245499
Year 1943: The first work which is now recognized as AI was done by Warren
McCulloch and Walter pits in 1943. They proposed a model of artificial neurons.
Year 1949: Donald Hebb demonstrated an updating rule for modifying the
connection strength between neurons. His rule is now called Hebbian learning.
Year 1950: The Alan Turing who was an English mathematician and pioneered
Machine learning in 1950. Alan Turing publishes "Computing Machinery and
Intelligence" in which he proposed a test. The test can check the machine's ability to
exhibit intelligent behavior equivalent to human intelligence, called a Turing test.
Year 1955: An Allen Newell and Herbert A. Simon created the "first artificial
intelligence program"Which was named as "Logic Theorist". This program had
proved 38 of 52 Mathematics theorems, and find new and more elegant proofs for
some theorems.
Year 1956: The word "Artificial Intelligence" first adopted by American Computer
Page
12
lOMoAR cPSD| 31245499
Year 1966: The researchers emphasized developing algorithms which can solve
mathematical problems. Joseph Weizenbaum created the first chatbot in 1966, which
was named as ELIZA.
Year 1972: The first intelligent humanoid robot was built in Japan which was named
as WABOT-1.
The duration between years 1974 to 1980 was the first AI winter duration. AI winter
refers to the time period where computer scientist dealt with a severe shortage of
funding from government for AI researches.
During AI winters, an interest of publicity on artificial intelligence was decreased.
1.4.5 A boom of AI (1980-1987)
Year 1980: After AI winter duration, AI came back with "Expert System". Expert
systems were programmed that emulate the decision-making ability of a human
expert.
In the Year 1980, the first national conference of the American Association of
Artificial Intelligence was held at Stanford University.
The duration between the years 1987 to 1993 was the second AI Winter duration.
Again Investors and government stopped in funding for AI research as due to high
cost but not efficient result. The expert system such as XCON was very cost effective.
Year 1997: In the year 1997, IBM Deep Blue beats world chess champion, Gary
Kasparov, and became the first computer to beat a world chess
champion.
Page
13
lOMoAR cPSD| 31245499
Year 2002: for the first time, AI entered the home in the form of Roomba, a vacuum
cleaner.
Year 2006: AI came in the Business world till the year 2006. Companies like
Facebook, Twitter, and Netflix also started using AI.
1.4.8 .8 Deep learning, big data and artificial general intelligence (2011-present)
Year 2011: In the year 2011, IBM's Watson won jeopardy, a quiz show, where it had
to solve the complex questions as well as riddles. Watson had proved that it could
understand natural language and can solve tricky questions quickly.
Year 2012: Google has launched an Android app feature "Google now", which was
able to provide information to the user as a prediction.
Year 2014: In the year 2014, Chatbot "Eugene Goostman" won a competition in the
infamous "Turing test."
Year 2018: The "Project Debater" from IBM debated on complex topics with two
master debaters and also performed extremely well.
Google has demonstrated an AI program "Duplex" which was a virtual assistant and
which had taken hairdresser appointment on call, and lady on other side didn't notice
that she was talking with the machine.
Now AI has developed to a remarkable level. The concept of Deep learning, big data, and
data science are now trending like a boom. Nowadays companies like Google, Facebook,
IBM, and Amazon are working with AI and creating amazing devices. The future of Artificial
Intelligence is inspiring and will come with high intelligence.
Page
14
lOMoAR cPSD| 31245499
sewage to fighting fire and diffusing bombs, it?s we who get down, get our hands dirty and
risk our lives. The number of human lives we lose is also very high in these processes. In the
near future, we can expect machines or robots to take care of them. As artificial intelligence
evolves and smarter robots roll out, we can see them replacing humans at some of the riskiest
jobs in the world. That?s the only time we expect automation to take away jobs.
Personal Assistants:
Virtual assistants are already there and some of us would’ve used them. However, as the
technology grows, we can expect them to act as personal assistants and emote like humans.
With artificial intelligence, deep learning, and neural networks, it?s highly possible that we
can make robots emote and make them assistants. They could be used in tons of different
purposes such as in hospitality industry, day care centers, elder care, in clerical jobs and
more.
1.5 AGENT
An agent is anything that can viewed as perceiving its environment through sensors
and acting upon that environment through effectors. An Agent runs in the cycle of perceiving,
thinking, and acting those inputs and display output on the screen.
Hence the world around us is full of agents such as thermostat, cellphone, camera, and
even we are also agents.
Sensor: Sensor is a device which detects the change in the environment and sends the
information to other electronic devices. An agent observes its environment through sensors.
Actuators: Actuators are the component of machines that converts energy into
motion. The actuators are only responsible for moving and controlling a system. An actuator
can be an electric motor, gears, rails, etc.
Effectors: Effectors are the devices which affect the environment. Effectors can be
legs, wheels, arms, fingers, wings, fins, and display screen.
Page
15
lOMoAR cPSD| 31245499
An AI system can be defined as the study of the rational agent and its environment.
The agents sense the environment through sensors and act on their environment through
actuators. An AI agent can have mental properties such as knowledge, belief, intention, etc.
An agent can be:
Human-Agent: A human agent has eyes, ears, and other organs which work for sensors and
hand, legs, vocal tract work for actuators.
Robotic Agent: A robotic agent can have cameras, infrared range finder, NLP for sensors
and various motors for actuators.
Page
16
lOMoAR cPSD| 31245499
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 Goal-based agents
o Utility-based agent
o Learning agent
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:
The task of AI is to design an agent program which implements the agent function.
The structure of an intelligent agent is a combination of architecture and agent program. It can
be viewed as:
Agent = Architecture + Agent program
The following are the main three terms involved in the structure of an AI agent: Architecture:
Architecture is machinery that an AI agent executes on. Agent Function: Agent function is
F : P* → A
Page
18
lOMoAR cPSD| 31245499
A: Actuators
S: Sensors
Here performance measure is the objective for the success of an agent's behavior.
PEAS for self-driving cars:
Let’s suppose a self-driving car then PEAS representation will be:
Performance: Safety, time, legal drive, comfort
Environment: Roads, other vehicles, road signs, pedestrian
Actuators: Steering, accelerator, brake, signal, horn
Sensors: Camera, GPS, speedometer, odometer, accelerometer, sonar.
Performance
Agent Environment Actuators Sensors
measure
Patient Keyboard
1. Medical Patient Health Tests
Hospital (Entry of
Diagnose Disease diagnoses Treatments
Staff symptoms)
Page
19
lOMoAR cPSD| 31245499
Performance
Agent Environment Actuators Sensors
measure
Camera
Dirt detection
Room
Cleanness Wheels sensor
Table
2. Vacuum Efficiency Brushes Cliff sensor
Wood floor
Cleaner Battery life Vacuum Bump Sensor
Carpet
Extractor Infrared Wall
Various obstacles
Sensor
Camera
Percentage of Conveyor belt
3. Part - Jointed Arms Joint angle
parts in correct with parts,
picking Robot Hand sensors.
bins. Bins
Other types of problems include identifying patterns, predicting outcomes, and determining
solutions to systems of equations. Each type of problem has its own set of techniques and tools
that can be used to solve it.
1) understanding the problem: This step involves understanding the specifics of the problem and
figuring out what needs to be done to solve it.
2) generating possible solutions: This step involves coming up with as many possible solutions as
possible based on information about the problem and what you know about how computers work.
3) choosing a solution: This step involves deciding which solution is best based on what you know
about the problem and your options for solving it.
Problem-solving agents are a type of artificial intelligence that helps automate problem-solving.
They can be used to solve problems in natural language, algebra, calculus, statistics, and machine
learning.
There are three types of problem-solving agents: propositional, predicate, and automata.
Propositional problem-solving agents can understand simple statements like “draw a line between
A and B” or “find the maximum value of x.” Predicate problem-solving agents can understand
more complex statements like “find the shortest path between two points” or “find all pairs of
snakes in a jar.” Automata is the simplest form of problem-solving agent and can only understand
sequences of symbols like “draw a square.”
The problem solving agent follows this four phase problem solving process:
1. Goal Formulation: This is the first and most basic phase in problem solving. It arranges
specific steps to establish a target/goal that demands some activity to reach it. AI agents are
now used to formulate goals.
3. Search: After the Goal and Problem Formulation, the agent simulates sequences of actions
and has to look for a sequence of actions that reaches the goal. This process is
called search, and the sequence is called a solution. The agent might have to simulate
multiple sequences that do not reach the goal, but eventually, it will find a solution, or it
will find that no solution is possible. A search algorithm takes a problem as input and
outputs a sequence of actions.
4. Execution: After the search phase, the agent can now execute the actions that are
recommended by the search algorithm, one at a time. This final stage is known as the
execution phase.
Page
21
lOMoAR cPSD| 31245499
2. Actions
3. Transition Model
4. Goal Test
5. Path Cost
Initial State
It is the agent’s starting state or initial step towards its goal. For example, if a taxi agent needs to
travel to a location(B), but the taxi is already at location(A), the problem’s initial state would be
the location (A).
Actions
It is a description of the possible actions that the agent can take. Given a state s, Actions(s)
returns the actions that can be executed in s. Each of these actions is said to be appropriate in s.
It describes what each action does. It is specified by a function Result(s, a) that returns the state
that results from doing action an in state s.
The initial state, actions, and transition model together define the state space (A state space is a
set of all possible states that it can reach from the current state. The nodes of a state space
represent states, and the arcs connecting them represent actions. A path is a set of states and the
actions that link them in the state space.) of a problem, a set of all states reachable from the initial
state by any sequence of actions. The state space forms a graph in which the nodes are states, and
the links between the nodes are actions.
Goal Test
It determines if the given state is a goal state. Sometimes there is an explicit list of potential goal
states, and the test merely verifies whether the provided state is one of them. The goal is
sometimes expressed via an abstract attribute rather than an explicitly enumerated set of
conditions.
Path Cost
Page
22
lOMoAR cPSD| 31245499
It assigns a numerical cost to each path that leads to the goal. The problem solving agents choose
a cost function that matches its performance measure. Remember that the optimal solution has
the lowest path cost of all the solutions.
Example Problems
The problem-solving approach has been used in a wide range of work contexts. There are two
kinds of problem approaches
2. Real-world Problems: It is real-world problems that need solutions. It does not rely on
descriptions, unlike a toy problem, yet we can have a basic description of the issue.
8 Puzzle Problem
In a sliding-tile puzzle, a number of tiles (sometimes called blocks or pieces) are arranged in a
grid with one or more blank spaces so that some of the tiles can slide into the blank space. One variant
is the Rush Hour puzzle, in which cars and trucks slide around a 6 x 6 grid in an attempt to free a car
from the traffic jam. Perhaps the best-known variant is the 8- puzzle (see Figure below), which
consists of a 3 x 3 grid with eight numbered tiles and one blank space. The object is to reach a
specified goal state, such as the one shown on the right of the figure. The standard formulation of the
8 puzzles is as follows:
Let us take a vacuum cleaner agent and it can move left or right and its jump is to suck up the dirt
from the floor.
A grid world problem is a two-dimensional rectangular array of square cells through which agents
can move. Typically, the agent can go to any nearby cell that is clear of obstacles, either horizontally
or vertically, and in rare cases diagonally. A wall or other impassible obstruction in a cell prohibits an
agent from moving inside that cell.
The vacuum world’s problem can be stated as follows:
Searching is a process to find the solution for a given set of problems. This in artificial intelligence
can be done by using uninformed searching strategies of either informed searching strategies.
Uninformed searches, also known as blind searches, are search algorithms that explore a problem
space without using any specific knowledge or heuristics about the problem domain. They operate
in a brute force, meaning they try out every part of search space (The space of all feasible
solutions (the set of solutions among which the desired solution resides) is called search space )
Page
24
lOMoAR cPSD| 31245499
blindly and a brute force algorithm is a simple, comprehensive search strategy that systematically
explores every option until a problem’s answer is discovered.
Uninformed searches rely solely on the given problem definition and operate systematically to find
a solution. Examples of uninformed search algorithms include breadth-first search (BFS), depth-
first search (DFS),uniform-cost search (UCS), depth-limited search , and iterative deepening depth-
first search. Although all these examples work in a brute force way, they differ in the way they
traverse the nodes.
So far we have talked about the uninformed search algorithms which looked through search space
for all possible solutions of the problem without having any additional knowledge about search
space. But informed search algorithm contains an array of knowledge such as how far we are from
the goal, path cost, how to reach to goal node, etc. This knowledge help agents to explore less to the
search space and find more efficiently the goal node.
Page
25
lOMoAR cPSD| 31245499
What is Heuristics?
A heuristic is a technique that is used to solve a problem faster than the classic methods. These
techniques are used to find the approximate solution of a problem when classical methods do not.
Heuristics are said to be the problem-solving techniques that result in practical and quick solutions.
Heuristics are strategies that are derived from past experience with similar problems. Heuristics use
practical methods and shortcuts used to produce the solutions that may or may not be optimal, but
those solutions are sufficient in a given limited timeframe.
History
Psychologists Daniel Kahneman and Amos Tversky have developed the study of Heuristics in
human decision-making in the 1970s and 1980s. However, this concept was first introduced by
the Nobel Laureate Herbert A. Simon, whose primary object of research was problem-solving.
Heuristics are used in situations in which there is the requirement of a short-term solution. On
facing complex situations with limited resources and time, Heuristics can help the companies to
make quick decisions by shortcuts and approximated calculations. Most of the heuristic methods
involve mental shortcuts to make decisions on past experiences.
The heuristic method might not always provide us the finest solution, but it is assured that it helps
us find a good solution in a reasonable time.
Page
26
lOMoAR cPSD| 31245499
The best first search uses the concept of a priority queue and heuristic search. It is a search
algorithm that works on a specific rule. The aim is to reach the goal from the initial state via the
shortest path. The best First Search algorithm in artificial intelligence is used for for finding the
shortest path from a given starting node to a goal node in a graph. The algorithm works by
expanding the nodes of the graph in order of increasing the distance from the starting node until the
goal node is reached.
BFS uses the concept of a Priority queue and heuristic search. To search the graph space, the BFS
method uses two lists for tracking the traversal. An ‘Open’ list that keeps track of the current
‘immediate’ nodes available for traversal and a ‘CLOSED’ list that keeps track of the nodes already
traversed.
Page
27
lOMoAR cPSD| 31245499
A * algorithm is a searching algorithm that searches for the shortest path between the initial and the final
state. It is used in various applications, such as maps.
In maps the A* algorithm is used to calculate the shortest distance between the source (initial state) and the
destination (final state).
How it works
Imagine a square grid which possesses many obstacles, scattered randomly. The initial and the final cell is
provided. The aim is to reach the final cell in the shortest amount of time.
Explanation
A* algorithm has 3 parameters:
g : the cost of moving from the initial cell to the current cell. Basically, it is the sum of all the cells
that have been visited since leaving the first cell.
h : also known as the heuristic value, it is the estimated cost of moving from the current cell to the
final cell. The actual cost cannot be calculated until the final cell is reached. Hence, h is the
estimated cost. We must make sure that there is never an over estimation of the cost.
The way that the algorithm makes its decisions is by taking the f-value into account. The algorithm selects
the smallest f-valued cell and moves to that cell. This process continues until the algorithm reaches its goal cell.
Page
28
lOMoAR cPSD| 31245499
Best-first search is what the AO* algorithm does. The AO* method divides any given difficult problem
into a smaller group of problems that are then resolved using the AND-OR graph concept. AND OR graphs
Page
29
lOMoAR cPSD| 31245499
are specialized graphs that are used in problems that can be divided into smaller problems. The AND side
of the graph represents a set of tasks that must be completed to achieve the main goal, while the OR side of
the graph represents different methods for accomplishing the same main goal.
AND-OR Graph
In the above figure, the buying of a car may be broken down into smaller problems or tasks that can be
accomplished to achieve the main goal in the above figure, which is an example of a simple AND-OR
graph. The other task is to either steal a car that will help us accomplish the main goal or use your own
money to purchase a car that will accomplish the main goal. The AND symbol is used to indicate the AND
part of the graphs, which refers to the need that all sub-problems containing the AND to be resolved before
the preceding node or issue may be finished.
The start state and the target state are already known in the knowledge-based search
strategy known as the AO* algorithm, and the best path is identified by heuristics. The informed search
technique considerably reduces the algorithm’s time complexity. The AO* algorithm is far more effective
in searching AND-OR trees than the A* 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.
Example:
Page
31
lOMoAR cPSD| 31245499
Here in the above example below the Node which is given is the heuristic value i.e h(n). Edge length
is considered as 1.
Step 1
Page
32
lOMoAR cPSD| 31245499
=6
So, by calculation A⇢B path is chosen which is the minimum path, i.e f(A⇢B)
Step 2
Page
33
lOMoAR cPSD| 31245499
f(B⇢E) = 1 + 7= 8
f(B⇢f) = 1 + 9 = 10
So, by above calculation B⇢E path is chosen which is minimum path, i.e f(B⇢E) because B's heuristic
value is different from its actual value The heuristic is updated and the minimum cost path is selected. The
minimum value in our situation is 8.
Page
34
lOMoAR cPSD| 31245499
Therefore, the heuristic for A must be updated due to the change in B's heuristic.
=1+8
=9
Step 3
f(C⇢G) = 1 + 3
=4
=2
f(C⇢H+I) is selected as the path with the lowest cost and the heuristic is also left unchanged
because it matches the actual cost. Paths H & I are solved because the heuristic for those paths is 0,
f(D⇢J) = 1 + 0
=1
=1+2+1+1 =5
as we can see that path f(A⇢C+D) is get solved and this tree has become a solved tree now.
In simple words, the main flow of this algorithm is that we have to find firstly level 1st heuristic
value and then level 2nd and after that update the values with going upward means towards the root node.
Page
36
lOMoAR cPSD| 31245499
Breadth-first Search
Breadth-first search (BFS) is one of the most important uninformed search strategies in artificial
intelligence to explore a search space systematically. BFS explores all the neighboring nodes of the initial
state before moving on to explore their neighbours. This strategy ensures that the shortest path to the goal
is found.
The algorithm works by starting at the initial state and adding all its neighbors to a queue. It then dequeues
the first node in the queue, adds neighbors to the end of the queue, and repeats the process until the goal
state is found or the queue is empty.
BFS explores all the nodes at a given distance (or level) from the starting node before moving on to explore
the nodes at the next distance (or level) from the starting node. This means that BFS visits all the nodes that
are closest to the starting node before moving on to nodes that are farther away.
Advantages
Page
37
lOMoAR cPSD| 31245499
Breadth-first search (BFS) is an algorithm used in artificial intelligence to explore a search space
systematically. Some advantages of BFS include the following:
Completeness:
BFS is guaranteed to find the goal state if it exists in the search space, provided the branching factor
is finite.
Optimal solution:
BFS is guaranteed to find the shortest path to the goal state, as it explores all nodes at the same
depth before moving on to nodes at a deeper level.
Simplicity:
BFS is easy to understand and implement, making it a good baseline algorithm for more complex
search algorithms.
No redundant paths:
BFS does not explore redundant paths because it explores all nodes at the same depth before
moving on to deeper levels.
Disadvantages
Memory-intensive:
BFS can be memory-intensive for large search spaces because it stores all the nodes at each level in
the queue.
Time-intensive:
BFS can be time-intensive for search spaces with a high branching factor because it needs to
explore many nodes before finding the goal state.
Inefficient for deep search spaces:
BFS can be inefficient for search spaces with a deep depth because it needs to explore all nodes at
each depth before moving on to the next level.
The time and space complexity of breadth-first search (BFS) in artificial intelligence can vary depending
on the size and structure of the search space.
Time complexity:
The time complexity of BFS is proportional to the number of nodes in the search space, as BFS explores all
nodes at each level before moving on to deeper levels. For example, if the goal state is at the deepest level,
BFS must explore all nodes in the search space, resulting in a time complexity of bd, where b is the
branching factor, and d is the depth of the search space.
Space complexity:
The space complexity of BFS is proportional to the maximum number of nodes stored in the queue during
the search. For example, if the search space is a tree, the maximum number of nodes stored in the queue at
any given time is the number of nodes at the deepest level, which is proportional to bd. Therefore, the
space complexity of BFS is O(bd).
Example
Suppose we have a search space with an initial state "A" and a goal state "E" connected by nodes as
follows:
Page
38
lOMoAR cPSD| 31245499
To perform BFS on this search space, we start by adding the initial state "A" to a queue:
Queue: A
Explored: {}
We dequeue the first node in the queue, which is "A", and add its children "B" and "C" to the end of the
queue:
Queue: B, C
Explored: {A}
We then dequeue "B" and "C" and add their children to the end of the queue:
Queue: C, D
Explored: {A, B}
We dequeue "C" and add its child "E" to the end of the queue:
Queue: D, E
Explored: {A, B, C}
Finally, we dequeue "D" and "E" and find that "E" is the goal state, so we have successfully found a path
from "A" to "E" using BFS.
Depth-first Search
Page
39
lOMoAR cPSD| 31245499
Depth-first search (DFS) is popular among the uninformed search strategies in artificial intelligence to
explore and traverse a graph or tree data structure. The algorithm starts at a given node in the graph and
explores as far as possible along each branch before backtracking.
DFS has several applications in AI, including pathfinding, searching for solutions to a problem, and
exploring the state space of a problem. It is particularly useful when the solution is far from the starting
node because it can explore the graph deeply before exploring widely.
Advantages
Memory efficiency:
DFS uses less memory than breadth-first search because it only needs to keep track of a single path
at a time.
Finds a solution quickly:
If the solution to a problem is located deep in a tree, DFS can quickly reach it by exploring one path
until it reaches the solution.
Easy to implement:
DFS is a simple algorithm to understand and implement, especially when using recursion.
Can be used for certain types of problems:
DFS is particularly useful for problems that involve searching for a path, such as maze-solving or
finding the shortest path between two nodes in a graph.
Disadvantages
Page
40
lOMoAR cPSD| 31245499
Example
Traversing a binary tree
1
/ \
2 3
/ \ / \
4 5 6 7
To traverse this tree using DFS, we start at the root node (1) and explore as far as possible along each
branch before backtracking. Here is the order in which the nodes would be visited.
We first visit the root node (1), then the left child (2), and so on. Once we reach a leaf node (4), we
backtrack to the last node with an unexplored child (2) and continue exploring its other child (5). We
continue this process until all nodes have been visited.
Uniform-cost search is a searching algorithm used for traversing a weighted tree or graph. This
algorithm comes into play when a different cost is available for each edge. The primary goal of the
Page
41
lOMoAR cPSD| 31245499
uniform-cost search is to find a path to the goal node which has the lowest cumulative cost.
Uniform-cost search expands nodes according to their path costs form the root node. It can be used
to solve any graph/tree where the optimal cost is in demand. A uniform-cost search algorithm is
implemented by the priority queue. It gives maximum priority to the lowest cumulative cost.
Uniform cost search is equivalent to BFS algorithm if the path cost of all edges is the same.
Example
Input: Let the graph be as below with source node being A and destination E.
Output:
Advantages:
o Uniform cost search is optimal because at every state the path with the least cost is chosen.
Page
42
lOMoAR cPSD| 31245499
Disadvantages:
o It does not care about the number of steps involve in searching and only concerned about path cost.
Due to which this algorithm may be stuck in an infinite loop.
Depth limited search is the new search algorithm for uninformed search. The unbounded tree
problem happens to appear in the depth-first search algorithm, and it can be fixed by imposing a
boundary or a limit to the depth of the search domain. We will say that this limit as the depth limit,
making the DFS search strategy more refined and organized into a finite loop. We denote this limit
by l, and thus this provides the solution to the infinite path problem that originated earlier in the
DFS algorithm. Thus, Depth limited search can be called an extended and refined version of the
DFS algorithm. In a nutshell, we can say that to avoid the infinite loop status while executing the
codes, and depth limited search algorithm is being executed into a finite set of depth called depth
limit.
Algorithm
This algorithm essentially follows a similar set of steps as in the DFS algorithm.
2. Then it is marked as visited, and if node 1 is not the goal node in the search,
3. Next, we mark it as visited and check if node 2 is the goal node or not.
4. If node 2 is not found to be the goal node, then we push node 4 on top of the
stack.
5. Now we search in the same depth limit and move along depth-wise to check for
6. If Node 4 is also not found to be the goal node and depth limit is found to be
unexplored.
Page
43
lOMoAR cPSD| 31245499
7. Then we push them into the stack and mark them visited.
8. We continue to perform these steps in iterative ways unless the goal node is
reached or until all nodes within depth limit have been explored for the goal.
Knowledge representation?
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).
Types of knowledge
Following are the various types of knowledge:
Page
45
lOMoAR cPSD| 31245499
1. Declarative Knowledge:
2. Procedural Knowledge
3. Meta-knowledge:
4. Heuristic knowledge:
Page
46
lOMoAR cPSD| 31245499
5. Structural knowledge:
Let's suppose if you met some person who is speaking in a language which you don't
know, then how you will able to act on that. The same thing applies to the intelligent
behavior of the agents. As we can see in below diagram, there is one decision maker
which act by sensing the environment and using knowledge. But if the knowledge
part will not present then, it cannot display intelligent behavior.
Page
47
lOMoAR cPSD| 31245499
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying
intelligent behavior:
o Perception
o Learning
o Knowledge Representation and Reasoning
o Planning
o Execution
The above diagram is showing how an AI system can interact with the real world and
what components help it to show intelligence. AI system has Perception component
by which it retrieves information from its environment. It can be visual, audio or
another form of sensory input. The learning component is responsible for learning
from data captured by Perception comportment. In the complete cycle, the main
components are knowledge representation and Reasoning. These two components
are involved in showing the intelligence in machine-like humans. These two
components are independent with each other but also coupled together. The
planning and execution depend on analysis of Knowledge representation and
reasoning.
Page
48
lOMoAR cPSD| 31245499
There are mainly four approaches to knowledge representation, which are given
below:
o It is the simplest way of storing facts which uses the relational method, and
each fact about a set of the object is set out systematically in columns.
o This approach of knowledge representation is famous in database systems
where the relationship between different entities is represented.
o This approach has little opportunity for inference.
Player1 65 23
Player2 58 18
Player3 75 24
2. Inheritable knowledge:
o In the inheritable knowledge approach, all data must be stored into a hierarchy
of classes.
o All classes should be arranged in a generalized form or a hierarchal manner.
o In this approach, we apply inheritance property.
o Elements inherit values from other members of a class.
o This approach contains inheritable knowledge which shows a relation between
instance and class, and it is called instance relation.
o Every individual frame can represent the collection of attributes and its value.
o In this approach, objects and values are represented in Boxed nodes.
o We use Arrows which point from objects to their values.
Example:
Page
49
lOMoAR cPSD| 31245499
3. Inferential knowledge:
a. Marcus is a man
b. All men are mortal
man(Marcus)
∀x = man (x) ----------> mortal (x)s
4. Procedural knowledge:
Page
50
lOMoAR cPSD| 31245499
Page
51
lOMoAR cPSD| 31245499
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
Page
52
lOMoAR cPSD| 31245499
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.
Syntax:
o Syntaxes are the rules which decide how we can construct legal sentences in
the logic.
Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.
Page
53
lOMoAR cPSD| 31245499
a) Propositional Logics
b) Predicate logics
Note: We will discuss Prepositional Logics and Predicate logics in later chapters.
Note: Do not be confused with logical representation and logical reasoning as logical representation
is a representation language and reasoning is a process of thinking logically.
Example: Following are some statements which we need to represent in the form of
nodes and arcs.
Statements:
a) Jerry is a cat.
b) Jerry is a mammal
Page
54
lOMoAR cPSD| 31245499
In the above diagram, we have represented the different type of knowledge in the
form of nodes and arcs. Each object is connected with another object by some
relation.
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.
Facets: The various aspects of a slot is known as Facets. Facets are features of
frames which enable us to put constraints on the frames. Example: IF-NEEDED facts
are called when data of any particular slot is needed. A frame may consist of any
number of slots, and a slot may include any number of facets and facets may have
any number of values. A frame is also known as slot-filter knowledge
representation in artificial intelligence.
Frames are derived from semantic networks and later evolved into our modern-day
classes and objects. A single frame is not much useful. Frames system consist of a
collection of frames which are connected. In the frame, knowledge about an object or
event can be stored together in the knowledge base. The frame is a type of
technology which is widely used in various applications including Natural language
processing and machine visions.
Example: 1
Slots Filters
Year 1996
Page 1152
Page
56
lOMoAR cPSD| 31245499
Example 2:
Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession,
and his age is 25, he lives in city London, and the country is England. So following is
the frame representation for this:
Slots Filter
Name Peter
Profession Doctor
Age 25
Weight 78
4. Production Rules
Page
57
lOMoAR cPSD| 31245499
Production rules system consist of (condition, action) pairs which mean, "If
condition then action". It has mainly three parts:
In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of
the rule determines which rule may be applied to a problem. And the action part
carries out the associated problem-solving steps. This complete process is called a
recognize-act cycle.
The working memory contains the description of the current state of problems-
solving and rule can write knowledge to the working memory. This knowledge match
and may fire other rules.
If there is a new situation (state) generates, then multiple production rules will be
fired together, this is called conflict set. In this situation, the agent needs to select a
rule from these sets, and it is called a conflict resolution.
Example:
o IF (at bus stop AND bus arrives) THEN action (get into the bus)
o IF (on the bus AND paid AND empty seat) THEN action (sit down).
o IF (on bus AND unpaid) THEN action (pay charges).
o IF (bus arrives at destination) THEN action (get down from the bus).
1. Production rule system does not exhibit any learning capabilities, as it does not
store the result of the problem for the future uses.
Page
58
lOMoAR cPSD| 31245499
2. During the execution of the program, many rules may be active hence rule-
based production systems are inefficient.
Example:
1. a) It is Sunday.
2. b) The Sun rises from West (False proposition)
3. c) 3+3= 7(False proposition)
4. d) 5 is a prime number.
Page
59
lOMoAR cPSD| 31245499
1. Atomic Propositions
2. Compound propositions
Example:
Example:
Logical Connectives:
Logical connectives are used to connect two simpler propositions or representing a
sentence logically. We can create compound propositions with the help of logical
connectives. There are mainly five connectives, which are given as follows:
Page
60
lOMoAR cPSD| 31245499
Q= Rohan is hardworking. → P∧ Q.
Precedence of connectives:
Just like arithmetic operators, there is a precedence order for propositional
connectors or logical operators. This order should be followed while evaluating a
propositional problem. Following is the list of the precedence order for operators:
Precedence Operators
Page
61
lOMoAR cPSD| 31245499
o We cannot represent relations like ALL, some, or none with propositional logic.
Example:
First-Order logic:
o First-order logic is another way of knowledge representation in artificial
intelligence. It is an extension to propositional logic.
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 Function: Father of, best friend, third inning of, end of, ......
a. Syntax
b. Semantics
Variables x, y, z, a, b,....
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.
Complex Sentences:
Page
64
lOMoAR cPSD| 31245499
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.
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:
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.
o For all x
o For each x
o For every x.
Example:
Page
65
lOMoAR cPSD| 31245499
Let a variable x which refers to a cat so all x can be represented in UOD as below:
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.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
Example:
Some boys are intelligent.
Page
66
lOMoAR cPSD| 31245499
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.
∀x bird(x) →fly(x).
And since there are all birds who fly so it will be represented as follows.
Page
67
lOMoAR cPSD| 31245499
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).
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:
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)].
Page
68
lOMoAR cPSD| 31245499
Machine Learning
A rapidly developing field of technology, machine learning allows computers to
automatically learn from previous data. For building mathematical models and
making
predictions based on historical data or information, machine learning employs a
variety
of algorithms. It is currently being used for a variety of tasks, including speech
recognition,
email filtering, auto-tagging on Facebook, a recommender system, and image
recognition.
prediction.
Machine Learning uses
Traditional AI can involve many
a
programming different techniques,
data-driven approach,
is typically rule-based including Machine
It is
and Learning
typically trained on
deterministic. It hasn’t and Deep Learning, as
historical data and
self-learning features well
then
like as traditional rule-
used to make
Machine Learning and based
predictions on
AI. programming.
new data.
Sometimes AI uses a
combination of both
Traditional
ML can find patterns Data
programming
and and Pre-defined rules,
is totally dependent on
insights in large which
the
datasets gives it a great edge in
intelligence of
that might be difficult solving complex tasks
developers.
for with
So, it has very limited
humans to discover. good accuracy which
capability.
seem
impossible to humans.
Machine Learning lifecycle:
3. Data Preparation: When our problem-related data is collected. then it is a good idea
to check the data properly and make it in the desired format so that it can be used by
the model to find the hidden patterns. This can be done in the following steps:
Page
71
lOMoAR cPSD| 31245499
• Data cleaning
• Data Transformation
• Explanatory Data Analysis and Feature Engineering
• Split the dataset for training and testing.
4. Model Selection: The next step is to select the appropriate machine learning
algorithm that is suitable for our problem. This step requires knowledge of the
strengths
and weaknesses of different algorithms. Sometimes we use multiple models and
compare their results and select the best model as per our requirements.
5. Model building and Training: After selecting the algorithm, we have to build
the
model.
1. In the case of traditional machine learning building mode is easy it is just a
few hyper parameter tunings.
6. Model Evaluation: Once the model is trained, it can be evaluated on the test dataset
to determine its accuracy and performance using different techniques like classification
report, F1 score, precision, recall, ROC Curve, Mean Square error, absolute error, etc.
7. Model Tuning: Based on the evaluation results, the model may need to be tuned or
optimized to improve its performance. This involves tweaking the hyper parameters of
the model.
8. Deployment: Once the model is trained and tuned, it can be deployed in a production
environment to make predictions on new data. This step requires integrating the model
into an existing software system or creating a new system for the model.
9. Monitoring and Maintenance: Finally, it is essential to monitor the model’s
performance in the production environment and perform maintenance tasks as required.
This involves monitoring for data drift, retraining the model as needed, and updating
the model as new data becomes available.
Page
72
lOMoAR cPSD| 31245499
Now in this Machine learning tutorial, let’s learn the applications of Machine
Learning:
• Automation: Machine learning, which works entirely autonomously in any field
without the need for any human intervention. For example, robots perform the
essential process steps in manufacturing plants.
• Healthcare industry: Healthcare was one of the first industries to use machine
learning with image detection.
Page
73
lOMoAR cPSD| 31245499
to
make decisions about navigation and safety.
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning
In supervised learning, the training data provided to the machines work as the supervisor that teaches the
machines to predict the output correctly. It applies the same concept as a student learns in the supervision
of the teacher.
Supervised learning is a process of providing input data as well as correct output data to the machine
learning model. The aim of a supervised learning algorithm is to find a mapping function to map the
input variable(x) with the output variable(y).
In the real-world, supervised learning can be used for Risk Assessment, Image classification, Fraud
Detection, spam filtering, etc.
The working of Supervised learning can be easily understood by the below example and diagram:
Suppose we have a dataset of different types of shapes which includes square, rectangle, triangle, and
Polygon. Now the first step is that we need to train the model for each shape.
o If the given shape has four sides, and all the sides are equal, then it will be labelled as a Square.
o If the given shape has three sides, then it will be labelled as a triangle.
o If the given shape has six equal sides then it will be labelled as hexagon.
Now, after training, we test our model using the test set, and the task of the model is to identify the shape.
The machine is already trained on all types of shapes, and when it finds a new shape, it classifies the shape
on the bases of a number of sides, and predicts the output.
o Split the training dataset into training dataset, test dataset, and validation dataset.
o Determine the input features of the training dataset, which should have enough knowledge so that
the model can accurately predict the output.
o Determine the suitable algorithm for the model, such as support vector machine, decision tree, etc.
o Execute the algorithm on the training dataset. Sometimes we need validation sets as the control
parameters, which are the subset of training datasets.
Page
75
lOMoAR cPSD| 31245499
o Evaluate the accuracy of the model by providing the test set. If the model predicts the correct
output, which means our model is accurate.
1. Regression
Regression algorithms are used if there is a relationship between the input variable and the output variable.
It is used for the prediction of continuous variables, such as Weather forecasting, Market Trends, etc.
Below are some popular Regression algorithms which come under supervised learning:
o Linear Regression
o Regression Trees
o Non-Linear Regression
o Polynomial Regression
2. Classification
Classification algorithms are used when the output variable is categorical, which means there are two
classes such as Yes-No, Male-Female, True-false, etc.
Spam Filtering,
o Random Forest
o Decision Trees
o Logistic Regression
Page
76
lOMoAR cPSD| 31245499
o With the help of supervised learning, the model can predict the output on the basis of prior
experiences.
o In supervised learning, we can have an exact idea about the classes of objects.
o Supervised learning model helps us to solve various real-world problems such as fraud detection,
spam filtering, etc.
o Supervised learning models are not suitable for handling the complex tasks.
o Supervised learning cannot predict the correct output if the test data is different from the training
dataset.
o Training required lots of computation times.
In the previous topic, we learned supervised machine learning in which models are trained using labeled
data under the supervision of training data. But there may be many cases in which we do not have labeled
data and need to find the hidden patterns from the given dataset. So, to solve such types of cases in
machine learning, we need unsupervised learning techniques.
As the name suggests, unsupervised learning is a machine learning technique in which models are not
supervised using training dataset. Instead, models itself find the hidden patterns and insights from the given
data. It can be compared to learning which takes place in the human brain while learning new things. It can
be defined as:
Unsupervised learning is a type of machine learning in which models are trained using unlabeled dataset
and are allowed to act on that data without any supervision.
Page
77
lOMoAR cPSD| 31245499
Unsupervised learning cannot be directly applied to a regression or classification problem because unlike
supervised learning, we have the input data but no corresponding output data. The goal of unsupervised
learning is to find the underlying structure of dataset, group that data according to similarities, and
represent that dataset in a compressed format.
Example: Suppose the unsupervised learning algorithm is given an input dataset containing images of
different types of cats and dogs. The algorithm is never trained upon the given dataset, which means it does
not have any idea about the features of the dataset. The task of the unsupervised learning algorithm is to
identify the image features on their own. Unsupervised learning algorithm will perform this task by
clustering the image dataset into the groups according to similarities between images.
o Unsupervised learning is helpful for finding useful insights from the data.
o Unsupervised learning is much similar as a human learns to think by their own experiences, which
makes it closer to the real AI.
o Unsupervised learning works on unlabeled and uncategorized data which make unsupervised
learning more important.
o In real-world, we do not always have input data with the corresponding output so to solve such
cases, we need unsupervised learning.
Page
78
lOMoAR cPSD| 31245499
Here, we have taken an unlabeled input data, which means it is not categorized and corresponding outputs
are also not given. Now, this unlabeled input data is fed to the machine learning model in order to train it.
Firstly, it will interpret the raw data to find the hidden patterns from the data and then will apply suitable
algorithms such as k-means clustering, Decision tree, etc.
Once it applies the suitable algorithm, the algorithm divides the data objects into groups according to the
similarities and difference between the objects.
The unsupervised learning algorithm can be further categorized into two types of problems:
o Clustering: Clustering is a method of grouping the objects into clusters such that objects with most
similarities remains into a group and has less or no similarities with the objects of another group.
Cluster analysis finds the commonalities between the data objects and categorizes them as per the
presence and absence of those commonalities.
Page
79
lOMoAR cPSD| 31245499
o Association: An association rule is an unsupervised learning method which is used for finding the
relationships between variables in the large database. It determines the set of items that occurs
together in the dataset. Association rule makes marketing strategy more effective. Such as people
who buy X item (suppose a bread) are also tend to purchase Y (Butter/Jam) item. A typical example
of Association rule is Market Basket Analysis.
o K-means clustering
o Hierarchal clustering
o Anomaly detection
o Neural Networks
o Apriori algorithm
o Unsupervised learning is used for more complex tasks as compared to supervised learning because,
in unsupervised learning, we don't have labeled input data.
o Unsupervised learning is preferable as it is easy to get unlabeled data in comparison to labeled data.
o Unsupervised learning is intrinsically more difficult than supervised learning as it does not have
corresponding output.
o The result of the unsupervised learning algorithm might be less accurate as input data is not labeled,
and algorithms do not know the exact output in advance.
Page
80
lOMoAR cPSD| 31245499
3) Reinforcement Learning
Reinforcement learning is a feedback-based learning method, in which a learning agent gets a reward for
each right action and gets a penalty for each wrong action. The agent learns automatically with these
feedbacks and improves its performance. In reinforcement learning, the agent interacts with the
environment and explores it. The goal of an agent is to get the most reward points, and hence, it improves
its
performance.
• Model-based reinforcement learning: as it sounds, has an agent trying to understand its environment
and creating a model for it based on its interactions with this environment. In such a system, preferences
take priority over the consequences of the actions i.e. the greedy agent will always try to perform an action
that will get the maximum reward irrespective of what that action may cause.
• Model-free reinforcement learning: On the other hand, model-free algorithms seek to learn the
consequences of their actions through experience via algorithms such as Policy Gradient, Q-Learning, etc.
In other words, such an algorithm will carry out an action multiple times and will adjust the policy (the
strategy behind its actions) for optimal rewards, based on the outcomes.
Some popular model-free reinforcement learning algorithms include Q-Learning, SARSA, and Deep
Reinforcement Learning.
Page
81