AI Notes
AI Notes
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.
o Year 1972: The first intelligent humanoid robot was built in Japan which was named as WABOT-
1.
A boom of AI (1980-1987)
o Year 1980: After AI winter duration, AI came back with "Expert System". Expert systems were programmed
o In the Year 1980, the first national conference of the American Association of Artificial Intelligence was
o 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.
o Year 2002: for the first time, AI entered the home in the form of Roomba, a vacuum cleaner.
o Year 2006: AI came in the Business world till the year 2006. Companies like Facebook, Twitter, and Netflix
questions as well as riddles. Watson had proved that it could understand natural language and can solve
o Year 2012: Google has launched an Android app feature "Google now", which was able to provide
o Year 2014: In the year 2014, Chatbot "Eugene Goostman" won a competition in the infamous "Turing
test."
o Year 2018: The "Project Debater" from IBM debated on complex topics with two master debaters and
o 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.
Types of Agents
Agents can be grouped into five classes based on their degree of perceived
intelligence and capability :
Simple Reflex Agents
Model-Based Reflex Agents
Goal-Based Agents
Utility-Based Agents
Learning Agent
Simple reflex agents
Simple reflex agents ignore the rest of the percept history and act only on the
basis of the current percept. Percept history is the history of all that an agent
has perceived to date. The agent function is based on the condition-action
rule.
Goal-based agents
These kinds of agents take decisions based on how far they are currently from
their goal (description of desirable situations).
Utility-based agents
The agents which are developed having their end uses as building blocks are
called utility-based agents
Learning Agent:
A learning agent in AI is the type of agent that can learn from its past
experiences, or it has learning capabilities. It starts to act with basic knowledge
and then can act and adapt automatically through learning.
Structure of an AI Agent
1. Agent = Architecture + Agent program
PEAS Representation
PEAS is a type of model on which an AI agent works upon.
o P: Performance measure
o E: Environment
o A: Actuators
o S: Sensors
Agent Environment in AI
An environment is everything in the world which surrounds the agent, but it is not a
part of an agent itself. An environment can be described as a situation in which an
agent is present.
Features of Environment
As per Russell and Norvig, an environment can have various features from the point of
view of an agent:
1. Fully observable vs Partially Observable
2. Static vs Dynamic
3. Discrete vs Continuous
4. Deterministic vs Stochastic
5. Single-agent vs multi-agent
6. Episodic vs sequential
7. Known vs Unknown
8. Accessible vs Inaccessible
Deterministic vs Stochastic:
o If an agent's current state and selected action can completely determine the next
state of the environment, then such environment is called a deterministic
environment.
o A stochastic environment is random in nature and cannot be determined completely
by an agent.
Episodic vs Sequential:
o In an episodic environment, there is a series of one-shot actions, and only the current
percept is required for the action.
o However, in Sequential environment, an agent requires memory of past actions to
determine the next best actions.
Single-agent vs Multi-agent
o If only one agent is involved in an environment and operating by itself then such
an environment is called single agent environment.
o However, if multiple agents are operating in an environment, then such an environment
is called a multi-agent environment.
Static vs Dynamic:
o If the environment can change itself while an agent is deliberating then such
environment is called a dynamic environment else it is called a static environment.
Discrete vs Continuous:
o If in an environment there are a finite number of percepts and actions that can be
performed within it, then such an environment is called a discrete environment else it
is called continuous environment.
Known vs Unknown
o Known and unknown are not actually a feature of an environment, but it is an agent's
state of knowledge to perform an action.
Accessible vs Inaccessible
o If an agent can obtain complete and accurate information about the state's
environment, then such an environment is called an Accessible environment else it is
called inaccessible.
G= (V , E)
Definition Tree is a non-linear data structure in A Graph is also a non-linear data structure.
which elements are arranged in
multiple levels.
Structure It is a collection of edges and nodes. It is a collection of vertices and edges. For example
For example, node is represented by and edge is represented as 'E', so
N and edge is represented as E, so it T = {V, E}
can be written as:
T = {N,E}
Root node In tree data structure, there is a In graph data structure, there is no unique node.
unique node known as a parent node.
It represents the topmost node in the
tree data structure.
Loop formation It does not create any loop or cycle. In graph, loop or cycle can be formed.
Model type It is a hierarchical model because It is a network model. For example, facebook is a soc
nodes are arranged in multiple level, data structure.
and that creates a hierarchy. For
example, any organization will have a
hierarchical model.
Edges If there are n nodes then there would The number of edges depends on the graph.
be n-1 number of edges.
Type of edge Tree data structure will always have In graph data structure, all the edges can either be dir
directed edges. or both.
Applications It is used for inserting, deleting or It is mainly used for finding the shortest path in the n
searching any element in tree.
There are two types of edges:
Directed edge: .
Undirected edge:
Directed graph: The graph with the directed edges known as a directed graph.
Undirected graph: The graph with the undirected edges known as a undirected graph.
Artificial Intelligence is the study of building agents that act rationally. Most
of the time, these agents perform some kind of search algorithm in the
background in order to achieve their tasks.
Greedy Search:
In greedy search, we expand the node closest to the goal node. The
“closeness” is estimated by a heuristic h(x).
Question. Find the path from S to G using greedy search. The heuristic values
h of each node below the name of the node.
Solution. Starting from S, we can traverse to A(h=9) or D(h=5). We choose
D, as it has the lower heuristic cost. Now from D, we can move to B(h=4) or
E(h=3). We choose E with a lower heuristic cost. Finally, from E, we go to
G(h=0). This entire traversal is shown in the search tree below, in blue.
A* Tree Search:
A* Tree Search, or simply known as A* Search, combines the strengths of
uniform-cost search and greedy search. In this search, the heuristic is the
summation of the cost in UCS, denoted by g(x), and the cost in the greedy
search, denoted by h(x). The summed cost is denoted by f(x).
Heuristic: The following points should be noted wrt heuristics in A*
search.
Here, h(x) is called the forward cost and is an estimate of the
distance of the current node from the goal node.
And g(x) is called the backward cost and is the cumulative cost of a
node from the root node.
Example:
Question. Find the path to reach from S to G using A* search.
Random Search.pdf
Here h(n) is heuristic cost, and h*(n) is the estimated cost. Hence heuristic cost
should be less than or equal to the estimated cost.
On each iteration, each node n with the lowest heuristic value is expanded and
generates all its successors and n is placed to the closed list. The algorithm continues
unit a goal state is found.
Imperfect information Battleships, blind, tic-tac-toe Bridge, poker, scrabble, nuclear war
o Perfect information: A game with the perfect information is that in which agents can
investigate the complete board. Agents have all the information about the game,
and they can see each other moves also. Examples are Chess, Checkers, Go, etc.
o Imperfect information: If in a game agent do not have all information about the
game and not aware with what's going on, such type of games is called the game
with imperfect information, such as tic-tac-toe, Battleship, blind, Bridge, etc.
o Deterministic games: Deterministic games are those games which follow a strict
pattern and set of rules for the games, and there is no randomness associated with
them. Examples are chess, Checkers, Go, tic-tac-toe, etc.
o Non-deterministic games: non-deterministic are those games which have various
unpredictable events and has a factor of chance or luck. This factor of chance or
luck is introduced by either dice or cards. These are random, and each action response
is not fixed. Such games are also called as stochastic games.
Example: Backgammon, Monopoly, Poker, etc.
Note: In this topic, we will discuss deterministic games, fully observable
environment, zero-sum, and where each agent acts alternatively.
Zero-Sum Game
o Zero-sum games are adversarial search which involves pure competition.
o In Zero-sum game each agent's gain or loss of utility is exactly balanced by the
losses or gains of utility of another agent.
o One player of the game tries to maximize one single value, while another player
tries to minimize it.
o Each move by one player in the game is called as ply.
o Chess and tic-tac-toe are examples of a Zero-sum game.
Zero-sum game: Embedded thinking
The Zero-sum game involved embedded thinking in which one agent or player is
trying to figure out:
o What to do.
o How to decide the move
o Needs to think about his opponent as well
o The opponent also thinks what to do
Each of the players is trying to find out the response of his opponent to their
actions. This requires embedded thinking or backward reasoning to solve the game
problems in AI.
Formalization of the problem:
A game can be defined as a type of search in AI which can be formalized of the
following elements:
57.3M
1.2K
Features of Java - Javatpoint
Unit 3
Definition
The probability of occurrence of any event A when another event B in relation to A has already
occurred is known as conditional probability. It is depicted by P(A|B).
As depicted by the above diagram, sample space is given by S, and there are two events A and B.
In a situation where event B has already occurred, then our sample space S naturally gets
reduced to B because now the chances of occurrence of an event will lie inside B.
As we must figure out the chances of occurrence of event A, only a portion common to both A
and B is enough to represent the probability of occurrence of A, when B has already occurred.
The common portion of the events is depicted by the intersection of both the events A and B, i.e.
A ∩ B.
This explains the concept of conditional probability problems, i.e., occurrence of any event when
another event in relation to has already occurred.
Formula
When the intersection of two events happen, then the formula for conditional probability for the
occurrence of two events is given by;
P(A|B) = N(A∩B)/N(B)
Or
P(B|A) = N(A∩B)/N(A)
Where P(A|B) represents the probability of occurrence of A given B has occurred.
N (A ∩ B) is the number of elements common to both A and B.
N(B) is the number of elements in B, and it cannot be equal to zero.
Let N represent the total number of elements in the sample space.
Question 1:
The probability that it is Friday and that a student is absent is 0.03. Since there are 5 school days
in a week, the probability that it is Friday is 0.2. What is the probability that a student is absent
given that today is Friday?
Solution:
The formula of Conditional probability Formula is:
P (B|A) = P (A ∩ B) ⁄P(A)
P (Absent | Friday) = P (Absent and Friday)⁄P(Friday)
= 0.03/0.2
= 0.15
= 15 %
Question: A bag contains 3 black and 5 white balls. Draw the probability tree diagram for two
draws.
Solution: Given:
No. of black balls = 3
No. of white balls = 5
Total Number of balls = 8
So, the probability of getting black balls = 3/8
The probability of getting white balls = 5/8
Therefore, the tree diagram for two draws of balls with possible outcomes and probability is
given as below.
Conditional Probability and Bayes Theorem
Bayes’ theorem defines the probability of occurrence of an event associated with any condition.
It is considered for the case of conditional probability. Also, this is known as the formula for the
likelihood of “causes”.
Properties
Property 1: Let E and F be events of a sample space S of an experiment, then we have:
P(S|F) = P(F|F) = 1.
Property 2: If A and B are any two events of a sample space S and F is an event of S such that
P(F) ≠ 0, then.
P((A ∪ B)|F) = P(A|F) + P(B|F) – P((A ∩ B)|F)
Property 3: P(A′|B) = 1 − P(A|B)
Bayesian networks are probabilistic, because these networks are built from
a probability distribution, and also use probability theory for prediction and anomaly
detection.
Real world applications are probabilistic in nature, and to represent the relationship
between multiple events, we need a Bayesian network. It can also be used in various
tasks including prediction, anomaly detection, diagnostics, automated insight,
reasoning, time series prediction, and decision making under uncertainty.
Bayesian Network can be used for building models from data and experts opinions,
and it consists of two parts:
o Directed Acyclic Graph
o Table of conditional probabilities.
The generalized form of Bayesian network that represents and solve decision problems
under uncertain knowledge is known as an Influence diagram.
A Bayesian network graph is made up of nodes and Arcs (directed links), where:
P[x1, x2, x3,....., xn], it can be written as the following way in terms of the joint
probability distribution.
In general, for each variable Xi, we can write the equation as:
P(Xi|Xi-1,........., X1) = P(Xi |Parents(Xi ))
Bayesian
Network.pdf
Example: Harry installed a new burglar alarm at his home to detect burglary. The alarm reliably
responds at detecting a burglary but also responds for minor earthquakes. Harry has two
neighbors David and Sophia, who have taken a responsibility to inform Harry at work when
they hear the alarm. David always calls Harry when he hears the alarm, but sometimes he got
confused with the phone ringing and calls at that time too. On the other hand, Sophia likes to
listen to high music, so sometimes she misses to hear the alarm. Here we would like to
compute the probability of Burglary Alarm.
We can write the events of problem statement in the form of probability: P[D, S, A, B,
E], can rewrite the above probability statement using joint probability distribution:
P(E= False)= 0.999, Which is the probability that an earthquake not occurred.
The Conditional probability of Sophia that she calls is depending on its Parent Node
"Alarm."
From the formula of joint distribution, we can write the problem statement in the form
of probability distribution:
= 0.00068045.
Hence, a Bayesian network can answer any query about the domain by using
Joint distribution.
Inference rules:
Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.
In inference rules, the implication among all the connectives plays an important role.
Following are some terminologies related to inference rules:
o Implication: It is one of the logical connectives which can be represented as P → Q. It
is a Boolean expression.
o Converse: The converse of implication, which means the right-hand side proposition
goes to the left-hand side and vice-versa. It can be written as Q → P.
o Contrapositive: The negation of converse is termed as contrapositive, and it can be
represented as ¬ Q → ¬ P.
o Inverse: The negation of implication is called inverse. It can be represented as ¬ P →
¬ Q.
From the above term some of the compound statements are equivalent to each other,
which we can prove using truth table:
Hence from the above truth table, we can prove that P → Q is equivalent to ¬ Q → ¬
P, and Q→ P is equivalent to ¬ P → ¬ Q.
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and
Q→R is true. It can be represented as the following notation:
Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
Example:
Proof by truth-table:
5. Addition:
The Addition rule is one the common inference rule, and it states that If P is true, then
P∨Q will be true.
Example:
AD
Proof by Truth-Table:
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will also be true. It can be
represented as:
Proof by Truth-Table:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be true. It
can be represented as
Proof by Truth-Table:
Hidden Markov Model (HMM)
When we can not observe the state themselves but only the result of
some probability function(observation) of the states we utilize HMM.
HMM is a statistical Markov model in which the system being
modeled is assumed to be a Markov process with unobserved
(hidden) states.
Assumptions of HMM
HMM too is built upon several assumptions and the following is vital.
Eq.5.