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

AI Lectures

Uploaded by

syedanabeeha260
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

AI Lectures

Uploaded by

syedanabeeha260
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 81

lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

UNIT I

INTRODUCTIO

Introduction–Definition – Future of Artificial Intelligence – Characteristics


of Intelligent Agents–Typical Intelligent Agents – Problem Solving
Approach to Typical AI problems.

1. 1 ARTIFICIAL INTELLIGENCE – AN INTRODUCTION

AI definitions can be categorized into four, they are as follows:


 Systems that think like humans
 Systems that think rationally
 Systems that act like humans
 System that act rationally

Page 1
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

1.2.1 Acting Humanly: Turning Test Approach

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:

self-driving cars, facial recognition systems, and gesture-based human-computer interfaces.


a. Self-driving cars: AI systems that can control a vehicle and navigate roads, traffic, and
obstacles in a human-like manner.
b. Facial recognition systems: AI systems that can identify individuals based on their facial
features.
c. Gesture-based human-computer interfaces: AI systems that can interpret and respond to
gestures made by a user.
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

Page 2
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

The questions and answers can be like:


Interrogator: Are you a computer?

Player A (Computer): No

Player B (Human) : No

Interrogator: Convert the decimal 45952 into binary.


Page 3
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

Player A: Long pause and give the wrong answer.?

Player B: 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.
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.

1.2.2 Thinking Humanly: The Cognitive Modeling Approach


This approach focuses on building artificial intelligence systems that can think like a human.
The goal is to create systems that can understand human language, emotions, and culture and
can interact with humans in a natural way.
This approach is mainly used in the development of conversational AI systems, such as
chatbots and virtual assistants, that need to understand and respond to natural language input
from humans.

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.

1.2.3 Thinking Rationally


This approach focuses on building artificial intelligence systems that can reason logically
and make decisions based on information and rules. The goal is to create systems that can
solve problems and make decisions in a way that is consistent with the principles of rational
thinking.
This approach is used in a wide range of applications, including decision-making, planning,
Page 4
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

and problem-solving. For example, expert systems, recommendation systems, and


optimization algorithms.
Examples:
a. Expert systems: AI systems that can make decisions and provide advice based on a set of
rules and knowledge.
b. Recommendation systems: AI systems that can provide personalized recommendations to
users based on their preferences and behavior.
c. Optimization algorithms: Optimization algorithms are computational methods that aim to
find the best solution among a set of possible solutions to a specific problem.

1.2.4 Acting Rationally


This approach is mainly used in artificial intelligence systems that need to make decisions and
take actions to achieve their goals in a rational and efficient manner. For example, autonomous
agents, recommendation systems, and reinforcement learning algorithms.

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.

b. Reinforcement learning algorithms: AI systems that can learn to take actions in an


environment by receiving rewards and punishments based on their decisions. In Reinforcement
Learning, the agent learns automatically using feedbacks without any labeled data

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

ARTIFICIAL INTELLIGENCE UNIT I

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

1.3.1 Goals of Artificial Intelligence

Following are the main goals of Artificial Intelligence:

1. Replicate human intelligence


2. Solve Knowledge-intensive tasks ("Solving knowledge-intensive tasks" means an AI system
can handle complex problems that need a lot of expert knowledge and reasoning.)
3. An intelligent connection of perception and action (A smart link between sensing and doing.)
4. Building a machine which can perform tasks that requires human intelligence such as:

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

1.3.2 Discipline of Artificial Intelligence

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

ARTIFICIAL INTELLIGENCE UNIT I

1.3.3 Advantages of Artificial Intelligence

Following are some main advantages of Artificial Intelligence:


 High Accuracy with fewer errors: AI machines or systems are likely to less errors
and high accuracy as it takes decisions as per pre-experience or information.
 High-Speed: AI systems can be of very high-speed and fast-decision making, because
of that AI systems can beat a chess champion in the Chess game.
 High reliability: AI machines are highly reliable and can perform the same action
multiple times with high accuracy.
 Useful for risky areas: AI machines can be helpful in situations such as defusing a
bomb, exploring the ocean floor, where to employ a human can be risky.
 Digital Assistant: AI can be very useful to provide digital assistant to the users such
as AI technology is currently used by various E-commerce websites to show the
products as per customer requirement.
 Useful as a public utility: AI can be very useful for public utilities such as a self-
driving car which can make our journey safer and hassle-free, facial recognition for
security purpose, Natural language processing to communicate with the human in
human-language, etc.

Page 7
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

1.3.4 Disadvantages of Artificial Intelligence


Every technology has some disadvantages, and the same goes for Artificial
intelligence. Being so advantageous technology still, it has some disadvantages which we
need to keep in our mind while creating an AI system. Following are the disadvantages of AI:
 High Cost: The hardware and software requirement of AI is very costly as it requires
lots of maintenance to meet current world requirements.
 Can't think out of the box: Even we are making smarter machines with AI, but still
they cannot work out of the box, as the robot will only do that work for which they
are trained, or programmed.
 No feelings and emotions: AI machines can be an outstanding performer, but still it
does not have the feeling so it cannot make any kind of emotional attachment with
human, and may sometime be harmful for users if the proper care is not taken.
 Increase dependency on machines: With the increment of technology, people are
getting more dependent on devices and hence they are losing their mental capabilities.
 No Original Creativity: As humans are so creative and can imagine some new ideas
but still AI machines cannot beat this power of human intelligence and cannot be
creative and imaginative.

Page 8
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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

ARTIFICIAL INTELLIGENCE UNIT I

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

ARTIFICIAL INTELLIGENCE UNIT I

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

ARTIFICIAL INTELLIGENCE UNIT I

1.4.1 Maturation of Artificial Intelligence (1943-1952)

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

1.4.2 .2 The birth of Artificial Intelligence (1952-1956)

 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

ARTIFICIAL INTELLIGENCE UNIT I

scientist at the Dartmouth Conference. For the first time, AI coined as


an academic field. At that time high-level computer languages such as FORTRAN,
LISP, or COBOL were invented. And the enthusiasm for AI was very high at that
time.

1.4.3 .3 The golden years-Early enthusiasm (1956-1974)

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

1.4.4 .4 The first AI winter (1974-1980)

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

1.4.6 second AI winter (1987-1993)

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

1.4.7 .7 The emergence of intelligent agents (1993-2011)

 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

ARTIFICIAL INTELLIGENCE UNIT I

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

1.4.9 Future of artificial intelligence


Autonomous Transportation:
In future, enhanced automated transportation the technology will evolve and we will see
in our roads replicas from Back to the Future, where transportations like public buses, cabs,
and even private vehicles will go driverless and on autopilot. With more precision, smart
vehicles will take over the roads and pave way for safer, faster and economical transport
systems.

Robots into Risky Jobs:


Today, some of the most dangerous jobs are done by humans. Right from cleaning

Page
14
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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

ARTIFICIAL INTELLIGENCE UNIT I

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

ARTIFICIAL INTELLIGENCE UNIT I

1.6 INTELLIGENT AGENTS

An intelligent agent is an autonomous entity which acts 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:
 Rule 1: An AI agent must have the ability to perceive the environment.
 Rule 2: The observation must be used to make decisions.
 Rule 3: Decision should result in an action.
 Rule 4: The action taken by an AI agent must be a rational action.

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.


Page
17
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

1.6.1 Structure of an AI Agent

The task of AI is to design an agent program which implements the agent function.
The structure of an intelligent agent is a combination of architecture and agent program. It can
be viewed as:
Agent = Architecture + Agent program
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

used to map a percept to an action.

F : P* → A

Agent program: Agent program is an implementation of agent function. An agent


program executes on the physical architecture to produce function F.

1.6.2 PEAS Representation


PEAS is a type of model on which an AI agent works upon. When we define an AI agent
or rational agent, then we can group its properties under PEAS representation model. It is
made up of four words:
 P: Performance measure
 E: Environment

Page
18
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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

Example of Agents with their PEAS representation

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

ARTIFICIAL INTELLIGENCE UNIT I

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

Problem Solving Agents in Artificial Intelligence


Are you curious to know how machines can solve complex problems, just like humans? Enter the
world of artificial intelligence and meet one of its most critical players- the Problem-Solving
Agent. Problem-solving in artificial intelligence can be quite complex, requiring the use of
multiple algorithms and data structures. One critical player is the Problem-Solving Agent, which
helps machines find solutions to problems. In this lecture, we’ll explore what a problem-solving
agent is, how it works in AI systems and some exciting real-world applications that showcase its
potential.

What is Problem Solving Agent?

Problem-solving in artificial intelligence is the process of finding a solution to a problem. There


are many different types of problems that can be solved, and the methods used will depend on the
specific problem. The most common type of problem is finding a solution to a maze or navigation
puzzle.

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.

There are three main steps in problem-solving in artificial intelligence:


Page
20
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Types of Problem-Solving Agents

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.

2. Problem Formulation: It is one of the fundamental steps in problem-solving that


determines what action should be taken to reach the goal.

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

ARTIFICIAL INTELLIGENCE UNIT I

Components to formulate the associated problem:


1. Initial State

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.

Transition Model (Successor function)

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

ARTIFICIAL INTELLIGENCE UNIT I

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

1. Standardized/ Toy Problem: Its purpose is to demonstrate or practice various problem


solving techniques. It can be described concisely and precisely, making it appropriate as a
benchmark for academics to compare the performance of algorithms.

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.

Some Standardized/Toy Problems

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:

Vacuum World Problem


Page
23
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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 Strategies: Introduction

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

ARTIFICIAL INTELLIGENCE UNIT I

blindly and a brute force algorithm is a simple, comprehensive search strategy that systematically
explores every option until a problem’s answer is discovered.

Examples of uninformed search algorithms

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.

Informed Search Algorithms

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Why do we need heuristics?

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.

Best First Search Algorithm in AI:

Page
26
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

If we consider searching as a form of traversal in a graph, an uninformed search algorithm would


blindly traverse to the next node in a given manner without considering the cost associated with that
step. An informed search, like BFS, on the other hand, would use an evaluation function to decide
which among the various available nodes is the most promising (or ‘BEST’) before traversing to
that node.

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

ARTIFICIAL INTELLIGENCE UNIT I

A Star (A*) Search Algorithm

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.

 f : it is the sum of g and h. So, f = g + h

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

ARTIFICIAL INTELLIGENCE UNIT I

AO* algorithm – Artificial intelligence

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Working of AO* algorithm:

The evaluation function in AO* looks like this:


f(n) = g(n) + h(n)
Page
30
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

f(n) = Actual cost + Estimated cost


here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal state.

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.

Example:

Page
31
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

AO* Algorithm – Question tree

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

ARTIFICIAL INTELLIGENCE UNIT I

AO* Algorithm (Step-1)

With help of f(n) = g(n) + h(n) evaluation function,

Start from node A,

f(A⇢B) = g(B) + h(B)

=1 + 5 ……here g(n)=1 is taken by default for path cost

=6

f(A⇢C+D) = g(c) + h(c) + g(d) + h(d)

=1+2+1+4=8 ……here we have added C & D because they are in AND

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

ARTIFICIAL INTELLIGENCE UNIT I

AO* Algorithm (Step-2)

According to the answer of step 1, explore node B

Here the value of E & F are calculated as follows,

f(B⇢E) = g(e) + h(e)

f(B⇢E) = 1 + 7= 8

f(B⇢f) = g(f) + h(f)

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

ARTIFICIAL INTELLIGENCE UNIT I

Therefore, the heuristic for A must be updated due to the change in B's heuristic.

So we need to calculate it again.

f(A⇢B) = g(B) + updated h(B)

=1+8

=9

We have updated all values in the above tree.

Step 3

AO* Algorithm (Step-3) -Geeksforgeeks

By comparing f(A⇢B) & f(A⇢C+D)

f(A⇢C+D) is shown to be smaller. i.e 8 < 9

Now explore f(A⇢C+D)

So, the current node is C


Page
35
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

f(C⇢G) = g(g) + h(g)

f(C⇢G) = 1 + 3

=4

f(C⇢H+I) = g(h) + h(h) + g(i) + h(i)

f(C⇢H+I) = 1 + 0 + 1 + 0 ……here we have added H & I because they are in AND

=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,

but Path A⇢D needs to be calculated because it has an AND.

f(D⇢J) = g(j) + h(j)

f(D⇢J) = 1 + 0

=1

the heuristic of node D needs to be updated to 1.

f(A⇢C+D) = g(c) + h(c) + g(d) + h(d)

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

In the above tree diagram, we have updated all the values.

Page
36
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

The Various Types Of Uninformed Search Algorithms

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.

Here are the steps for performing BFS in a search space:

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.

We use the queue data structure to implement BFS.

 Add the initial state to a queue.


 While the queue is not empty, dequeue the first node.
 If the node is the goal state, return it.
 If the node is not the goal state, add all its neighbors to the end of the queue.
 Repeat steps 2-4 until the goal state is found or the queue is empty.

Advantages

Page
37
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Time and Space Complexity

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

ARTIFICIAL INTELLIGENCE UNIT I


/ \
B C
/ \
D E

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

ARTIFICIAL INTELLIGENCE UNIT I

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 is a recursive algorithm that follows the following steps:

 Mark the starting node as visited.


 Explore all adjacent nodes that have not been visited.
 For each unvisited adjacent node, repeat steps 1 and 2 recursively.
 Backtrack if all adjacent nodes have been visited or there are no unvisited nodes.
 DFS can be implemented using a stack data structure or recursion. The recursive implementation is
simpler to understand but can cause a stack overflow if the graph or tree is too large.

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

 Can get stuck in infinite loops:


DFS can get stuck in an infinite loop if there are cycles in the graph or tree. This can be avoided by
keeping track of visited nodes.
 May not find the optimal solution:
DFS only sometimes finds the shortest path to a solution. It may find a suboptimal path before
finding the shortest one.
 Can take a long time:
In some cases, DFS may take a long time to find a solution, especially if the solution is located far
from the starting node.

Page
40
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

Example
Traversing a binary tree

Consider the following 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.

1 -> 2 -> 4 -> 5 -> 3 -> 6 -> 7

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 Algorithm:

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

ARTIFICIAL INTELLIGENCE UNIT I

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:

The shortest path here is A−>B−>C−>E forming the cost 17.

Advantages:

o Uniform cost search is optimal because at every state the path with the least cost is chosen.

Page
42
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Introduction to Depth Limited Search

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.

1. The start node or node 1 is added to the beginning of the stack.

2. Then it is marked as visited, and if node 1 is not the goal node in the search,

then we push second node 2 on top of the stack.

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

the goal nodes.

6. If Node 4 is also not found to be the goal node and depth limit is found to be

reached, then we retrace back to nearest nodes that remain unvisited or

unexplored.

Page
43
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Depth-limited search is found to terminate under these two clauses:

1. When the goal node is found to exist.

2. When there is no solution within the given depth limit domain.

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
Page
44
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

knowledge representation and reasoning. Hence we can describe Knowledge


representation as following:

o Knowledge representation and reasoning (KR, KRR) is the part of Artificial


intelligence which concerned with AI agents thinking and how thinking
contributes to intelligent behavior of agents.
o It is responsible for representing information about the real world so that a
computer can understand and can utilize this knowledge to solve the complex
real world problems such as diagnosis a medical condition or communicating
with humans in natural language.
o It is also a way which describes how we can represent knowledge in artificial
intelligence. Knowledge representation is not just storing data into some
database, but it also enables an intelligent machine to learn from that
knowledge and experiences so that it can behave intelligently like a human.

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

Knowledge: Knowledge is awareness or familiarity gained by experiences of facts,


data, and situations. Following are the types of knowledge in artificial intelligence:

Types of knowledge
Following are the various types of knowledge:

Page
45
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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 declarative sentences.
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 Meta-knowledge is another important knowledge type, as it provides


knowledge about other types of knowledge that are suitable for problem-
solving. Moreover, it helps enhance the efficiency of solving a problem through
the proper reasoning process.

4. Heuristic knowledge:
Page
46
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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 Based on thumb rule, Heuristic Knowledge or Shallow Knowledge provides


information based on the strategies, compiled by experts, to solve the
problems through the experience of past problems. Moreover, it is useful in
guiding the reasoning process.

The relation between knowledge and intelligence:


Knowledge of real-worlds plays a vital role in intelligence and same for creating
artificial intelligence. Knowledge plays an important role in demonstrating intelligent
behavior in AI agents. An agent is only able to accurately act on some input when he
has some knowledge or experience about that input.

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Approaches to knowledge representation:

Page
48
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

There are mainly four approaches to knowledge representation, which are given
below:

1. Simple relational knowledge:

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.

Example: The following is the simple relational knowledge representation.

Player Weight Age

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

ARTIFICIAL INTELLIGENCE UNIT I

3. Inferential knowledge:

o Inferential knowledge approach represents knowledge in the form of formal


logics.
o This approach can be used to derive more facts.
o It guaranteed correctness.
o Example: Let's suppose there are two statements:

a. Marcus is a man
b. All men are mortal

Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s

4. Procedural knowledge:

o Procedural knowledge approach uses small programs and codes which


describes how to do specific things, and how to proceed.
o In this approach, one important rule is used which is If-Then rule.

Page
50
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

o In this knowledge, we can use various coding languages such as LISP


language and Prolog language.
o We can easily represent heuristic or domain-specific knowledge using this
approach.
o But it is not necessary that we can represent all cases in this approach.

Requirements for knowledge Representation system:


A good knowledge representation system must possess the following properties.

Page
51
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

Techniques 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

Page
52
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

o It determines which symbol we can use in knowledge representation.

o How to write those symbols.

Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.

o Semantic also involves assigning a meaning to each sentence.

Logical representation can be categorized into mainly two logics:

Page
53
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

a) Propositional Logics
b) Predicate logics

Note: We will discuss Prepositional Logics and Predicate logics in later chapters.

Advantages of logical representation:

1. Logical representation enables us to do logical reasoning.


2. Logical representation is the basis for the programming languages.

Disadvantages of logical Representation:

1. Logical representations have some restrictions and are challenging to work


with.
2. Logical representation technique may not be very natural, and inference may
not be so efficient.

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.

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.

This representation consist of mainly two types of relations:

a. IS-A relation (Inheritance)


b. Kind-of-relation

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

ARTIFICIAL INTELLIGENCE UNIT I

c) Jerry is owned by Priya.


d) Jerry is brown colored.
e) All Mammals are animal.

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.

Drawbacks in Semantic representation:

1. Semantic networks take more computational time at runtime as we need to


traverse the complete network tree to answer some questions. It might be
possible in the worst case scenario that after traversing the entire tree, we find
that the solution does not exist in this network.
2. Semantic networks try to model human-like memory (Which has 1015 neurons
and links) to store the information, but in practice, it is not possible to build
such a vast semantic network.
3. These types of representations are inadequate as they do not have any
equivalent quantifier, e.g., for all, for some, none, etc.
4. Semantic networks do not have any standard definition for the link names.
5. These networks are not intelligent and depend on the creator of the system.

Advantages of Semantic network:

1. Semantic networks are a natural representation of knowledge.


2. Semantic networks convey meaning in a transparent manner.
Page
55
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

3. These networks are simple and easily understandable.

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

Title Artificial Intelligence

Genre Computer Science

Author Peter Norvig

Edition Third Edition

Year 1996

Page 1152

Page
56
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

Let's take an example of a frame for a book

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

Marital status Single

Weight 78

Advantages of frame representation:

1. The frame knowledge representation makes the programming easier by


grouping the related data.
2. The frame representation is comparably flexible and used by many applications
in AI.
3. It is very easy to add slots for new attribute and relations.
4. It is easy to include default data and to search for missing values.
5. Frame representation is easy to understand and visualize.

Disadvantages of frame representation:

1. In frame system inference mechanism is not be easily processed.


2. Inference mechanism cannot be smoothly proceeded by frame representation.
3. Frame representation has a much generalized approach.

4. Production Rules

Page
57
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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

o The set of production rules


o Working Memory
o The recognize-act-cycle

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

Advantages of Production rule:

1. The production rules are expressed in natural language.


2. The production rules are highly modular, so we can easily remove, add or
modify an individual rule.

Disadvantages of Production rule:

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

ARTIFICIAL INTELLIGENCE UNIT I

2. During the execution of the program, many rules may be active hence rule-
based production systems are inefficient.

Propositional logic in Artificial intelligence


Propositional logic (PL) is the simplest form of logic where all the statements are
made by propositions. A proposition is a declarative statement which is either true or
false. It is a technique of knowledge representation in logical and mathematical form.

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.

Following are some basic facts about propositional logic:

o Propositional logic is also called Boolean logic as it works on 0 and 1.


o In propositional logic, we use symbolic variables to represent the logic, and we
can use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
o Propositions can be either true or false, but it cannot be both.
o Propositional logic consists of an object, relations or function, and logical
connectives.
o These connectives are also called logical operators.
o The propositions and connectives are the basic elements of the propositional
logic.
o Connectives can be said as a logical operator which connects two sentences.
o A proposition formula which is always true is called tautology, and it is also
called a valid sentence.
o A proposition formula which is always false is called Contradiction.

Page
59
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

o Statements which are questions, commands, or opinions are not propositions


such as "Where is Rohini", "How are you", "What is your name", are not
propositions.

Syntax of propositional logic:


The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:

1. Atomic Propositions
2. Compound propositions

o Atomic Proposition: Atomic propositions are the simple propositions. It


consists of a single proposition symbol. These are the sentences which must be
either true or false.

Example:

a) 2+2 is 4, it is an atomic proposition as it is a true fact.


b) "The Sun is cold" is also a proposition as it is a false fact.
o Compound proposition: Compound propositions are constructed by
combining simpler or atomic propositions, using parenthesis and logical
connectives.

Example:

1. a) "It is raining today, and street is wet."


2. b) "Ankit is a doctor, and his clinic is in Mumbai."

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:

1. Negation: A sentence such as ¬ P is called negation of P. A literal can be


either Positive literal or negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a
conjunction.

Page
60
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

Example: Rohan is intelligent and hardworking. It can be written as,


P= Rohan is intelligent,

Q= Rohan is hardworking. → P∧ Q.

3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called


disjunction, where P and Q are the propositions.

Example: "Ritika is a doctor or Engineer",

Here P= Ritika is Doctor. Q= Ritika is Engineer, so we can write it as P ∨ Q.

4. Implication: A sentence such as P → Q, is called an implication. Implications


are also known as if-then rules. It can be represented as

If it is raining, then the street is wet.

Let P= It is raining, and Q= Street is wet, so it is represented as P → Q

5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence,


example If I am breathing, then I am alive

P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.

Following is the summarized table for Propositional Logic Connectives:

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

ARTIFICIAL INTELLIGENCE UNIT I

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Fifth Precedence Implication

Six Precedence Biconditional

¬R∨ Q, It can be interpreted as (¬R) ∨ Q.


Note: For better understanding use parenthesis to make sure of the correct interpretations. Such as

Limitations of Propositional logic:

o We cannot represent relations like ALL, some, or none with propositional logic.
Example:

a. All the girls are intelligent.


b. Some apples are sweet.
o Propositional logic has limited expressive power.
o In propositional logic, we cannot describe statements in terms of their
properties or logical relationships.

First-Order Logic in Artificial intelligence


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.
Page
62
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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, colors, wars, theories, squares, pits,


wumpus, ......

o Relations: It can be unary relation such as: red, round, is


adjacent, or n-any relation such as: the sister of, brother of, has color,
comes between

o Function: Father of, best friend, third inning of, end of, ......

o As a natural language, first-order logic also has two main parts:

a. Syntax

b. 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:


Page
63
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Page
64
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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:

a) Universal Quantifier, (for all, everyone, everything)


b) 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:
Page
65
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.
Page
66
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

∃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)."

∀x bird(x) →fly(x).
And since there are all birds who fly so it will be represented as follows.

2. Every man respects his parent.

Page
67
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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)].

Page
68
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

What is Machine Learning?


In the real world, we are surrounded by humans who can learn everything from their
experiences with their learning capability, and we have computers or machines
which
work on our instructions. But can a machine also learn from experiences or past data
like
a human does? So here comes the role of Machine Learning.

Introduction to Machine Learning


Page
69
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

A subset of artificial intelligence known as machine learning focuses primarily on the


creation of algorithms that enable a computer to independently learn from data and
previous experiences. Arthur Samuel first used the term "machine learning" in 1959. It
could be summarized as follows:
Without being explicitly programmed, machine learning enables a machine to
automatically learn from data, improve performance from experiences, and predict things.
Machine learning algorithms create a mathematical model that, without being explicitly
programmed, aids in making predictions or decisions with the assistance of sample
historical data, or training data. For the purpose of developing predictive models, machine
learning brings together statistics and computer science. Algorithms that learn from
historical data are either constructed or utilized in machine learning.
A machine can learn if it can gain more data to improve its performance.

How does Machine Learning work


A machine learning system builds prediction models, learns from previous data, and
predicts the output of new data whenever it receives it. The amount of data helps to build
a better model that accurately predicts the output, which in turn affects the accuracy of
the predicted output.
Let's say we have a complex problem in which we need to make predictions. Instead of
writing code, we just need to feed the data to generic algorithms, which build the logic
based on the data and predict the output. Our perspective on the issue has changed as a
result of machine learning. The Machine Learning algorithm's operation is depicted in the
following block diagram:
Difference between Machine Learning and Traditional Programming
The Difference between Machine Learning and Traditional Programming is as
follows:
Machine Traditional Artificial
Learning Programming Intelligence
Machine Learning is a In traditional Artificial Intelligence
subset of artificial programming, rule- involves making the
intelligence(AI) that based machine as much
focus code is written by the capable,
on learning from data developers depending So that it can perform
to on the
develop an algorithm the problem tasks that typically
that statements. require
can be used to make a human intelligence.
Page
70
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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:

The lifecycle of a machine learning project involves a series of steps that


include:
1. Study the Problems: The first step is to study the problem. This step
involves
understanding the business problem and defining the objectives of the model.
2. Data Collection: When the problem is well-defined, we can collect the
relevant data
required for the model. The data could come from various sources such as
databases,
APIs, or web scraping.

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

ARTIFICIAL INTELLIGENCE UNIT I

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

2. In the case of deep learning, we have to define layer-wise architecture along


with input and output size, number of nodes in each layer, loss function, gradient
descent optimizer, etc.

3. After that model is trained using the preprocessed dataset.

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

ARTIFICIAL INTELLIGENCE UNIT I

Various Applications of Machine Learning

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.

. Finance Industry: Machine learning is growing in popularity in the finance


industry.
Banks are mainly using ML to find patterns inside the data but also to prevent fraud.
• Government organization: The government makes use of ML to manage public
safety and utilities. Take the example of China with its massive face recognition. The
government uses Artificial intelligence to prevent jaywalking.

• Healthcare industry: Healthcare was one of the first industries to use machine
learning with image detection.

• Marketing: Broad use of AI is done in marketing thanks to abundant access to


data.
Before the age of mass data, researchers develop advanced mathematical tools like
Bayesian analysis to estimate the value of a customer. With the boom of data, the
marketing department relies on AI to optimize customer relationships and marketing
campaigns.
• Retail industry: Machine learning is used in the retail industry to analyze
customer
behavior, predict demand, and manage inventory. It also helps retailers to
personalize
the shopping experience for each customer by recommending products based on
their
past purchases and preferences.

• Transportation: Machine learning is used in the transportation industry to


optimize
routes, reduce fuel consumption, and improve the overall efficiency of transportation
systems. It also plays a role in autonomous vehicles, where ML algorithms are used

Page
73
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

to
make decisions about navigation and safety.

Classification of Machine Learning

At a broad level, machine learning can be classified into three types:

1. Supervised learning

2. Unsupervised learning

3. Reinforcement learning

Supervised Machine Learning


Supervised learning is the types of machine learning in which machines are trained using well "labelled"
training data, and on basis of that data, machines predict the output. The labelled data means some input
data is already tagged with the correct output.

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.

How Supervised Learning Works?


In supervised learning, models are trained using labelled dataset, where the model learns about each type of
data. Once the training process is completed, the model is tested on the basis of test data (a subset of the
training set), and then it predicts the output.
Page
74
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Steps Involved in Supervised Learning:


o First Determine the type of training dataset

o Collect/Gather the labelled training data.

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Types of supervised Machine learning Algorithms:


Supervised learning can be further divided into two types of problems:

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 Bayesian 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

ARTIFICIAL INTELLIGENCE UNIT I

o Support vector Machines

Note: We will discuss these algorithms in detail in later chapters.

Advantages of Supervised learning:

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.

Disadvantages of supervised learning:

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.

o In supervised learning, we need enough knowledge about the classes of object.

Unsupervised Machine Learning

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.

What is Unsupervised Learning?

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Why use Unsupervised Learning?


Below are some main reasons which describe the importance of Unsupervised Learning:

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.

Working of Unsupervised Learning

Working of unsupervised learning can be understood by the below diagram:

Page
78
lOMoAR cPSD| 31245499

ARTIFICIAL INTELLIGENCE UNIT I

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.

Types of Unsupervised Learning Algorithm:

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

ARTIFICIAL INTELLIGENCE UNIT I

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.

Note: We will learn these algorithms in later chapters.

Unsupervised Learning algorithms:

Below is the list of some popular unsupervised learning algorithms:

o K-means clustering

o KNN (k-nearest neighbors)

o Hierarchal clustering

o Anomaly detection

o Neural Networks

o Principle Component Analysis

o Independent Component Analysis

o Apriori algorithm

o Singular value decomposition

Advantages of Unsupervised Learning

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.

Disadvantages of Unsupervised Learning

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

ARTIFICIAL INTELLIGENCE UNIT I

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

You might also like