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

AI 3rd and 4th Unit Notes

Knowledge-based agents in AI utilize an internal knowledge base and inference system to make decisions and reason about actions. They can represent states, incorporate new percepts, and deduce appropriate actions based on their knowledge. The Wumpus World serves as an example to illustrate how these agents operate within a structured environment, using logical reasoning and various percepts to achieve their goals.

Uploaded by

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

AI 3rd and 4th Unit Notes

Knowledge-based agents in AI utilize an internal knowledge base and inference system to make decisions and reason about actions. They can represent states, incorporate new percepts, and deduce appropriate actions based on their knowledge. The Wumpus World serves as an example to illustrate how these agents operate within a structured environment, using logical reasoning and various percepts to achieve their goals.

Uploaded by

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

Knowledge - Based Agent in AI

An intelligent agent needs knowledge about the real world for taking decisions and reasoning to
act efficiently. Knowledge-based agents are those agents who have the capability of maintaining
an internal state of knowledge, reason over that knowledge, update their knowledge after
observations and take actions. These agents can represent the world with some formal
representation and act intelligently.
Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system.
In Knowledge based agent:
• An agent should be able to represent states, actions, etc.
• An agent Should be able to incorporate new percepts
• An agent can update the internal representation of the world
• An agent can deduce the internal representation of the world
• An agent can deduce appropriate actions.
The architecture of knowledge-based agent:

• The above diagram is representing a generalized architecture for a knowledge-based agent.


• The knowledge-based agent (KBA) take input from the environment by perceiving the
environment.
• The input is taken by the inference engine of the agent and which also communicate with
KB to decide as per the knowledge store in KB.
• The learning element of KBA regularly updates the KB by learning new knowledge.
• Knowledge base: Knowledge-base is a central component of a knowledge-based agent, it
is also known as KB.
• It is a collection of sentences (here 'sentence' is a technical term and it is not identical to
sentence in English).
• These sentences are expressed in a language which is called a knowledge representation
language.
• The Knowledge-base of KBA stores fact about the world.
Why use knowledge base?
• Knowledge-base is required for updating knowledge for an agent to learn with experiences
and take action as per the knowledge
Inference system
• Inference means deriving new sentences from old. Inference system allows us to add a new
sentence to the knowledge base. A sentence is a proposition about the world. Inference
system applies logical rules to the KB to deduce new information.
• Inference system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as:
• Forward chaining
• Backward chaining
Operations Performed by KBA
• Following are three operations which are performed by KBA in order to show the
intelligent behavior:
• TELL: This operation tells the knowledge base what it perceives from the environment.
• ASK: This operation asks the knowledge base what action it should perform.
• Perform: It performs the selected action.
The knowledge-based agent takes percept as input and returns an action as output. The agent
maintains the knowledge base, KB, and it initially has some background knowledge of the real
world. It also has a counter to indicate the time for the whole process, and this counter is initialized
with zero. Each time when the function is called, it performs its three operations:
• Firstly it TELLs the KB what it perceives.
• Secondly, it asks KB what action it should take
• Third agent program TELLS the KB that which action was chosen.
In KB the MAKE-PERCEPT-SENTENCE generates a sentence as setting that the agent perceived
the given percept at the given time. The MAKE-ACTION-QUERY generates a sentence to ask
which action should be done at the current time. MAKE-ACTION-SENTENCE generates a
sentence which asserts that the chosen action was executed.
Various levels of Knowledge based agent:
Knowledge level
• Knowledge level is the first level of knowledge-based agent, and in this level, we need to
specify what the agent knows, and what the agent goals are. With these specifications, we
can fix its behavior.
• For example, suppose an automated taxi agent needs to go from a station A to station B,
and he knows the way from A to B, so this comes at the knowledge level.
Logical level:
• At this level, we understand that how the knowledge representation of knowledge is stored.
• At this level, sentences are encoded into different logics.
• At the logical level, an encoding of knowledge into logical sentences occurs.
• At the logical level we can expect to the automated taxi agent to reach to the destination
B.
Implementation level:
• This is the physical representation of logic and knowledge.
• At the implementation level agent perform actions as per logical and knowledge level.
At this level, an automated taxi agent actually implement his knowledge and logic so that he can
reach to the destination.
Approaches to designing a knowledge-based agent:
There are mainly two approaches to build a knowledge-based agent:
1. Declarative approach: We can create a knowledge-based agent by initializing with an empty
knowledge base and telling the agent all the sentences with which we want to start with. This
approach is called Declarative approach.
2. Procedural approach: In the procedural approach, we directly encode desired behavior as a
program code. Which means we just need to write a program that already encodes the desired
behavior or agent.
In the real world, a successful agent can be built by combining both declarative and procedural
approaches, and declarative knowledge can often be compiled into more efficient procedural code.
Wumpus World:
• The Wumpus world is a simple world example to illustrate the worth of a knowledge-based
agent and to represent knowledge representation.
• It was inspired by a video game Hunt the Wumpus by Gregory Yob in 1973.
• The Wumpus world is a cave which has 4/4 rooms connected with passageways.
• So there are total 16 rooms which are connected with each other.
• We have a knowledge-based agent who will go forward in this world.
• The cave has a room with a beast which is called Wumpus, who eats anyone who enters
the room.
• The Wumpus can be shot by the agent, but the agent has a single arrow.
• In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls
in Pits, then he will be stuck there forever
• The exciting thing with this cave is that in one room there is a possibility of finding a heap
of gold.
• So the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten
by Wumpus.
• The agent will get a reward if he comes out with gold, and he will get a penalty if eaten
by Wumpus or falls in the pit
• The cave has a room with a beast which is called Wumpus, who eats anyone who enters
the room.
• The Wumpus can be shot by the agent, but the agent has a single arrow.
• In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls
in Pits, then he will be stuck there forever
• The exciting thing with this cave is that in one room there is a possibility of finding a heap
of gold.
• So the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten
by Wumpus.
• The agent will get a reward if he comes out with gold, and he will get a penalty if eaten
by Wumpus or falls in the pit
• Following is a sample diagram for representing the Wumpus world.
• It is showing some rooms with Pits, one room with Wumpus and one agent at (1, 1) square
location of the world.

• There are also some components which can help the agent to navigate the cave. These
components are given as follows:
a. The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
b. The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will
perceive the breeze.
c. There will be glitter in the room if and only if the room has gold.
d. The Wumpus can be killed by the agent if the agent is facing to it, and Wumpus will
emit a horrible scream which can be heard anywhere in the cave.
PEAS description of Wumpus world
• To explain the Wumpus world we have given PEAS description as below:
Performance measure:
• +1000 reward points if the agent comes out of the cave with the gold.
• -1000 points penalty for being eaten by the Wumpus or falling into the pit.
• -1 for each action, and -10 for using an arrow.
• The game ends if either agent dies or came out of the cave.
Environment:
• A 4*4 grid of rooms.
• The agent initially in room square [1, 1], facing toward the right.
• Location of Wumpus and gold are chosen randomly except the first square [1,1].
• Each square of the cave can be a pit with probability 0.2 except the first square.
Actuators:
• Left turn,
• Right turn
• Move forward
• Grab
• Release
• Shoot.
Sensors: The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not
diagonally). The agent will perceive breeze if he is in the room directly adjacent to the Pit. The
agent will perceive the glitter in the room where the gold is present. The agent will perceive
the bump if he walks into a wall. When the Wumpus is shot, it emits a horrible scream which can
be perceived anywhere in the cave. These percepts can be represented as five element list, in which
we will have different indicators for each sensor. Example if agent perceives stench, breeze, but
no glitter, no bump, and no scream then it can be represent as
[Stench, Breeze, None, None, None].
The Wumpus world Properties: Partially observable: The Wumpus world is partially observable
because the agent can only perceive the close environment such as an adjacent room.
Deterministic: It is deterministic, as the result and outcome of the world are already known.
Sequential: The order is important, so it is sequential.
Static: It is static as Wumpus and Pits are not moving.
Discrete: The environment is discrete.
One agent: The environment is a single agent as we have one agent only and Wumpus is not
considered as an agent.
Exploring the Wumpus world:
• Now we will explore the Wumpus world and will determine how the agent will find its
goal by applying logical reasoning.
• Agent's First step:
• Initially, the agent is in the first room or on the square [1,1], and we already know that this
room is safe for the agent, so to represent on the below diagram (a) that room is safe we
will add symbol OK.
• Symbol A is used to represent agent, symbol B for the breeze, G for Glitter or gold, V for
the visited room,P for Pits and W for Wumpus
• At Room [1,1] agent does not feel any breeze or any Stench which means the adjacent
squares are also OK.
Agents first Step

Agent’s Second Step:


• Now agent needs to move forward, so it will either move to [1, 2], or [2,1].
• Let's suppose agent moves to the room [2, 1], at this room agent perceives some breeze
which means Pit is around this room.
• The pit can be in [3, 1], or [2,2], so we will add symbol P? to say that, is this Pit room?
• Now agent will stop and think and will not make any harmful move.
• The agent will go back to the [1, 1] room.
• The room [1,1], and [2,1] are visited by the agent, so we will use symbol V to represent the
visited squares
Agent’s Third Step:
• At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2]
agent perceives a stench which means there must be a Wumpus nearby.
• But Wumpus cannot be in the room [1,1] as by rules of the game, and also not in [2,2]
(Agent had not detected any stench when he was at [2,1]).
• Therefore agent infers that Wumpus is in the room [1,3], and in current state, there is no
breeze which means in [2,2] there is no Pit and no Wumpus.
• So it is safe, and we will mark it OK, and the agent moves further in [2,2].

Agent’s Fourth step:


At room [2,2], here no stench and no breezes present so let's suppose agent decides to move to
[2,3]. At room [2,3] agent perceives glitter, so it should grab the gold and climb out of the cave.
LOGIC
Logic is the basis of all mathematical reasoning, and of all automated reasoning. The rules of logic
specify the meaning of mathematical statements. These rules help us understand and reason with
statements such as –
∃x such that x≠a2+b2, where x,a,b∈z
Which in Simple English means “There exists an integer that is not the sum of two squares”.
The rules of logic give precise meaning to mathematical statements. These rules are used to
distinguish between valid and invalid mathematical arguments.
Apart from its importance in understanding mathematical reasoning, logic has numerous
applications in Computer Science, varying from design of digital circuits, to the construction of
computer programs and verification of correctness of programs.
Propositional logic in AI
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:
a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.
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.
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.
Compound proposition: Compound propositions are constructed by combining simpler or atomic
propositions, using parenthesis and logical connectives.
Example:
a) "It is raining today, and street is wet."
b) "Ankit is a doctor, and his clinic is in Mumbai."
Logical Connectives:
Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or
negative literal.
Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
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 Doctor, so we can write it as P ∨ Q.
Logical connectives:
Implication: A sentence such as P → Q, is called an implication. Implications are also known as
if-then rules. It can be represented as
Ex: 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
Bi-Conditional: A sentence such as P⇔ Q is a Bi-conditional 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.
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

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Fifth Precedence Implication

Six Precedence Biconditional

Logical equivalence is one of the features of propositional logic.


Two propositions are said to be logically equivalent if and only if the columns in the truth table
are identical to each other. Let's take two propositions A and B, so for logical equivalence, we can
write it as A⇔B. In below truth table we can see that column for ¬A∨ B and A→B, are identical
hence A is Equivalent to B
A B ¬A ¬A∨ B A→B

T T F T T

T F F F F

F T T T T

F F T T T

• Commutativity:
• P∧ Q= Q ∧ P, or
• P ∨ Q = Q ∨ P.
• Associativity:
• (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
• Identity element:
• P ∧ True = P,
• P ∨ True= True.
• Distributive:
• P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
• DE Morgan's Law:
• ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
• ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
• Double-negation elimination:
• ¬ (¬P) = P.
• Limitations of Propositional logic:
• We cannot represent relations like ALL, some, or none with propositional logic. Example:
• All the girls are intelligent.
• Some apples are sweet.
• Propositional logic has limited expressive power.
• In propositional logic, we cannot describe statements in terms of their properties or logical
relationships.
Inference:
In artificial intelligence, we need intelligent computers which can create new logic from old logic
or by evidence, so generating the conclusions from evidence and facts is termed as Inference.
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:
Implication: It is one of the logical connectives which can be represented as P → Q. It is a Boolean
expression.
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.
Contrapositive: The negation of converse is termed as contrapositive, and it can be represented
as ¬ Q → ¬ P.
Inverse: The negation of implication is called inverse. It can be represented as ¬ P → ¬ Q.
Truth Table

P Q P→Q Q→P ¬Q→¬P ¬P→¬Q

T T T T T T

T F F T F T

F T T F T F

F F T T T T

Logical Equivalence:
Rules for propositional theorem proving:
Types of Inference rules:
The Modus Ponens rule is one of the most important rules of inference, and it states that if P and
P → Q is true, then we can infer that Q will be true. It can be represented as:

Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.

Knowledge-base for Wumpus world proof:


The agent starts visiting from first square [1, 1], and we already know that this room is safe for the
agent. To build a knowledge base for wumpus world, we will use some rules and atomic
propositions. We need symbol [i, j] for each location in the wumpus world, where i is for the
location of rows, and j for column location.

Atomic proposition variable for Wumpus world:


• Let Pi,j be true if there is a Pit in the room [i, j].
• Let Bi,j be true if agent perceives breeze in [i, j], (dead or alive).
• Let Wi,j be true if there is wumpus in the square[i, j].
• Let Si,j be true if agent perceives stench in the square [i, j].
• Let Vi,j be true if that square[i, j] is visited.
• Let Gi,j be true if there is gold (and glitter) in the square [i, j].
• Let OKi,j be true if the room is safe.
Note: For a 4 * 4 square board, there will be 7*4*4= 122 propositional variables.
Some Propositional Rules for the wumpus world:

Note: lack of variables gives us similar rules for each cell.


Representation of Knowledgebase for Wumpus world:
Following is the Simple KB for wumpus world when an agent moves from room [1, 1], to room
[2,1]:

Here in the first row, we have mentioned propositional variables for room[1,1], which is showing
that room does not have wumpus(¬ W11), no stench (¬S11), no Pit(¬P11), no breeze(¬B11), no gold
(¬G11), visited (V11), and the room is Safe(OK11).
In the second row, we have mentioned propositional variables for room [1,2], which is showing
that there is no wumpus, stench and breeze are unknown as an agent has not visited room [1,2], no
Pit, not visited yet, and the room is safe.
In the third row we have mentioned propositional variable for room[2,1], which is showing that
there is no wumpus(¬ W21), no stench (¬S 21), no Pit (¬P21), Perceives breeze(B21), no
glitter(¬G21), visited (V21), and room is safe (OK21 ).
Prove that Wumpus is in the room (1, 3)
We can prove that wumpus is in the room (1, 3) using propositional rules which we have derived
for the wumpus world and using inference rule.
Apply Modus Ponens with ¬S11 and R1:
We will firstly apply MP rule with R1 which is ¬S 11 → ¬ W11 ^ ¬ W12 ^ ¬ W21, and ¬S11 which
will give the output ¬ W11 ^ W12 ^ W12.

Apply And-Elimination Rule:


After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21, we will get three statements:
¬ W11, ¬ W12, and ¬W21.
Apply Modus Ponens to ¬S21, and R2:
Now we will apply Modus Ponens to ¬S21 and R2 which is ¬S21 → ¬ W21 ∧¬ W22 ∧ ¬ W31, which
will give the Output as ¬ W21 ∧ ¬ W22 ∧¬ W31
Apply And -Elimination rule:
Now again apply And-elimination rule to ¬ W21 ∧ ¬ W22 ∧¬ W31, We will get three statements:
¬ W21, ¬ W22, and ¬ W31.
Apply MP to S12 and R4:
Apply Modus Ponens to S12 and R4 which is S12 → W13 ∨. W12 ∨. W22 ∨.W11, we will get the
output as W13∨ W12 ∨ W22 ∨.W11.

• Apply Unit resolution on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 :


• After applying Unit resolution formula on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 we will get
W13 ∨ W12 ∨ W22.
Apply Unit resolution on W13 ∨ W12 ∨ W22 and ¬ W22 :
After applying Unit resolution on W13 ∨ W12 ∨ W22, and ¬W22, we will get W13 ∨ W12 as output.

• Apply Unit Resolution on W13 ∨ W12 and ¬ W12 :


• After Applying Unit resolution on W13 ∨ W12 and ¬ W12, we will get W13 as an output,
hence it is proved that the Wumpus is in the room [1, 3].

Effective Propositional Model:


• There are two families of efficient algorithms for general propositional inference based on
model checking:
• 1. Backtracking search
• 2. Local hill-climbing search
• 1. A complete backtracking algorithm: This algorithm is often called the Davis-Putnam
algorithm
• DPLL takes as input a sentence in conjunctive normal form- a set of clauses
• A. Early Termination: The algorithm detects whether the sentence must be true or False
even with partially completed mode. A clause is true if any literal is true, even if the other
literals don't yet have truth values, hence, the sentence as a whole be judged true even
before the model is complete.
• B. Pure symbol heuristic: A pure symbol is a symbol that always appears with the same
“sign” in all clauses. For example, in three clauses(A ∨ ¬B),(¬B ∨¬C), and (C ∨A), the
symbol A is pure because only the positive literal appears, B is Pure because only the
negative literal appears, and C is impure. It is easy to see that if a sentences has a model,
then it has a model with the pure symbols assigned so as to make their literals true, because
by doing so can never make a clause false.
• Unit clause heuristic: A unit clause is defined as a clause with just one literal. In the context
of DPLL, it also means clauses in which all literals but one are already assigned false by
the model.
• For example if B=true, then(¬ B ∨ ¬ C) simples to ¬C which is a unit clause. For this
clause to be true, C must be set to false. The unit clause heuristic assigns all such symbols
before branching on the remainder. Once important consequence of the heuristic is that any
attempt to prove a literal that is already in the knowledge base will succeed immediately
when C is set to false.
• For example when C is set to false, (C ∨A) becomes a unit clause, causing true to be
assigned to A. This “cascade” of forced assignment is called Unit Propagation.
Tricks to scale up to large SAT(Satisfiability) problems:
• Component analysis: As DPLL assigns truth values to variables, the set of clauses may
become separated into disjoint subsets, called components, that share no unassigned
variables. Given an efficient way to detect when this occurs, a solver can gain considerable
speed by working on each component separately.
• Variable and value ordering: our simple implementation of DPLL uses an arbitrary
variable ordering and always tries the value true before false. The degree heuristic suggests
choosing the variable that appears most frequently over all remaining clauses.
• Intelligent backtracking: Many problems that cannot be solved in hours of run time with
chronological backtracking can be solved in seconds with intelligent backtracking that
backs up all the way to the relevant point of conflict. All SAT solvers that do intelligent
backtracking use some form of conflict clause learning to record conflicts so that they wont
be repeated later in the search. Usually limited-size set of conflicts is kept, and rarely used
ones are dropped.
• Random restarts: Sometimes a run appears not to be making progress. In this case, we
can start over from the top of the search tree rather than trying to continue. After restarting,
different random choices are made. Clauses that are learned in the first run are retained
after the restart and can help prune the search space. Restarting does not guarantee that a
solution will be found faster, but it does reduce the variance on the time of solution
Tricks to scale up to large SAT(Satisfiability) problems:
• Clever indexing: The speedup methods used in DPLL itself, as well as the tricks used in
modern solvers, require fast indexing of such thing as the “ the set of clauses in which
variable Xi appears as a positive literal”. This task is complicated by the fact that the
algorithms are interested only in the clauses that have not yet been satisfied by previous
assignments to variables, so the indexing structures must be updated dynamically as the
computation proceeds.
• Agent based on propositional logic:
The first step in order to construct wumpus world agents using the propositional logic is to
enable the agent to deduce, to the extent possible, the state of the world given it s percept
history. This requires writing down a complete logical model of the effects of actions. Then
we show how the agent can keep track of the world efficiently without going back into the
percept history for each inference. Finally we show how the agent can use logical inference to
construct plans that are guaranteed to achieve its goal, provided its knowledge base is true in
the actual world.
First Order Logic:
In the topic of Propositional logic, we have seen that how to represent statements using
propositional logic. 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.
First-order logic is another way of knowledge representation in artificial intelligence. It is an
extension to propositional logic. FOL is sufficiently expressive to represent the natural language
statements in a concise way. First-order logic is also known as Predicate logic or First-order
predicate logic. First-order logic is a powerful language that develops information about the
objects in a more easy way and can also express the relationship between those objects. First-order
logic (like natural language) does not only assume that the world contains facts like propositional
logic but also assumes the following things in the world:
Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus,
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
Function: Father of, best friend, third inning of, end of,
As a natural language, first-order logic also has two main parts: 1..Syntax 2. Semantics
Syntax of First Order Logic
The syntax of FOL determines which collection of symbols is a logical expression in first-order
logic. The basic syntactic elements of first-order logic are symbols. We write statements in short-
hand notation in FOL.
• Basic Elements of First-order logic:
• Following are the basic elements of FOL syntax:

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

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

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃
Syntax for First Order Logic
Atomic sentences: 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.
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:
Complex sentences are made by combining atomic sentences using connectives. First-order logic
statements can be divided into two parts:
Subject: Subject is the main part of the statement.
Predicate: A predicate can be defined as a relation, which binds two atoms together in a statement.
Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject
of the statement and second part "is an integer," is known as a predicate.

Quantifiers in First-order logic:


A quantifier is a language element which generates quantification, and quantification specifies the
quantity of specimen in the universe of discourse.
These are the symbols that permit to determine or identify the range and scope of the variable in
the logical expression. There are two types of quantifier:
Universal Quantifier, (for all, everyone, everything)
Existential quantifier, (for some, at least one).
Example: All man drink coffee.
• Let a variable x which refers to a cat so all x can be represented in UOD as below:
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier: Existential quantifiers are the type of quantifiers, which express that the
statement within its scope is true for at least one instance of something.
It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a
predicate variable then it is called as an existential quantifier.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
There exists a 'x.'
• For some 'x.'
• For at least one 'x.'
Example:
Some boys are intelligent.
∃x: boys(x) ∧ intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.
Free and Bound Variables: The quantifiers interact with variables which appear in a suitable
way. There are two types of variables in First-order logic which are given below:
Free Variable: A variable is said to be a free variable in a formula if it occurs outside the scope of
the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: A variable is said to be a bound variable in a formula if it occurs within the scope
of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound variable
Knowledge Engineering in First-order logic
What is knowledge-engineering?
The process of constructing a knowledge-base in first-order logic is called as knowledge-
engineering. In knowledge-engineering, someone who investigates a particular domain, learns
important concept of that domain, and generates a formal representation of the objects, is known
as knowledge engineer.
Example:
Following are some main steps of the knowledge-engineering process. Using these steps, we will
develop a knowledge base which will allow us to reason about digital circuit (One-bit full adder)
which is given below
Identifying the task:
• The first step of the process is to identify the task, and for the digital circuit, there are
various reasoning tasks.
• At the first level or highest level, we will examine the functionality of the circuit:
• Does the circuit add properly?
• What will be the output of gate A2, if all the inputs are high?
• At the second level, we will examine the circuit structure details such as:
• Which gate is connected to the first input terminal?
• Does the circuit have feedback loops?
Assemble the relevant knowledge:
• In the second step, we will assemble the relevant knowledge which is required for digital
circuits. So for digital circuits, we have the following required knowledge:
• Logic circuits are made up of wires and gates.
• Signal flows through wires to the input terminal of the gate, and each gate produces the
corresponding output which flows further.
• In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.
• All these gates have one output terminal and two input terminals (except NOT gate, it has
one input terminal).
Decide on vocabulary:
• The next step of the process is to select functions, predicate, and constants to represent the
circuits, terminals, signals, and gates.
• Firstly we will distinguish the gates from each other and from other objects. Each gate is
represented as an object which is named by a constant, such as, Gate(X1).
• The functionality of each gate is determined by its type, which is taken as constants such
as AND, OR, XOR, or NOT. Circuits will be identified by a predicate: Circuit (C1).
• For the terminal, we will use predicate: Terminal(x).
• For gate input, we will use the function In(1, X1) for denoting the first input terminal of
the gate and for output terminal we will use Out (1, X1).
• The function Arity(c, i, j) is used to denote that circuit c has i input, j output.
• The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1,
X1)).
• We use a unary predicate On (t), which is true if the signal at a terminal is on.
Encode general knowledge about the domain:
• To encode the general knowledge about the logic circuit, we need some following rules:
• If two terminals are connected then they have the same input signal, it can be represented
as:
• ∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (2).
• Signal at every terminal will have either value 0 or 1, it will be represented as:
• ∀ t Terminal (t) →Signal (t) = 1 ∨Signal (t) = 0.
• Connect predicates are commutative:
• ∀ t1, t2 Connect(t1, t2) → Connect (t2, t1).
• Representation of types of gates:
• ∀ g Gate(g) ∧ r = Type(g) → r = OR ∨r = AND ∨r = XOR ∨r = NOT.
• Output of AND gate will be zero if and only if any of its input is zero.
• ∀ g Gate(g) ∧ Type(g) = AND →Signal (Out(1, g))= 0 ⇔ ∃n Signal (In(n, g))= 0.
Encode general knowledge about the domain:
• Output of OR gate is 1 if and only if any of its input is 1:
• ∀ g Gate(g) ∧ Type(g) = OR → Signal (Out(1, g))= 1 ⇔ ∃n Signal (In(n, g))= 1
• Output of XOR gate is 1 if and only if its inputs are different:
• ∀ g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔ Signal (In(1, g)) ≠ Signal (In
(2, g)).
• Output of NOT gate is invert of its input:
• ∀ g Gate(g) ∧ Type(g) = NOT → Signal (In(1, g)) ≠ Signal (Out(1, g)).
• All the gates in the above circuit have two inputs and one output (except NOT gate).
• ∀ g Gate(g) ∧ Type(g) = NOT → Arity(g, 1, 1)
• ∀ g Gate(g) ∧ r =Type(g) ∧ (r= AND ∨r= OR ∨r= XOR) → Arity (g, 2, 1).
• All gates are logic circuits:
• ∀ g Gate(g) → Circuit (g).
Encode a description of the problem instance:
• Now we encode problem of circuit C1, firstly we categorize the circuit and its gate
components. This step is easy if ontology about the problem is already thought. This step
involves the writing simple atomics sentences of instances of concepts, which is known as
ontology.
• For the given circuit C1, we can encode the problem instance in atomic sentences as below:
• Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences
for these gates will be:
• For XOR gate: Type(x1)= XOR, Type(X2) = XOR
• For AND gate: Type(A1) = AND, Type(A2)= AND
• For OR gate: Type (O1) = OR.
Pose queries to the inference procedure and get answers:
In this step, we will find all the possible set of values of all the terminal for the adder circuit. The
first query will be:
What should be the combination of input which would generate the first output of circuit C1, as 0
and a second output to be 1?
∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C1))= i3
∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1
Debug Knowledge Base
Now we will debug the knowledge base, and this is the last step of the complete process. In this
step, we will try to debug the issues of knowledge base.
Inference in First-Order Logic
Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences.
Before understanding the FOL inference rule, let's understand some basic terminologies used in
FOL.
Substitution:
Substitution is a fundamental operation performed on terms and formulas. It occurs in all inference
systems in first-order logic. The substitution is complex in the presence of quantifiers in FOL. If
we write F[a/x], so it refers to substitute a constant "a" in place of variable "x".
Equality:
First-Order logic does not only use predicate and terms for making atomic sentences but also uses
another way, which is equality in FOL. For this, we can use equality symbols which specify that
the two terms refer to the same object.
Example: Brother (John) = Smith.
As in the above example, the object referred by the Brother (John) is similar to the object referred
by Smith. The equality symbol can also be used with negation to represent that two terms are not
the same objects.

Example: ¬(x=y) which is equivalent to x ≠y.


FOL Rules for Quantifier
As propositional logic we also have inference rules in first-order logic, so following are some basic
inference rules in FOL:
• Universal Generalization
• Universal Instantiation
• Existential Instantiation
• Existential introduction
Universal Generalization
Universal generalization is a valid inference rule which states that if premise P(c) is true for any
arbitrary element c in the universe of discourse, then we can have a conclusion as ∀ x P(x).
It is represented as:

This rule can be used if we want to show that every element has a similar property.
In this rule, x must not appear as a free variable.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8 bits.",
it will also be true.
Universal Instantiation:
Universal instantiation is also called as universal elimination or UI is a valid inference rule. It can
be applied multiple times to add new sentences.
The new KB is logically equivalent to the previous KB.
As per UI, we can infer any sentence obtained by substituting a ground term for the variable.
The UI rule state that we can infer any sentence P(c) by substituting a ground term c (a constant
within domain x) from ∀ x P(x) for any object in the universe of discourse.
It can be represented as:

• Example:1.
• IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
Existential Instantiation:
Existential instantiation is also called as Existential Elimination, which is a valid inference rule in
first-order logic. It can be applied only once to replace the existential sentence. The new KB is not
logically equivalent to old KB, but it will be satisfiable if old KB was satisfiable. This rule states
that one can infer P(c) from the formula given in the form of ∃x P(x) for a new constant symbol c.
The restriction with this rule is that c used in the rule must be a new term for which P(c ) is true.
It can be represented as:

Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge
base. The above used K is a constant symbol, which is called Skolem constant. The Existential
instantiation is a special case of Skolemization process.
Existential introduction
• An existential introduction is also known as an existential generalization, which is a valid
inference rule in first-order logic.
• This rule states that if there is some element c in the universe of discourse which has a
property P, then we can infer that there exists something in the universe which has the
property P.
• It is represented as:


• Example: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
What is Unification?
Unification is a process of making two different logical atomic expressions identical by finding a
substitution. Unification depends on the substitution process. It takes two literals as input and
makes them identical using substitution. Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier
such that, Ψ1𝜎 = Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
Forward Chaining and backward chaining in AI
Inference engine: The inference engine is the component of the intelligent system in artificial
intelligence, which applies logical rules to the knowledge base to infer new information from
known facts. The first inference engine was part of the expert system. Inference engine commonly
proceeds in two modes, which are:
• Forward chaining
• Backward chaining
Forward Chaining: Forward chaining is also known as a forward deduction or forward
reasoning method when using an inference engine. Forward chaining is a form of reasoning
which start with atomic sentences in the knowledge base and applies inference rules (Modus
Ponens) in the forward direction to extract more data until a goal is reached. The Forward-
chaining algorithm starts from known facts, triggers all rules whose premises are satisfied, and
add their conclusion to the known facts. This process repeats until the problem is solved.
Properties of Forward Chaining
It is a down-up approach, as it moves from bottom to top. It is a process of making a conclusion
based on known facts or data, by starting from the initial state and reaches the goal state. Forward-
chaining approach is also called as data-driven as we reach to the goal using available data.
Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and
production rule systems.
"As per the law, it is a crime for an American to sell weapons to hostile nations. Country A,
an enemy of America, has some missiles, and all the missiles were sold to it by Robert, who
is an American citizen." Prove that "Robert is criminal."
• To solve the above problem, first, we will convert all the above facts into first-order definite
clauses, and then we will use a forward-chaining algorithm to reach the goal.
• Facts Conversion into FOL:
• It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are
variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
• Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can be written in two definite
clauses by using Existential Instantiation, introducing new Constant T1.
Owns(A, T1) ......(2)
Missile(T1) .......(3)
• All of the missiles were sold to country A by Robert.
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
• Missiles are weapons.
Missile(p) → Weapons (p) .......(5)
• Enemy of America is known as hostile.
Enemy(p, America) →Hostile(p) ........(6)
• Country A is an enemy of America.
Enemy (A, America) .........(7)
• Robert is American
American(Robert). ..........(8)
Forward Chaining Proof:
In the first step we will start with the known facts and will choose the sentences which do not
have implications, such as: American(Robert), Enemy(A, America), Owns(A, T1), and
Missile(T1). All these facts will be represented as below.
Step-2:
At the second step, we will see those facts which infer from available facts and with satisfied
premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Rule-(2) and (3) are already added.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which infers
from the conjunction of Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from
Rule-(7).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from Rule-
(7).

Step-3:
At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1, r/A}, so we
can add Criminal(Robert) which infers all the available facts. And hence we reached our goal
statement. Hence it is proved that Robert is Criminal using forward chaining approach.
Backward Chaining: Backward-chaining is also known as a backward deduction or backward
reasoning method when using an inference engine.
• A backward chaining algorithm is a form of reasoning, which starts with the goal and works
backward, chaining through rules to find known facts that support the goal.
Properties of backward chaining:
• It is known as a top-down approach.
• Backward-chaining is based on modus ponens inference rule.
• In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
• It is called a goal-driven approach, as a list of goals decides which rules are selected and
used.
• Backward -chaining algorithm is used in game theory, automated theorem proving tools,
inference engines, proof assistants, and various AI applications.
• The backward-chaining method mostly used a depth-first search strategy for proof.
In backward-chaining, we will use the same above example, and will rewrite all the rules.
• American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
Owns(A, T1) ........(2)
• Missile(T1)
• ?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
• Missile(p) → Weapons (p) .......(5)
• Enemy(p, America) →Hostile(p) ........(6)
• Enemy (A, America) .........(7)
• American(Robert). ..........(8)
Backward-Chaining proof:
Backward chaining, we will start with our goal predicate, which is Criminal(Robert), and then
infer further rules.
Step-1: At the first step, we will take the goal fact. And from the goal fact, we will infer other facts,
and at last, we will prove those facts true. So our goal fact is "Robert is Criminal," so following is
the predicate of it.
Step-2: At the second step, we will infer other facts form goal fact which satisfies the rules. So as
we can see in Rule-1, the goal predicate Criminal (Robert) is present with substitution {Robert/P}.
So we will add all the conjunctive facts below the first level and will replace p with Robert.
• Here we can see American (Robert) is a fact, so it is proved here.

Step-3:t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it
satisfies Rule-(5). Weapon (q) is also true with the substitution of a constant T1 at q.
IV UNIT:
Machine Learning
Machine learning is a subset of AI, which enables the machine to automatically learn from data,
improve performance from past experiences, and make predictions. Machine learning contains a
set of algorithms that work on a huge amount of data. Data is fed to these algorithms to train them,
and on the basis of training, they build the model & perform a specific task.
ML algorithms: These ML algorithms help to solve different business problems like Regression,
Classification, Forecasting, Clustering, and Associations, etc. Based on the methods and way of
learning, machine learning is divided into mainly four types, which are:
• Supervised Machine Learning
• Unsupervised Machine Learning
• Semi-Supervised Machine Learning
• Reinforcement Learning

Supervised Machine Learning: As its name suggests, supervised machine learning is based on
supervision. It means in the supervised learning technique, we train the machines using the
"labelled" dataset, and based on the training, the machine predicts the output. Here, the labelled
data specifies that some of the inputs are already mapped to the output. More preciously, we can
say; first, we train the machine with the input and corresponding output, and then we ask the
machine to predict the output using the test dataset.
Example: Let's understand supervised learning with an example. Suppose we have an input dataset
of cats and dog images.
• So, first, we will provide the training to the machine to understand the images, such as
the shape & size of the tail of cat and dog, Shape of eyes, colour, height (dogs are taller,
cats are smaller), etc.
• After completion of training, we input the picture of a cat and ask the machine to identify
the object and predict the output. Now, the machine is well trained, so it will check all the
features of the object, such as height, shape, colour, eyes, ears, tail, etc., and find that it's a
cat.
• So, it will put it in the Cat category. This is the process of how the machine identifies the
objects in Supervised Learning.
• The main goal of the supervised learning technique is to map the input variable(x) with the
output variable(y). Some real-world applications of supervised learning are Risk
Assessment, Fraud Detection, Spam filtering, etc.
Categories of Supervised Machine Learning:
Categories of Supervised Machine Learning
Classification
Regression
a) Classification
Classification algorithms are used to solve the classification problems in which the output variable
is categorical, such as "Yes" or No, Male or Female, Red or Blue, etc. The classification algorithms
predict the categories present in the dataset. Some real-world examples of classification algorithms
are Spam Detection, Email filtering, etc.
• Random Forest Algorithm
• Decision Tree Algorithm
• Logistic Regression Algorithm
• Support Vector Machine Algorithm
Regression: Regression algorithms are used to solve regression problems in which there is a linear
relationship between input and output variables. These are used to predict continuous output
variables, such as market trends, weather prediction, etc.
• Some popular Regression algorithms are given below:
• Simple Linear Regression Algorithm
• Multivariate Regression Algorithm
• Decision Tree Algorithm
• Lasso Regression
Applications of Supervised Learning:
Some common applications of Supervised Learning are given below:
• Image Segmentation:
Supervised Learning algorithms are used in image segmentation. In this process, image
classification is performed on different image data with pre-defined labels.
• Medical Diagnosis:
Supervised algorithms are also used in the medical field for diagnosis purposes. It is done
by using medical images and past labelled data with labels for disease conditions. With
such a process, the machine can identify a disease for the new patients.
Applications of Supervised Learning
Fraud Detection - Supervised Learning classification algorithms are used for identifying fraud
transactions, fraud customers, etc. It is done by using historic data to identify the patterns that can
lead to possible fraud.
Spam detection - In spam detection & filtering, classification algorithms are used. These
algorithms classify an email as spam or not spam. The spam emails are sent to the spam folder.
Speech Recognition - Supervised learning algorithms are also used in speech recognition. The
algorithm is trained with voice data, and various identifications can be done using the same, such
as voice-activated passwords, voice commands, etc.
Unsupervised Learning:
Unsupervised learning is a type of machine learning that learns from unlabeled data. This means
that the data does not have any pre-existing labels or categories. The goal of unsupervised
learning is to discover patterns and relationships in the data without any explicit guidance.
Unsupervised learning is the training of a machine using information that is neither classified
nor labeled and allowing the algorithm to act on that information without guidance. Here the
task of the machine is to group unsorted information according to similarities, patterns, and
differences without any prior training of data.
Unlike supervised learning, no teacher is provided that means no training will be given to the
machine. Therefore the machine is restricted to find the hidden structure in unlabeled data by
itself.
You can use unsupervised learning to examine the animal data that has been gathered and
distinguish between several groups according to the traits and actions of the animals. These
groupings might correspond to various animal species, providing you to categorize the creatures
without depending on labels that already exist.
Types of Unsupervised Learning
Unsupervised learning is classified into two categories of algorithms:
 Clustering: A clustering problem is where you want to discover the inherent groupings in
the data, such as grouping customers by purchasing behavior.
 Association: An association rule learning problem is where you want to discover rules that
describe large portions of your data, such as people that buy X also tend to buy Y.
Clustering
Clustering is a type of unsupervised learning that is used to group similar data points
together. Clustering algorithms work by iteratively moving data points closer to their cluster
centers and further away from data points in other clusters.
1. Exclusive (partitioning)
2. Agglomerative
3. Overlapping
4. Probabilistic
Clustering Types:-
1. Hierarchical clustering
2. K-means clustering
3. Principal Component Analysis
4. Singular Value Decomposition
5. Independent Component Analysis
6. Gaussian Mixture Models (GMMs)
7. Density-Based Spatial Clustering of Applications with Noise (DBSCAN)
Association rule learning
Association rule learning is a type of unsupervised learning that is used to identify patterns in a
data. Association rule learning algorithms work by finding relationships between different items
in a dataset.
Some common association rule learning algorithms include:
 Apriori Algorithm
 Eclat Algorithm
 FP-Growth Algorithm
Application of Unsupervised learning
Non-supervised learning can be used to solve a wide variety of problems, including:
 Anomaly detection: Unsupervised learning can identify unusual patterns or deviations from
normal behavior in data, enabling the detection of fraud, intrusion, or system failures.
 Scientific discovery: Unsupervised learning can uncover hidden relationships and patterns in
scientific data, leading to new hypotheses and insights in various scientific fields.
 Recommendation systems: Unsupervised learning can identify patterns and similarities in
user behavior and preferences to recommend products, movies, or music that align with their
interests.
 Customer segmentation: Unsupervised learning can identify groups of customers with
similar characteristics, allowing businesses to target marketing campaigns and improve
customer service more effectively.
 Image analysis: Unsupervised learning can group images based on their content, facilitating
tasks such as image classification, object detection, and image retrieval.
Advantages of Unsupervised learning
 It does not require training data to be labeled.
 Dimensionality reduction can be easily accomplished using unsupervised learning.
 Capable of finding previously unknown patterns in data.
 Unsupervised learning can help you gain insights from unlabeled data that you might not
have been able to get otherwise.
 Unsupervised learning is good at finding patterns and relationships in data without being told
what to look for. This can help you learn new things about your data.
Disadvantages of Unsupervised learning
 Difficult to measure accuracy or effectiveness due to lack of predefined answers during
training.
 The results often have lesser accuracy.
 The user needs to spend time interpreting and label the classes which follow that
classification.
 Unsupervised learning can be sensitive to data quality, including missing values, outliers,
and noisy data.
 Without labeled data, it can be difficult to evaluate the performance of unsupervised learning
models, making it challenging to assess their effectiveness.

Difference between supervised and unsupervised learning:

Supervised machine Unsupervised machine


Parameters learning learning

Algorithms are trained Algorithms are used against


Input Data using labeled data. data that is not labeled

Computational
Simpler method Computationally complex
Complexity

Accuracy Highly accurate Less accurate


Supervised machine Unsupervised machine
Parameters learning learning

No. of classes No. of classes is known No. of classes is not known

Uses real-time analysis of


Uses offline analysis
Data Analysis data

Linear and Logistics


regression, Random forest, K-Means clustering,
multi-class classification, Hierarchical
decision tree, Support clustering, KNN, Apriori
Vector Machine, Neural algorithm, etc.
Algorithms used Network, etc.

Output Desired output is given. Desired output is not given.

Use training data to infer


No training data is used.
Training data model.

It is not possible to learn


It is possible to learn larger
larger and more complex
and more complex models
models than with
with unsupervised learning.
Complex model supervised learning.

Model We can test our model. We can not test our model.

Supervised learning is also Unsupervised learning is


Called as called classification. also called clustering.

Example: Optical character Example: Find a face in an


Example recognition. image.

supervised learning needs Unsupervised learning does


supervision to train the not need any supervision to
Supervision model. train the
What is Natural Language Processing?

Natural Language Processing is a part of artificial intelligence that aims to teach the human
language with all its complexities to computers. This is so that machines can understand and
interpret the human language to eventually understand human communication in a better way.
Natural Language Processing is a cross among many different fields such as artificial intelligence,
computational linguistics, human-computer interaction, etc. There are many different methods
in NLP to understand human language which include statistical and machine learning methods.
These involve breaking down human language into its most basic pieces and then understand how
these pieces relate to each other and work together to create meanings in sentences.

Applications of Natural Language Processing:

Chatbots : are a form of artificial intelligence that are programmed to interact with humans in such
a way that they sound like humans themselves. Depending on the complexity of the chatbots, they
can either just respond to specific keywords or they can even hold full conversations that make it
tough to distinguish them from humans. Chatbots are created using Natural Language Processing
and Machine Learning, which means that they understand the complexities of the English language
and find the actual meaning of the sentence and they also learn from their conversations with
humans and become better with time. Chatbots work in two simple steps. First, they identify the
meaning of the question asked and collect all the data from the user that may be required to answer
the question. Then they answer the question appropriately.

Autocomplete in Search Engines

Have you noticed that search engines tend to guess what you are typing and automatically complete
your sentences? For example, On typing “game” in Google, you may get further suggestions for
“game of thrones”, “game of life” or if you are interested in maths then “game theory”. All these
suggestions are provided using autocomplete that uses Natural Language Processing to guess what
you want to ask. Search engines use their enormous data sets to analyze what their customers are
probably typing when they enter particular words and suggest the most common possibilities. They
use Natural Language Processing to make sense of these words and how they are interconnected
to form different sentences.

Voice Assistants

These days voice assistants are all the rage! Whether its Siri, Alexa, or Google Assistant, almost
everyone uses one of these to make calls, place reminders, schedule meetings, set alarms, surf the
internet, etc. These voice assistants have made life much easier. But how do they work? They use
a complex combination of speech recognition, natural language understanding, and natural
language processing to understand what humans are saying and then act on it. The long term goal
of voice assistants is to become a bridge between humans and the internet and provide all manner
of services based on just voice interaction. However, they are still a little far from that goal seeing
as Siri still can’t understand what you are saying sometimes!
Language Translator

Want to translate a text from English to Hindi but don’t know Hindi? Well, Google Translate is
the tool for you! While it’s not exactly 100% accurate, it is still a great tool to convert text from
one language to another. Google Translate and other translation tools as well as use Sequence to
sequence modeling that is a technique in Natural Language Processing. It allows the algorithm to
convert a sequence of words from one language to another which is translation. Earlier, language
translators used Statistical machine translation (SMT) which meant they analyzed millions of
documents that were already translated from one language to another (English to Hindi in this
case) and then looked for the common patterns and basic vocabulary of the language. However,
this method was not that accurate as compared to Sequence to sequence modeling.

What Is Text Classification?


Text classification also known as text tagging or text categorization is the process of categorizing
text into organized groups. By using Natural Language Processing (NLP), text classifiers can
automatically analyze text and then assign a set of pre-defined tags or categories based on its
content.
Text Classification Examples
Text classification is becoming an increasingly important part of businesses as it allows to easily
get insights from data and automate business processes. Some of the most common examples
and use cases for automatic text classification include the following:
Sentiment Analysis: the process of understanding if a given text is talking positively or
negatively about a given subject (e.g. for brand monitoring purposes).
Topic Detection: the task of identifying the theme or topic of a piece of text (e.g. know if a
product review is about Ease of Use, Customer Support, or Pricing when analyzing customer
feedback).
Language Detection: the procedure of detecting the language of a given text (e.g. know if an
incoming support ticket is written in English or Spanish for automatically routing tickets to the
appropriate team).
Speech Recognition in AI
What is Speech Recognition in AI?
Speech recognition is the process of identifying a human voice. Typically, businesses create
these programs and integrate them into various hardware devices to identify speech. When the
program hears your voice or receives your order, it will respond appropriately.
Numerous businesses create software that recognizes speech using cutting-edge technologies like
artificial intelligence, machine learning, and neural networks. The way individuals utilize
hardware and electrical devices has been changed by technologies like Siri, Amazon, Google
Assistant, and Cortana. They include smartphones, devices for home security, cars, etc.
Remember that voice recognition and speech recognition are not the same. Speech recognition
takes an audio file of a speaker, recognizes the words in the audio, and converts the words into
text. Voice recognition, in contrast, only recognizes voice instructions that have been pre-
programmed. The conversion of voice into text is the only similarity between these two methods.
What is Speech Recognition in AI?
Speech recognition is the process of identifying a human voice. Typically, businesses create
these programs and integrate them into various hardware devices to identify speech. When the
program hears your voice or receives your order, it will respond appropriately.
Numerous businesses create software that recognizes speech using cutting-edge technologies like
artificial intelligence, machine learning, and neural networks. The way individuals utilize
hardware and electrical devices has been changed by technologies like Siri, Amazon, Google
Assistant, and Cortana. They include smartphones, devices for home security, cars, etc.
Remember that voice recognition and speech recognition are not the same. Speech recognition
takes an audio file of a speaker, recognizes the words in the audio, and converts the words into
text. Voice recognition, in contrast, only recognizes voice instructions that have been pre-
programmed. The conversion of voice into text is the only similarity between these two methods.
Applications Speech Recognition AI
Speech recognition across a wide range of fields and applications, artificial intelligence is
employed as a commercial solution. AI is enabling more natural user interactions with
technology and software, with higher data transcription accuracy than ever before, in everything
from ATMs to call centres and voice-activated audio content assistants.
Call centres: One of the most common applications of speech AI in call centres is speech
recognition. Using cloud models, this technology enables you to hear what customers are saying
and respond properly. The use of voice patterns as identification or permission for access
solutions or services without relying on passwords or other conventional techniques or models
like fingerprints or eye scans is also possible with speech recognition technology. By doing this,
business problems like lost passwords or compromised security codes can be resolved.
Banking: Speech AI applications are being used by banking and financial institutions to assist
consumers with their business inquiries. If you want to know your account balance or the current
interest rate on your savings account, for instance, you can ask a bank. As a result, customer
support agents may respond to inquiries more quickly and provide better service because they no
longer need to conduct extensive research or consult cloud data.
Telecommunications: Models for speech recognition technology provide more effective call
analysis and management. Providing better customer service enables agents to concentrate on
their most valuable activities. Consumers may now communicate with businesses in real-time,
around-the-clock, via text messaging or voice transcription services, which improves their
overall experience and helps them feel more connected to the firm.
Healthcare: Speech-enabled In the telecommunications sector, AI is a technology that is
growing in popularity. Models for speech recognition technology provide more effective call
analysis and management. Providing better customer service enables agents to concentrate on
their most valuable activities.
Media and marketing: Speech recognition and AI are used in tools like dictation software to
enable users to type or write more in a shorter amount of time. In general, copywriters and
content writers may transcribe up to 3000–4000 words in as little as 30 minutes. Yet accuracy is
a consideration. These tools cannot ensure 100% error-free transcription. Yet, they are quite
helpful in assisting media and marketing professionals in creating their initial draughts.
AI in Robotics

o Self-Moving Robots: AI makes robots really smart at moving around on their own. It's
like giving them a built-in GPS and a clever brain. They can figure out where to go and
how to get there without bumping into things or needing a person to show them the way.
This helps them do tasks like delivering packages or exploring places on their own, making
them super independent.
o Object Recognition and Manipulation: AI gives robots sharp eyes and clever hands. It
helps them see objects clearly and then pick them up and move them just right. This is
super useful, especially in places like warehouses, where they can do things like sorting
and packing items accurately.
o Collaboration of Humans and Robots: AI makes it possible for robots to be great team
players with people. They can work alongside humans, helping out and learning from them.
If a person does something, the robot can understand and follow their lead. This makes
workplaces safer and more efficient, like having a trusty robot colleague who understands
and supports you.

You might also like