0% found this document useful (0 votes)
38 views44 pages

Understanding Knowledge-Based AI Systems

Artificial intelligence (AI) is the ability of digital systems to perform tasks commonly associated with intelligent beings, such as reasoning, learning, and problem-solving. A knowledge-based system is a type of AI that aims to capture human expertise to support decision-making. It consists of a knowledge base containing information about a domain, an inference engine that deduces insights from the knowledge base, and an interface for user interaction. Knowledge-based systems have been developed for applications like medical diagnosis, equipment fault detection, and cash management.

Uploaded by

Sushmita Mhamane
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)
38 views44 pages

Understanding Knowledge-Based AI Systems

Artificial intelligence (AI) is the ability of digital systems to perform tasks commonly associated with intelligent beings, such as reasoning, learning, and problem-solving. A knowledge-based system is a type of AI that aims to capture human expertise to support decision-making. It consists of a knowledge base containing information about a domain, an inference engine that deduces insights from the knowledge base, and an interface for user interaction. Knowledge-based systems have been developed for applications like medical diagnosis, equipment fault detection, and cash management.

Uploaded by

Sushmita Mhamane
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

UNIT 1

1. Define Artificial Intelligence.

artificial intelligence (AI), the ability of a digital computer or computer-controlled robot to perform
tasks commonly associated with intelligent beings. The term is frequently applied to the project of
developing systems endowed with the intellectual processes characteristic of humans, such as the ability to
reason, discover meaning, generalize, or learn from past experience. Since the development of the digital
computer in the 1940s, it has been demonstrated that computers can be programmed to carry out very
complex tasks—as, for example, discovering proofs for mathematical theorems or playing chess—with
great proficiency. Still, despite continuing advances in computer processing speed and memory capacity,
there are as yet no programs that can match human flexibility over wider domains or in tasks requiring
much everyday knowledge. On the other hand, some programs have attained the performance levels of
human experts and professionals in performing certain specific tasks, so that artificial intelligence in this
limited sense is found in applications as diverse as medical diagnosis, computer search engines, and voice
or handwriting recognition.

What is a Knowledge Based System? Explain

A knowledge-based system (KBS) is a form of artificial intelligence (AI) that aims to capture the
knowledge of human experts to support decision-making. Examples of knowledge-based systems
include expert systems, which are so called because of their reliance on human expertise.

The typical architecture of a knowledge-based system, which informs its problem-solving method, includes
a knowledge base and an inference engine. The knowledge base contains a collection of information in a
given field -- medical diagnosis, for example. The inference engine deduces insights from the information
housed in the knowledge base. Knowledge-based systems also include an interface through which users
query the system and interact with it.

A knowledge-based system may vary with respect to its problem-solving method or approach. Some
systems encode expert knowledge as rules and are therefore referred to as rule-based systems. Another
approach, case-based reasoning, substitutes cases for rules. Cases are essentially solutions to existing
problems that a case-based system will attempt to apply to a new problem.

Where knowledge-based systems are used


Over the years, knowledge-based systems have been developed for a number of applications. MYCIN, for
example, was an early knowledge-based system created to help doctors diagnose diseases. Healthcare has
remained an important market for knowledge-based systems, which are now referred to as clinical
decision-support systems in the health sciences context.

Knowledge-based systems have also been employed in applications as diverse as avalanche path analysis,
industrial equipment fault diagnosis and cash management.
Knowledge-based systems and artificial intelligence
While a subset of artificial intelligence, classical knowledge-based systems differ in approach to some of
the newer developments in AI.

Daniel Dennett, a philosopher and cognitive scientist, in his 2017 book, From Bacteria to Bach and Back,
cited a strategy shift from early AI, characterized by "top-down-organized, bureaucratically efficient know-
it-all" systems to systems that harness Big Data and "statistical pattern-finding techniques" such as data-
mining and deep learning in a more bottom-up approach.

Examples of AI following the latter approach include neural network systems, a type of deep-learning
technology that concentrates on signal processing and pattern recognition problems such as facial
recognition.

Explain Knowledge Based Reasoning w.r.t Agents and Knowledge.

Knowledge-Based Agent in Artificial intelligence

• For efficient decision-making and reasoning, an intelligent agent need knowledge about the real
world.
• Knowledge-based agents are capable of maintaining an internal state of knowledge, reasoning over
that knowledge, updating their knowledge following observations, and taking actions. These agents
can use some type of formal representation to represent the world and act intelligently.
• Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system

The following must be able to be done by a knowledge-based agent:

• Agents should be able to represent states, actions, and other things.


• A representative New perceptions should be able to be incorporated.
• An agent's internal representation of the world can be updated.
• An agent can infer the world's intrinsic representation.
• An agent can deduce the best course of action.
A generic architecture for a knowledge-based agent is depicted in the diagram above. By observing the
environment, the knowledge-based agent (KBA) receives input from it. The input is taken by the agent's
inference engine, which also communicates with KB to make decisions based on the knowledge store in KB.
KBA's learning component keeps the KB up to date by learning new information.

Knowledge base: : A knowledge-based agent's knowledge base, often known as KB, is a critical component.
It's a group of sentences ('sentence' is a technical term that isn't the same as'sentence' in English). These
sentences are written in what is known as a knowledge representation language. The KBA Knowledge Base
contains information about the world.

Inference system

Inference is the process of creating new sentences from existing ones. We can add a new sentence to the
knowledge base using the inference mechanism. A proposition about the world is a sentence. The inference
system uses logical rules to deduce new information from the KB.
The inference system generates new facts for an agent to update the knowledge base. An inference system
is based on two rules, which are as follows:

• 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 discern from the environment.
• ASK: This operation asks the knowledge base what action it should perform.
• Perform: It performs the selected action.

Various levels of knowledge-based agent:

1. Knowledge level:
The first level of a knowledge-based agent is the knowledge level, where we must explain what the agent
knows and what the agent's goals are. We can correct its behavior using these specs. Let's say an automated
taxi agent needs to get from station A to station B, and he knows how to get there, so this is a knowledge
problem.

2. Logical level:
We understand how the knowledge representation of knowledge is stored at this level. Sentences are
encoded in various logics at this level. At the logical level, knowledge is encoded into logical statements. We
can expect the automated taxi agent to arrive at destination B on a rational level.

3. Implementation level:
Physical representation of logic and knowledge (implementation level). Agents at the
implementation level take actions based on their logical and knowledge levels. At this phase, an
autonomous cab driver puts his knowledge and logic into action in order to go to his destination.

Differentiate between AI and Predictive Analytics

What is Artificial Intelligence?

Artificial intelligence is a combination of technologies that analyze records, make assumptions, test, and
retest data autonomously. Complex algorithms process massive amounts of data in real-time without
predetermined rules, allowing the software to automatically identify and learn from data trends. This
machine learning process continuously reevaluates models and data to accurately forecast outcomes at
scale and at speeds unattainable by human analysts.

When applied to marketing efforts, AI predicts events like customer-product matches and consumers’ next
purchases with high degrees of confidence. Marketers use this generative modeling technique to garner
microtargeted insights across large populations and produce highly targeted campaigns while maximizing
time and monetary resources.

What is Predictive Analytics?

As a subset of AI, predictive analytics is a statistics-based method that data analysts use to make
assumptions and test records in order to predict the likelihood of a given future outcome. Analysts capture
historical trends and apply these patterns to current data, then compute a specific value at a future point in
time. However, data must be manually retested on a continual basis for up-to-date predictions.

In the marketing realm, predictive analytics takes a more guided approach to data-driven forecasting. This
analytic strategy informs decision-making on demographics, targeting, and collateral and predicts
campaign effectiveness at a surface-level. Higher time and cost demands restrict insight depth, limiting use
cases and campaign personalization.

Key Differences Between AI & Predictive Analytics

The biggest difference between artificial intelligence and predictive analytics is that AI is completely
autonomous while predictive analytics relies on human interaction to query data, identify trends, and test
assumptions. Due to this, AI possesses a significantly broader scope and more applications than sole
predictive analytics. Artificial intelligence also involves continuously expanding multi-variable algorithms
compared to the strict forecasting model of predictive analytics.

Mitigating risk and forecasting campaign success has never been easier thanks to AI and predictive
analytics. While each strategy takes a slightly different approach to data analysis, both offer advanced
insights and 360-degree views of data patterns to help you increase marketing ROI, conversion rates, and
customer loyalty.

What are the four basic types of agent program in any intelligent system? Explain how did you convert them
into learning agents?.

Intelligent Agents: Agent Programs & Main Type of Agents

In my previous post, I mentioned about agent programs. In this post, I will get into more details. To quick

recap, an agent program is a real implementation of an agent function. In other words, it implements an

agent function which maps percepts to actions.

Despite the agent function can hold all history of percepts, an agent program can only take one input

(current input) at a time cause there is nothing available at the time. (Think about it, an agent program

takes snapshots of the environment. Even though it takes multiple snapshots at the same time, they will be

identical.) However, they may hold state inside of the program. Let’s deep dive.
There are four basic types of agent programs. These almost embody the all intelligent agent systems.

1. Simple Reflex Agents

2. This is the simplest type of all four. This type of agents are admirably simple but they have very

limited intelligence. Their actions are based on the current percept. They only looks at the current

state and decides what to do. Neither they hold nor consider any part of the history during their

decision process.

3. In some cases like smart thermostats, this type of agent might be useful, however, in most cases its

not. Especially, if the environment is partially observable, it might be the recipe of a disaster 🤔 As

I said, they have very limited intelligence. Their intelligence is only based on the given static table.

No learning capacity. Below is a pseudo code for a simple reflex agent.

def
simple_reflex_agent(percept):
state = get_state_from_percept(percept)
rule = match_rule(state, rules)
action = [Link]
return action

Simple reflex agent holds a static table for rules. It gets a percept as an input and returns an action. First,
based on the input tries to understand the state of the environment. Then in the static table, finds the
corresponding rule to this state. At last, returns the action of the rule.
2)Model-based Reflex Agents
This type of agents is little bit more complicated than the reflex based agents. A model based agent holds an

internal state based on the percept history. This internal state helps agent to handle a partially observable

environment. It consider both internal state and current percept to take an action. Also, each step it updates

the internal state.

Updating internal state requires two kinds of knowledge.

1. Agent needs to know how the world evolves independently from the agent.

2. How the agent’s actions affect the environment.

Both of these knowledge is embedded to the agent’s program and they help agent to understand how the

world works. Implementation of this, is called the model of the world and the agent that uses this model to

decide what action to take called model based agent.


A model based reflex agent takes the current percept and combine it with the internal state, model, and

most recent action’s effect then decides about what action to take

def
model_based_reflex_agent(percept):
state = update_state(state, action, percept, model)
rule = match_rule(state, rules)
action = [Link]
return action

3)Goal-Based Agents
For some tasks, its not always enough to know how the world works. In some cases, its desirable to define

a goal information to describe a desirable situations. A goal-based agent combines model-based agent’s

model with a goal. To reach its goal. it often uses Search and Planning algorithms.

Goal based agents usually less efficient but more flexible than reflex-based agents. A goal based-agent can

suit itself based on the environment. For example, a goal-based agent can adapt its behavior based on the

sensor data.

4) Utility-Based Agents

Goal-Based agents seems pretty cool and seems like we don’t need another one. Is that so? No, no no no.

That’s not correct. If we look at the goal based agents, we see they select the action based on the goal. End

result is we achieve our goal and we are happy 🤗🤠👻. But how happy are we? Just imagine that, we
want to go from point A to point B. There are 2 paths. One is 10-miles long and the other is 100.

Unfortunately, our goal based agent may or may not choose the path 2(100 miles long). At the end

whichever path we take, we will reach our destination but how happy will we be if we take the longer path?
Probably, not so much. That’s the problem for goal-based agents. They don’t consider the journey 😞. How

do we fix this? Well we try to fix this with Utility-Based Agents 😀

With Utility-Based agents we use utility function which is essentially an internationalization of the

performance measurement (It kinda defines how happy will we be if we choose this path). Also, if there are

multiple goals(yes, you heard me right. Might be multiple goals.) and these goals conflicts in some cases,

utility function specifies the appropriate tradeoff. Also, if non of these goals can be achieved with certainty,

utility may provide likelihood of success.

Technically speaking, a rational utility based agent chooses its action to maximize the performance.

Unit2
1. Define the syntactic elements of first-Order logic. Illustrate the use of first-order logic to represent
knowledge.

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.

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.

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

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


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

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

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

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


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

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

Quantifiers in First-order logic:

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

(a) forward chaining (b) Backward chaining

Forward Chaining and backward chaining in AI

In artificial intelligence, forward and backward chaining is one of the important topics, but before
understanding forward and backward chaining lets first understand that from where these two terms came.

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:

a. Forward chaining
b. Backward chaining

Horn Clause and Definite clause:

Horn clause and definite clause are the forms of sentences, which enables knowledge base to use a more
restricted and efficient inference algorithm. Logical inference algorithms use forward and backward chaining
approaches, which require KB in the form of the first-order definite clause.

Definite clause: A clause which is a disjunction of literals with exactly one positive literal is known as a
definite clause or strict horn clause.

Horn clause: A clause which is a disjunction of literals with at most one positive literal is known as horn
clause. Hence all the definite clauses are horn clauses.

Example: (¬ p V ¬ q V k). It has only one positive literal k.

It is equivalent to p ∧ q → k.

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

o It is a down-up approach, as it moves from bottom to top.


o 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.
o Forward-chaining approach is also called as data-driven as we reach to the goal using available data.
o Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and
production rule systems.

Consider the following famous example which we will use in both approaches:

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

o It is known as a top-down approach.


o Backward-chaining is based on modus ponens inference rule.
o In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
o It is called a goal-driven approach, as a list of goals decides which rules are selected and used.
o Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference
engines, proof assistants, and various AI applications.
o The backward-chaining method mostly used a depth-first search strategy for proof.

What is propositional logic? What are the elements of propositional logic?


As the name suggests propositional logic is a branch of mathematical logic which studies
the logical relationships between propositions (or statements, sentences, assertions) taken as a whole, and
connected via logical connectives.

Propositional logic is also known by the names sentential logic, propositional calculus and sentential
calculus. It is useful in a variety of fields, including, but not limited to:

• workflow problems
• computer logic gates
• computer science
• game strategies
• designing electrical systems
Fundamental Concepts - Definitions
In propositional logic a statement (or proposition) is represented by a symbol (or letter) whose
relationship with other statements is defined via a set of symbols (or connectives). The statement is
described by its truth value which is either true or false.

\color{#D61F06} \textbf{Propositions}Propositions

A proposition is a statement, taken in its entirety, that is either true or false. For example, a proposition
might be:

All elephants are green.


Unlike syllogistic logic, in propositional logic, this statement is taken in its entirety, usually represented
by a symbol, and we only concern ourselves with whether or not it is true or false, not the individual terms
in the statement.

\color{#D61F06} \textbf{Proposition Letters}Proposition Letters

In propositional logic, a proposition by convention is represented by a capital letter, typically boldface.


For example, the proposition above might be represented by the letter A.

A: All elephants are green.


\color{#D61F06} \textbf{Truth Value}Truth Value

Each of the propositions is assigned a truth value of either true or false. In other areas (for example
computer logic gates) these values are given by the binary representations 11 (true) and 00 (false).

We say that v(P)v(P) evaluates the proposition PP, i.e. returns its truth value.

\color{#D61F06} \textbf{Connectives}Connectives

In propositional logic, the relationships between propositions are represented by connectives.

There are essentially five different connectives outlined in the following table:

\color{#3D99F6} \color{#3D99F6} \color{#3D99F6}


\textbf{Connective}Connective \textbf{Symbol}Symbol \textbf{Description}Description

Negation \neg¬ NOT

Conjugation \wedge∧ AND

Disjunction \vee∨ OR

Conditional \to→ If ... then

Biconditional \leftrightarrow↔ If and only if

Suppose we wanted to say "If it rains, Jake won't walk to school"

We would first represent the two propositions as a proposition letter:


• A: It rains
• B: Jake won't walk to school
Then we would use the conditional connective to make our statement.

A \to→ B _\square□
Truth Table Overview

In order to clarify the meaning of a proposition or a connective, a truth table is used.

Truth tables are a way of visualizing the truth values of propositions. A value of true is represented by a
"1" and a value of false is represented by a "0".

For example, consider the following propositions:

• A: Marty wears green boots.


• B: Marty has a dog.
• C: Marty wears green boots, and Marty has a dog.
Proposition C takes on the following truth values:

• If Marty doesn't wear green boots and doesn't have a dog, then proposition C is false.
• If Marty doesn't wear green boots but has a dog, then proposition C is false.
• If Marty wears green boots but doesn't have a dog, then proposition C is false.
• If Marty wears green boots and has a dog, then proposition C is true.
Represented in a truth table, we have one row for each of the above statements (which include all possible
combinations of Marty wearing green boots and/or having a dog), and each column represents the
possible states of each of the propositions A, B, and, C above.

So, the four statements above are represented in the following truth table:

AA BB C = A \wedge BC=A∧B

0 0 0

0 1 0

1 0 0

1 1 1

Connectives

Connectives are logical symbols which express the relationship between propositions.

There are five basic connectives:


• Negation
• Conjunction
• Disjunction
• Conditional
•Biconditional
These concepts are further described below.

\color{#D61F06} \textbf{Negation}Negation

Negation is a unary logical connective. For any proposition PP, the negation of PP, denoted \neg P,¬P, is
a proposition implying that PP is false. \neg P¬P is also read as "not" PP.

v(\neg B) = \left\{\begin{matrix} 1 &&& \text{if } v(B)= 0\\ 0 &&& \text{otherwise.} \ _\square


\end{matrix}\right.v(¬B)={10if v(B)=0otherwise. □
The truth table (1=true, 0=false) for negation is as follows:

P \neg¬ P

1 0

0 1

For the proposition:

A: The moon is made of green cheese.

What is \neg A¬A?

The negation of proposition A, would be a statement which is always true if A is false and always false
if A is true. The following statement fits that criteria::

\neg¬ A: The moon is not made of green cheese. _\square□


\color{#D61F06} \textbf{Conjugation}Conjugation

Logical conjunction is an associative binary logical connective which evaluates as true only if both of the
propositions it relates are true.

v(A \wedge B) = \left\{\begin{matrix} 1 && \text{if } v(B)= 1 \text{ and } v(A)= 1 \\ 0 &&
\text{otherwise}. \end{matrix}\right.v(A∧B)={10if v(B)=1 and v(A)=1otherwise.
The truth table for conjugation is as follows:

P Q P \wedge∧ Q
0 0 0

0 1 0

1 0 0

1 1 1

(1 = true, 0 = false)

Consider the following statement:

The elephants are green, and George wears red boots.

What type of proposition is this?

We can assign propositional letters to these statements:

E: Elephants are green

G: George wears red boots.

Then, the above statement is rewritten as:

E \wedge∧ G

So, this proposition is a conjunction. _\square□


\color{#D61F06} \textbf{Disjunction}Disjunction

Logical disjunction is an associative binary logical connective which evaluates as true if either of the
propositions it relates are true. Note: This is the "inclusive" definition of disjunction, not to be confused
with the "exclusive" form equivalent to an "XOR" gate in computer logic.

v(A \vee B) = \left\{\begin{matrix} 0 &&& \text{if } v(B)= 0 \text{ and } v(A)= 0 \\ 1 &&&
\text{otherwise.} \ _\square \end{matrix}\right.v(A∨B)={01if v(B)=0 and v(A)=0otherwise. □
The truth table for disjunction iis as follows:

P Q P \vee∨ Q

0 0 0

0 1 1

1 0 1
1 1 1

(1 = true, 0 = false)

Consider the following statement:

The elephants are green, or George wears red boots (or both).

Rewrite this using propositional logic.

We can assign propositional letters to these statements:

E: Elephants are green

G: George wears red boots.

Then, the above statement is rewritten as:

E \vee∨ G _\square□
\color{#D61F06} \textbf{Conditional}Conditional

The logical conditional is the equivalent of the expression "If A then B". The result is true if it is
consistent with that statement. The only inconsistent situation is if B is false when A is true. This
contradicts the conditional statement. So the definition is as follows:

v(P \to Q) = \left\{\begin{matrix} 0 &&& \text{if } v(P)= 1, v(Q)= 0 \\ 1 &&& \text{otherwise.} \


_\square \end{matrix}\right.v(P→Q)={01if v(P)=1,v(Q)=0otherwise. □
And this is the corresponding truth table:

P Q P \to→ Q

0 0 1

0 1 1

1 0 0

1 1 1

(1 = true, 0 = false)

Suppose we have the following statement (compound proposition):

If Rebecca finishes her homework, then she can watch Netflix.

Is this a logical conditional?


This consists of the two simple propositions that we will call P and Q:

• P: Rebecca finishes her homework.


•Q: Rebecca watches Netflix.
Then, we can set up the following conditional statement, using a conditional connective:

P \to→ Q

So, yes, this is a logical conditional. _\square□


8, red8, red, brown88, Brown

This is a famous problem in the study of deductive reasoning and


logic.
You are shown a set of four cards placed on a table, each of which has a number on one side and a colored
patch on the other side.

The visible faces of the cards show 3, 8, red and brown.

Which card(s) must you turn over in order to test the truth of the proposition that if a card shows an even
number on one face, then its opposite face is red?
\color{#D61F06} \textbf{Biconditional}Biconditional

A biconditional is a connective that represents the condition "if and only if".

It checks for whether both of the propositions evaluate to the same truth value. It can also be thought of
as (A \to B)\wedge(B \to A).(A→B)∧(B→A).

v(A \leftrightarrow B) = \left\{\begin{matrix} 1 &&& \text{if } v(A)= v(B) \\ 0 &&& \text{otherwise.}


\ _\square \end{matrix}\right.v(A↔B)={10if v(A)=v(B)otherwise. □
This is equivalent to the XNOR logic gate.

The truth table looks like this:

P Q P \leftrightarrow↔ Q

0 0 1

0 1 0

1 0 0
1 1 1

(1 = true, 0 = false)

What type of logic proposition is this?:

We will cancel the parade if and only if it rains.

This is equivalent to saying. "If it rains we will cancel the parade, and if we cancel the parade then it's
raining." Note: This doesn't imply causation. That is, it doesn't imply that because we cancelled the parade
it is raining. In fact it just means that if it isn't raining, we will definitely hold the parade.

We set up the following propositions:

• P: We will cancel the parade.


• Q: It rains.
Then we write our compound proposition as:

P \leftrightarrow QP↔Q

So, it's a biconditional. _\square□

\begin{aligned} A: &\text{ The angle is right.} \\ B: &~a^2 + b^2 = c^2. \end{aligned}A:B:


The angle is right. a2+b2=c2.
Pythagorean theorem states A \to B.A→B.
The converse says B \to A.B→A.

Together, we could claim A \leftrightarrow B.A↔B.


(p \wedge q) \vee (p \wedge q)(p∧q)∨(p∧q)(p \implies q) \wedge (q \implies p)(p⟹q)∧(q⟹p)(p \implies
q) \vee (q \implies p)(p⟹q)∨(q⟹p)(p \vee q) \implies (p \vee q)(p∨q)⟹(p∨q)
What is the logically equivalent proposition of \displaystyle{p \Leftrightarrow q}?p⇔q?
In summary, here is a truth table showing the functionality of all of the connectives:

P Q \neg¬ P P \wedge∧ Q P \vee∨ Q P \to→ Q P \leftrightarrow↔ Q

0 0 1 0 0 1 1

0 1 1 0 1 1 0

1 0 0 0 1 0 0
1 1 0 1 1 1 1

Well formed formulae

So far we have discussed the following simple propositions:

• A
• \neg¬ A
• A \wedge∧ B
• A \vee∨ B
• A \to→ B
However, we can construct much more complex propositions by combining the above simple propositions
to construct an infinite number of combinations of well formed formula, such as:

• \neg¬ [(A \wedge∧ B) \vee∨ C]


A proposition is called a "well formed formula" (or wff) if it is constructed with the following set of rules:

1. Any atomic proposition is a well formed formula.


2. If AA is a well formed formula, then \neg A¬A is also a well formed formula.
3. If AA and BB are well formed formulae, then (A \wedge B)(A∧B) is also a well formed
formula.
4. If AA and BB are well formed formulae, then (A \vee B)(A∨B) is also a well formed formula.
5. If AA and BB are well formed formulae, then (A \to B)(A→B) is also a well formed formula.
6. If AA and BB are well formed formulae, then (A \leftrightarrow B)(A↔B) is also a well
formed formula. _\square□
7. Unless constructed using only 1-6 above, then a proposition isn't a well formed formula.

2. Differentiate propositional & predicate logic


Logical reasoning forms the basis for a huge domain of computer science and mathematics. They help in
establishing mathematical arguments, valid or invalid.
1. Propositional Logic :
A proposition is basically a declarative sentence that has a truth value. Truth value can either be true or
false, but it needs to be assigned any of the two values and not be ambiguous. The purpose of using
propositional logic is to analyze a statement, individually or compositely.
For example :
The following statements :

1. If x is real, then x2 > 0


2. What is your name?
3. (a+b)2 = 100
4. This statement is false.
5. This statement is true.
Are not propositions because they do not have a truth value. They are ambiguous.
But the following statements :

1. (a+b)2 = a2 + 2ab + b2
2. If x is real, then x2 >= 0
3. If x is real, then x2 < 0
4. The sun rises in the east.
5. The sun rises in the west.
Are all propositions because they have a specific truth value, true or false.
The branch of logic that deals with proposition is propositional logic.
2. Predicate Logic :
Predicates are properties, additional information to better express the subject of the sentence. A
quantified predicate is a proposition , that is, when you assign values to a predicate with variables it can
be made a proposition.
For example :
In P(x) : x>5, x is the subject or the variable and ‘>5’ is the predicate.
P(7) : 7>5 is a proposition where we are assigning values to the variable x, and it has a truth value, i.e.
True.
The set of values that the variables of the predicate can assume is called the Universe or Domain of
Discourse or Domain of Predicate.
Difference between Propositional Logic and Predicate Logic :

Propositional Logic Predicate Logic

Propositional logic is the logic that deals with a Predicate logic is an expression consisting of variables with a
1 collection of declarative statements which have a specified domain. It consists of objects, relations and
truth value, true or false. functions between the objects.

2 It is the basic and most widely used logic. Also It is an extension of propositional logic covering predicates
known as Boolean logic. and quantification.

3 A proposition has a specific truth value, either true or


false. A predicate’s truth value depends on the variables’ value.

Predicate logic helps analyze the scope of the subject over the
predicate. There are three quantifiers : Universal Quantifier
(∀) depicts for all, Existential Quantifier (∃) depicting there
4 exists some and Uniqueness Quantifier (∃!) depicting exactly
Scope analysis is not done in propositional logic. one.

Propositions are combined with Logical Operators or


Logical Connectives like Negation(¬), Disjunction(∨),
5 Conjunction(∧), Exclusive OR(⊕), Implication(⇒), Predicate Logic adds by introducing quantifiers to the
Bi-Conditional or Double Implication(⇔). existing proposition.

6
It is a more generalized representation. It is a more specialized representation.

7
It cannot deal with sets of entities. It can deal with set of entities with the help of quantifiers.
Predicate Logic

Predicate Logic deals with predicates, which are propositions, consist of variables.

Predicate Logic - Definition

A predicate is an expression of one or more variables determined on some specific domain. A predicate with
variables can be made a proposition by either authorizing a value to the variable or by quantifying the
variable.

The following are some examples of predicates.

o Consider E(x, y) denote "x = y"


o Consider X(a, b, c) denote "a + b + c = 0"
o Consider M(x, y) denote "x is married to y."

Quantifier:

The variable of predicates is quantified by quantifiers. There are two types of quantifier in predicate logic -
Existential Quantifier and Universal Quantifier.

Existential Quantifier:

If p(x) is a proposition over the universe U. Then it is denoted as ∃x p(x) and read as "There exists at least
one value in the universe of variable x such that p(x) is true. The quantifier ∃ is called the existential
quantifier.

There are several ways to write a proposition, with an existential quantifier, i.e.,

(∃x∈A)p(x) or ∃x∈A such that p (x) or (∃x)p(x) or p(x) is true for some x ∈A.

Universal Quantifier:

If p(x) is a proposition over the universe U. Then it is denoted as ∀x,p(x) and read as "For every x∈U,p(x)
is true." The quantifier ∀ is called the Universal Quantifier.

There are several ways to write a proposition, with a universal quantifier.

∀x∈A,p(x) or p(x), ∀x ∈A Or ∀x,p(x) or p(x) is true for all x ∈A.

Negation of Quantified Propositions:

When we negate a quantified proposition, i.e., when a universally quantified proposition is negated, we obtain
an existentially quantified proposition,and when an existentially quantified proposition is negated, we obtain
a universally quantified proposition.
Unit 3
1)Breadth First Search: Breadth-First Search (BFS) is an algorithm used for traversing graphs or trees.
Traversing means visiting each node of the graph. Breadth-First Search is a recursive algorithm to search all
the vertices of a graph or a tree. BFS in python can be implemented by using data structures like a dictionary
and lists. Breadth-First Search in tree and graph is almost the same. The only difference is that the graph may
contain cycles, so we may traverse to the same node again.
As breadth-first search is the process of traversing each node of the graph, a standard BFS algorithm
traverses each vertex of the graph into two parts: 1) Visited 2) Not Visited. So, the purpose of the
algorithm is to visit all the vertex while avoiding cycles.

BFS starts from a node, then it checks all the nodes at distance one from the beginning node, then it checks
all the nodes at distance two, and so on. So as to recollect the nodes to be visited, BFS uses a queue.

The steps of the algorithm work as follow:

1. Start by putting any one of the graph’s vertices at the back of the queue.
2. Now take the front item of the queue and add it to the visited list.
3. Create a list of that vertex's adjacent nodes. Add those which are not within the visited list to the
rear of the queue.
4. Keep continuing steps two and three till the queue is empty.

Many times, a graph may contain two different disconnected parts and therefore to make sure that we have
visited every vertex, we can also run the BFS algorithm at every node.

2)Uniform Cost Search :


Algorithm for USC

• Insert RootNode into the queue.


• Repeat till queue is not empty:
• Remove the next element with the highest priority from the queue.
• If the node is a destination node, then print the cost and the path and exit

else insert all the children of removed elements into the queue with their cumulative cost as their
priorities.

Here root Node is the starting node for the path, and a priority queue is being maintained to maintain the
path with the least cost to be chosen for the next traversal. In case 2 paths have the same cost of traversal,
nodes are considered alphabetically.

3)The Depth-First Search

The Depth-First Search is a recursive algorithm that uses the concept of backtracking. It involves thorough searches
of all the nodes by going ahead if potential, else by backtracking. Here, the word backtrack means once you are moving
forward and there are not any more nodes along the present path, you progress backward on an equivalent path to
seek out nodes to traverse. All the nodes are progressing to be visited on the current path until all the unvisited nodes
are traversed after which subsequent paths are going to be selected.

The recursive method of the Depth-First Search algorithm is implemented using stack. A standard Depth-
First Search implementation puts every vertex of the graph into one in all 2 categories: 1) Visited 2) Not
Visited. The only purpose of this algorithm is to visit all the vertex of the graph avoiding cycles.

The DSF algorithm follows as:

1. We will start by putting any one of the graph's vertex on top of the stack.
2. After that take the top item of the stack and add it to the visited list of the vertex.
3. Next, create a list of that adjacent node of the vertex. Add the ones which aren't in the visited list of
vertexes to the top of the stack.
4. Lastly, keep repeating steps 2 and 3 until the stack is empty.

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

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

When we compare the above steps with DFS, we may find that DLS can also be implemented using the
queue data structure. In addition to each level of the node needs to be computed to check the finiteness and
reach of the goal node from the source node.

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.

What is A* search? Explain various stages of A* search with an example.

A* search algorithm is an algorithm which separates it from other traversal techniques. This makes A*
very smart and pushes it much ahead of other conventional algorithms.
Let’s try to understand Basic AI Concepts and comprehend how does A* algorithm work. Imagine a
huge maze, one that is too big that it takes hours to reach the endpoint manually. Once you complete it
on foot, you need to go for another one. This implies that you would end up investing a lot of time and
effort to find the possible paths in this maze. Now, you want to make it less time -consuming. To make
it easier, we will consider this maze as a search problem and will try to apply it to other possible mazes
we might encounter in the due course, provided they follow the same structure and rules.
As the first step to converting this maze into a search problem, we need to define these six things.

1. A set of prospective states we might be in


2. A beginning and end state
3. A way to decide if we’ve reached the endpoint
4. A set of actions in case of possible direction/path changes
5. A function that advises us about the result of an action
6. A set of costs incurring in different states/paths of movement
To solve the problem, we need to map the intersections to the nodes (denoted by the red dots) and all
the possible ways we can make movements towards the edges (denoted by the blue lines).
A denotes the starting point and B denotes the endpoint. We define the starting and endpoint at the
nodes A and B respectively.
If we use an uninformed search algorithm, it would be like finding a path that is blind, while an informed
algorithm for a search problem would take the path that brings you closer to your destination. For
instance, consider Rubik’s cube; it has many prospective states that you can be in and this makes the
solution very difficult. This calls for the use of a guided search algorithm to find a solution. This explains
the importance of A*.
Unlike other algorithms, A* decides to take up a step only if it is convincingly sensible and reasonable
as per its functions. This means, it never considers any non-optimal steps. This is why A* is a popular
choice for AI systems that replicate the real world – like video games and machine learning.

A* Search Algorithm Steps

Firstly, add the beginning node to the open list Then repeat the following step

In the open list, find the square with the lowest F cost – and this denotes the current square.
Now we move to the closed square.
Consider 8 squares adjacent to the current square and Ignore it if it is on the closed list, or if it is not
workable. Do the following if it is workable

Check if it is on the open list; if not, add it. You need to make the current square as this square’s a parent.
You will now record the different costs of the square like the F, G and H costs.

If it is on the open list, use G cost to measure the better path. The lower the G cost, the better the path.
If this path is better, make the current square as the parent square. Now you need to recalculate the
other scores – the G and F scores of this square.

– You’ll stop:

If you find the path, you need to check the closed list and add the target square to it.

There is no path if the open list is empty and you could not find the target square.

Step [Link] you can save the path and work backwards starting from the target square, going to the
parent square from each square you go, till it takes you to the starting square. You’ve found your path
now.

Explain the following local search strategies with examples.


1)Hill climbing algorithm:
Hill climbing algorithm is a local search algorithm which continuously moves in the direction of increasing
elevation/value to find the peak of the mountain or best solution to the problem. It terminates when it
reaches a peak value where no neighbour has a higher value.
o Hill climbing algorithm is a technique which is used for optimizing the mathematical problems. One
of the widely discussed examples of Hill climbing algorithm is Traveling-salesman Problem in which
we need to minimize the distance traveled by the salesman.
o It is also called greedy local search as it only looks to its good immediate neighbor state and not
beyond that.
o A node of hill climbing algorithm has two components which are state and value.
o Hill Climbing is mostly used when a good heuristic is available.
o In this algorithm, we don't need to maintain and handle the search tree or graph as it only keeps a
single current state.

Following are some main features of Hill Climbing Algorithm:

o Generate and Test variant: Hill Climbing is the variant of Generate and Test method. The
Generate and Test method produce feedback which helps to decide which direction to move in the
search space.
o Greedy approach: Hill-climbing algorithm search moves in the direction which optimizes the cost.
o No backtracking: It does not backtrack the search space, as it does not remember the previous states.

2) Genetic Algorithms:

Genetic Algorithms(GAs) are adaptive heuristic search algorithms that belong to the larger part of
evolutionary algorithms. Genetic algorithms are based on the ideas of natural selection and genetics.
These are intelligent exploitation of random search provided with historical data to direct the search into
the region of better performance in solution space. They are commonly used to generate high-quality
solutions for optimization problems and search problems.
Genetic algorithms simulate the process of natural selection which means those species who can adapt
to changes in their environment are able to survive and reproduce and go to next generation. In simple
words, they simulate “survival of the fittest” among individual of consecutive generation for solving a
problem. Each generation consist of a population of individuals and each individual represents a point
in search space and possible solution. Each individual is represented as a string of
character/integer/float/bits. This string is analogous to the Chromosome.
Foundation of Genetic Algorithms
Genetic algorithms are based on an analogy with genetic structure and behaviour of chromosomes of the
population. Following is the foundation of GAs based on this analogy –
1. Individual in population compete for resources and mate
2. Those individuals who are successful (fittest) then mate to create more offspring than others
3. Genes from “fittest” parent propagate throughout the generation, that is sometimes parents
create offspring which is better than either parent.
4. Thus, each successive generation is more suited for their environment.

3) Simulated annealing
Given a cost function f: R^n –> R, find an n-tuple that minimizes the value of f. Note that minimizing the
value of a function is algorithmically equivalent to maximization (since we can redefine the cost function
as 1-f).
Many of you with a background in calculus/analysis are likely familiar with simple optimization for
single variable functions. For instance, the function f(x) = x^2 + 2x can be optimized setting the first
derivative equal to zero, obtaining the solution x = -1 yielding the minimum value f(-1) = -1. This
technique suffices for simple functions with few variables. However, it is often the case that researchers
are interested in optimizing functions of several variables, in which case the solution can only be
obtained computationally.
One excellent example of a difficult optimization task is the chip floor planning problem. Imagine you’re
working at Intel and you’re tasked with designing the layout for an integrated circuit. You have a set of
modules of different shapes/sizes and a fixed area on which the modules can be placed. There are a
number of objectives you want to achieve: maximizing ability for wires to connect components, minimize
net area, minimize chip cost, etc. With these in mind, you create a cost function, taking all,
say, 1000 variable configurations and returning a single real value representing the ‘cost’ of the input
configuration. We call this the objective function, since the goal is to minimize its value.
A naive algorithm would be a complete space search — we search all possible configurations until we
find the minimum. This may suffice for functions of few variables, but the problem we have in mind
would entail such a brute force algorithm to fun in O(n!).
Due to the computational intractability of problems like these, and other NP-hard problems, many
optimization heuristics have been developed in an attempt to yield a good, albeit potentially suboptimal,
value. In our case, we don’t necessarily need to find a strictly optimal value — finding a near-optimal
value would satisfy our goal. One widely used technique is simulated annealing, by which we introduce a
degree of stochasticity, potentially shifting from a better solution to a worse one, in an attempt to escape
local minima and converge to a value closer to the global optimum.
Simulated annealing is based on metallurgical practices by which a material is heated to a high
temperature and cooled. At high temperatures, atoms may shift unpredictably, often eliminating
impurities as the material cools into a pure crystal. This is replicated via the simulated annealing
optimization algorithm, with energy state corresponding to current solution.
In this algorithm, we define an initial temperature, often set as 1, and a minimum temperature, on the
order of 10^-4. The current temperature is multiplied by some fraction alpha and thus decreased until it
reaches the minimum temperature. For each distinct temperature value, we run the core optimization
routine a fixed number of times. The optimization routine consists of finding a neighboring solution and
accepting it with probability e^(f(c) – f(n)) where c is the current solution and n is the neighboring
solution. A neighboring solution is found by applying a slight perturbation to the current solution. This
randomness is useful to escape the common pitfall of optimization heuristics — getting trapped in local
minima. By potentially accepting a less optimal solution than we currently have, and accepting it with
probability inverse to the increase in cost, the algorithm is more likely to converge near the global
optimum. Designing a neighbor function is quite tricky and must be done on a case by case basis, but
below are some ideas for finding neighbors in locational optimization problems.
• Move all points 0 or 1 units in a random direction
• Shift input elements randomly
• Swap random elements in input sequence
• Permute input sequence
• Partition input sequence into a random number of segments and permute segments
One caveat is that we need to provide an initial solution so the algorithm knows where to start. This can
be done in two ways: (1) using prior knowledge about the problem to input a good starting point and (2)
generating a random solution. Although generating a random solution is worse and can occasionally
inhibit the success of the algorithm, it is the only option for problems where we know nothing about the
landscape.
There are many other optimization techniques, although simulated annealing is a useful, stochastic
optimization heuristic for large, discrete search spaces in which optimality is prioritized over time.
Below, I’ve included a basic framework for locational-based simulated annealing (perhaps the most
applicable flavor of optimization for simulated annealing). Of course, the cost function, candidate
generation function, and neighbor function must be defined based on the specific problem at hand,
although the core optimization routine has already been implemented.

4) Local beam search

A heuristic technique is a set of criteria for determining which of multiple options will be the most
effective in achieving a particular goal. This strategy increases the efficiency of a search process by
surrendering claims of systematic and completeness of the best.
We can hope to achieve a good solution to difficult problems (such as the traveling salesman problem) in
less than exponent time if we use appropriate heuristics.
Beam Search :
A heuristic search algorithm that examines a graph by extending the most promising node in a limited
set is known as beam search.
Beam search is a heuristic search technique that always expands the W number of the best nodes at each
level. It progresses level by level and moves downwards only from the best W nodes at each level. Beam
Search uses breadth-first search to build its search tree. Beam Search constructs its search tree using
breadth-first search. It generates all the successors of the current level’s state at each level of the tree.
However, at each level, it only evaluates a W number of states. Other nodes are not taken into account.
The heuristic cost associated with the node is used to choose the best nodes. The width of the beam
search is denoted by W. If B is the branching factor, at every depth, there will always be W × B nodes
under consideration, but only W will be chosen. More states are trimmed when the beam width is
reduced.
When W = 1, the search becomes a hill-climbing search in which the best node is always chosen from
the successor nodes. No states are pruned if the beam width is unlimited, and the beam search is
identified as a breadth-first search.
The beamwidth bounds the amount of memory needed to complete the search, but it comes at the cost of
completeness and optimality (possibly that it will not find the best solution). The reason for this danger
is that the desired state could have been pruned.

Recursive best-first search (RBFS):


The recursive best-first search (RBFS) algorithm is a simple recursive algorithm that attempts to mimic
the operation of A-star search (i.e., the standard best-first search with an evaluation function that adds
up the path cost and the heuristic), but using only linear space (instead of showing an exponential space
complexity). The structure of RBFS is similar to that of recursive depth-first search (a tree-search
version), but rather than continuing indefinitely down the current path, it uses an evaluation limit to keep
track of the best alternative path available from any ancestor of the current node,

RBFS is robust and optimal (if the heuristic is admissible), but it still suffers from excessive node
regeneration due to its low memory profile, which entails a long processing time. Given enough time,
though, it can solve problems that A-star cannot solve because it runs out of memory.

2) Heuristic Functions:
Heuristic Functions in AI: As we have already seen that an informed search make use of heuristic
functions in order to reach the goal node in a more prominent way. Therefore, there are several pathways
in a search tree to reach the goal node from the current node. The selection of a good heuristic function
matters certainly. A good heuristic function is determined by its efficiency. More is the information about the
problem, more is the processing time.
Some toy problems, such as 8-puzzle, 8-queen, tic-tac-toe, etc., can be solved more efficiently with the help
of a heuristic function. Let’s see how:
Consider the following 8-puzzle problem where we have a start state and a goal state. Our task is to slide
the tiles of the current/start state and place it in an order followed in the goal state. There can be four
moves either left, right, up, or down. There can be several ways to convert the current/start state to the
goal state, but, we can use a heuristic function h(n) to solve the problem more efficiently.
Properties of a Heuristic search Algorithm:
Use of heuristic function in a heuristic search algorithm leads to following properties of a heuristic search
algorithm:

• Admissible Condition: An algorithm is said to be admissible, if it returns an optimal solution.


• Completeness: An algorithm is said to be complete, if it terminates with a solution (if the solution
exists).
• Dominance Property: If there are two admissible heuristic
algorithms A1 and A2 having h1 and h2 heuristic functions, then A1 is said to dominate A2 if h1 is
better than h2 for all the values of node n.
• Optimality Property: If an algorithm is complete, admissible, and dominating other algorithms, it
will be the best one and will definitely give an optimal solution.

Minimax Algorithm:

Minimax is a type of backtracking algorithm. The Minimax algorithm finds an optimal move to make

decisions in game theory. Minimax algorithm takes into consideration that the opponent is also

playing optimally, which makes it useful for two-player games such as checker, chess, Tic-tac-toe, go

and many others.

In general, when two human beings play, they must make the decision at each move with all the

possible moves, and then chose anyone which he thinks is the best move. The same is with the

Minimax algorithm too, but here the decision, to make a move is taken using a backtracking approach.

To do this it selects two players one is the min, and the other is max, the goal of min player is to pick

the minimum value, and on the other hand, the goal of max is to pick the maximum value.

It is a decision-making algorithm used in game theory. It considers two players min and max, and min
always picks up a minimum value score from game and max always picks up maximum value score. The
value for each game move is decided based on some heuristics.

It uses some terminology which is stated below:

• Game Tree: Tree for the game moves, it shows all the possible moves available to the player at a
particular state. The player makes an optimum decision and makes a move.

To quantify game moves, we can use the following components:

• Initial State: The state at which the game starts.


• Successor Function: The function is used to define all the available moves for the player at the
current state.
• Terminal State: This is the last state of the game which decides the winner of the game and the
game gets over.
• Utility Function: It is the most important function in this algorithm. It is that a heuristic approach
is used to assign values for each outcome from the game. The values are assigned based on the rules
of the game. The values assigned come from terminal leaves if it’s a winning move the high value
will be assigned to that move and if it’s a losing move, the low value will be assigned to that move.

Working of Minimax Algorithm


As we know what Minimax algorithm time is now to understand how it works. We will take a simple
example and then will solve it using the Minimax algorithm:

Step1: Let us take a 4-level tree generated by an algorithm, for our example (as shown below). Level zero
is Root node or initial state and is represented as RN, other respective levels with L1, L2, and L3. L1N1
represents Level 1 and Node 1; In the same way, all others are also represented.

Alpha-Beta Pruning:

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


for the minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game states it has to examine
are exponential in depth of the tree. Since we cannot eliminate the exponent, but we can cut it to half.
Hence there is a technique by which without checking each node of the game tree we can compute
the correct minimax decision, and this technique is called pruning. This involves two threshold
parameter Alpha and beta for future expansion, so it is called alpha-beta pruning. It is also called
as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the tree
leaves but also entire sub-tree.
o The two-parameter can be defined as:
1. Alpha: The best (highest-value) choice we have found so far at any point along the path of
Maximizer. The initial value of alpha is -∞.
2. Beta: The best (lowest-value) choice we have found so far at any point along the path of
Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move as the standard
algorithm does, but it removes all the nodes which are not really affecting the final decision but
making algorithm slow. Hence by pruning these nodes, it makes the algorithm fast.

The main condition which required for alpha-beta pruning is

1. α>=β

Key points about alpha-beta pruning:

o The Max player will only update the value of alpha.


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

Unit 4
1. Define and explain or Differentiate
1) Supervised 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.

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.

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

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.

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

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.

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

Here, we have taken an un labeled 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.
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.

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.

3. Reinforcement learning:

Reinforcement Learning is a feedback-based Machine learning technique in which an agent learns to


behave in an environment by performing the actions and seeing the results of actions. For each good
action, the agent gets positive feedback, and for each bad action, the agent gets negative feedback or
penalty.

In Reinforcement Learning, the agent learns automatically using feedbacks without any labeled data,
unlike supervised learning.

Since there is no labeled data, so the agent is bound to learn by its experience only.

RL solves a specific type of problem where decision making is sequential, and the goal is long-term, such
as game-playing, robotics, etc.

The agent interacts with the environment and explores it by itself. The primary goal of an agent in
reinforcement learning is to improve the performance by getting the maximum positive rewards.

The agent learns with the process of hit and trial, and based on the experience, it learns to perform the
task in a better way. Hence, we can say that "Reinforcement learning is a type of machine learning
method where an intelligent agent (computer program) interacts with the environment and learns
to act within that." How a Robotic dog learns the movement of his arms is an example of Reinforcement
learning.

It is a core part of Artificial intelligence, and all AI agent works on the concept of reinforcement learning.
Here we do not need to pre-program the agent, as it learns from its own experience without any human
intervention.

Example: Suppose there is an AI agent present within a maze environment, and his goal is to find the
diamond. The agent interacts with the environment by performing some actions, and based on those
actions, the state of the agent gets changed, and it also receives a reward or penalty as feedback.

The agent continues doing these three things (take action, change state/remain in the same state,
and get feedback), and by doing these actions, he learns and explores the environment.

The agent learns that what actions lead to positive feedback or rewards and what actions lead to negative
feedback penalty. As a positive reward, the agent gets a positive point, and as a penalty, it gets a negative
point.
Terms used in Reinforcement Learning

o Agent(): An entity that can perceive/explore the environment and act upon it.
o Environment(): A situation in which an agent is present or surrounded by. In RL, we assume the
stochastic environment, which means it is random in nature.
o Action(): Actions are the moves taken by an agent within the environment.
o State(): State is a situation returned by the environment after each action taken by the agent.
o Reward(): A feedback returned to the agent from the environment to evaluate the action of the agent.
o Policy(): Policy is a strategy applied by the agent for the next action based on the current state.
o Value(): It is expected long-term retuned with the discount factor and opposite to the short-term
reward.
o Q-value(): It is mostly similar to the value, but it takes one additional parameter as a current action
(a).

Key Features of Reinforcement Learning

o In RL, the agent is not instructed about the environment and what actions need to be taken.
o It is based on the hit and trial process.
o The agent takes the next action and changes states according to the feedback of the previous action.
o The agent may get a delayed reward.
o The environment is stochastic, and the agent needs to explore it to reach to get the maximum positive
rewards.

Approaches to implement Reinforcement Learning

There are mainly three ways to implement reinforcement-learning in ML, which are:

1. Value-based:
The value-based approach is about to find the optimal value function, which is the maximum value
at a state under any policy. Therefore, the agent expects the long-term return at any state(s) under
policy π.
2. Policy-based:
Policy-based approach is to find the optimal policy for the maximum future rewards without using
the value function. In this approach, the agent tries to apply such a policy that the action performed
in each step helps to maximize the future reward.
The policy-based approach has mainly two types of policy:
o Deterministic: The same action is produced by the policy (π) at any state.
o Stochastic: In this policy, probability determines the produced action.
3. Model-based: In the model-based approach, a virtual model is created for the environment, and the
agent explores that environment to learn it. There is no particular solution or algorithm for this
approach because the model representation is different for each environment.

Elements of Reinforcement Learning

There are four main elements of Reinforcement Learning, which are given below:

1. Policy
2. Reward Signal
3. Value Function
4. Model of the environment

1) Policy: A policy can be defined as a way how an agent behaves at a given time. It maps the perceived
states of the environment to the actions taken on those states. A policy is the core element of the RL as it
alone can define the behavior of the agent. In some cases, it may be a simple function or a lookup table,
whereas, for other cases, it may involve general computation as a search process.

2) Reward Signal: The goal of reinforcement learning is defined by the reward signal. At each state, the
environment sends an immediate signal to the learning agent, and this signal is known as a reward signal.
These rewards are given according to the good and bad actions taken by the agent. The agent's main
objective is to maximize the total number of rewards for good actions. The reward signal can change the
policy, such as if an action selected by the agent leads to low reward, then the policy may change to select
other actions in the future.

3) Value Function: The value function gives information about how good the situation and action are and
how much reward an agent can expect. A reward indicates the immediate signal for each good and bad
action, whereas a value function specifies the good state and action for the future. The value function
depends on the reward as, without reward, there could be no value. The goal of estimating values is to
achieve more rewards.

4) Model: The last element of reinforcement learning is the model, which mimics the behavior of the
environment. With the help of the model, one can make inferences about how the environment will behave.
Such as, if a state and an action are given, then a model can predict the next state and reward.

The model is used for planning, which means it provides a way to take a course of action by considering all
future situations before actually experiencing those situations. The approaches for solving the RL
problems with the help of the model are termed as the model-based approach. Comparatively, an
approach without using a model is called a model-free approach.
Decision Tree Algorithm:

o Decision Tree is a Supervised learning technique that can be used for both classification and
Regression problems, but mostly it is preferred for solving Classification problems. It is a tree-
structured classifier, where internal nodes represent the features of a dataset, branches
represent the decision rules and each leaf node represents the outcome.
o In a Decision tree, there are two nodes, which are the Decision Node and Leaf Node. Decision
nodes are used to make any decision and have multiple branches, whereas Leaf nodes are the output
of those decisions and do not contain any further branches.
o The decisions or the test are performed on the basis of features of the given dataset.
o It is a graphical representation for getting all the possible solutions to a problem/decision
based on given conditions.
o It is called a decision tree because, similar to a tree, it starts with the root node, which expands on
further branches and constructs a tree-like structure.
o In order to build a tree, we use the CART algorithm, which stands for Classification and
Regression Tree algorithm.
o A decision tree simply asks a question, and based on the answer (Yes/No), it further split the tree
into subtrees.
o Below diagram explains the general structure of a decision tree:

Why use Decision Trees?

There are various algorithms in Machine learning, so choosing the best algorithm for the given dataset and
problem is the main point to remember while creating a machine learning model. Below are the two reasons
for using the Decision tree:

o Decision Trees usually mimic human thinking ability while making a decision, so it is easy to
understand.
o The logic behind the decision tree can be easily understood because it shows a tree-like structure.

Decision Tree Terminologies

• Root Node: Root node is from where the decision tree starts. It represents the entire dataset,
which further gets divided into two or more homogeneous sets.
• Leaf Node: Leaf nodes are the final output node, and the tree cannot be segregated further after
getting a leaf node.
• Splitting: Splitting is the process of dividing the decision node/root node into sub-nodes according
to the given conditions.
• Branch/Sub Tree: A tree formed by splitting the tree.
• Pruning: Pruning is the process of removing the unwanted branches from the tree.
• Parent/Child node: The root node of the tree is called the parent node, and other nodes are called
the child nodes.

How does the Decision Tree algorithm Work?

In a decision tree, for predicting the class of the given dataset, the algorithm starts from the root node of the
tree. This algorithm compares the values of root attribute with the record (real dataset) attribute and, based
on the comparison, follows the branch and jumps to the next node.

For the next node, the algorithm again compares the attribute value with the other sub-nodes and move
further. It continues the process until it reaches the leaf node of the tree. The complete process can be better
understood using the below algorithm:

o Step-1: Begin the tree with the root node, says S, which contains the complete dataset.
o Step-2: Find the best attribute in the dataset using Attribute Selection Measure (ASM).
o Step-3: Divide the S into subsets that contains possible values for the best attributes.
o Step-4: Generate the decision tree node, which contains the best attribute.
o Step-5: Recursively make new decision trees using the subsets of the dataset created in step -3.
Continue this process until a stage is reached where you cannot further classify the nodes and called
the final node as a leaf node.

Example: Suppose there is a candidate who has a job offer and wants to decide whether he should accept the
offer or Not. So, to solve this problem, the decision tree starts with the root node (Salary attribute by ASM).
The root node splits further into the next decision node (distance from the office) and one leaf node based
on the corresponding labels. The next decision node further gets split into one decision node (Cab facility)
and one leaf node. Finally, the decision node splits into two leaf nodes (Accepted offers and Declined offer).
Consider the below diagram:
Advantages of the Decision Tree

o It is simple to understand as it follows the same process which a human follow while making any
decision in real-life.
o It can be very useful for solving decision-related problems.
o It helps to think about all the possible outcomes for a problem.
o There is less requirement of data cleaning compared to other algorithms.

Disadvantages of the Decision Tree

o The decision tree contains lots of layers, which makes it complex.


o It may have an overfitting issue, which can be resolved using the Random Forest algorithm.
o For more class labels, the computational complexity of the decision tree may increase.

How the performance of a learning algorithm is assessed? Draw a learning curve for the decision tree
algorithm.
The learning curve is very useful to determine if an algorithm is working correctly and to improve the
performance of an algorithm. It is useful to determine if an algorithm is suffering from bias or underfitting,
a variance or overfishing, or a bit of both.

If your machine learning algorithm is not working as expected, what to do next? There are several
options:

1. Getting more training data which is very time-consuming. It may even take months to obtain
more research data.
2. Getting more training features. It may also take a lot of time. But if adding some polynomial
features works, that is cool.
3. Selecting a smaller set of training features.
4. Increasing regularization term
5. Decreasing the regularization term.
So, which one should you try next? This is not a good idea to start trying just anything. Because you may
end up spending too much time on something that is not helpful. You need to detect the problem first and
then take action accordingly. A learning curve helps to detect the problem easily which saves a lot of time.

How Learning Curve Works

The learning curve is the plot of the cost function. The cost function for the training data and the cost
function for the cross-validation data in the same plot gives important insights about the algorithm. As a
reminder, here is the formula for the cost function:
In other words, it is squared of the predicted output minus the original output divided by twice the number
of training data. To make the learning curve, we need to plot these cost functions as a function of the
number of training data (m). Instead of using all the training data, we will use only a smaller subset of
training data to train the data.

Have a look at the picture below:

Here is the concept. If we train the data with a too-small number of data, the algorithm will fit perfectly on
the training data and the cost function will return 0. In the picture above it is showing clearly that when
we train the data with only one, two, or three data algorithms can learn that few data very well and
training cost comes out to be zero or close to zero. But this type of algorithm cannot perform well on other
data. When you will try to fit the cross-validation data on this algorithm, the probability is very high that
it will perform poorly on cross-validation data. So, the cost function for cross-validation data will return a
very high value. On the other hand, when we will take more and more data to train the algorithm, it will
not fit in the training data perfectly anymore. So, the training cost will become higher. At the same time,
as this algorithm is trained on a lot of data, it will perform better on the cross-validation data and the cost
function for cross-validation data will return a lower value. Here is how to develop a learning curve.

What is reinforcement learning? Explain (a) Passive reinforcement learning (b) Active reinforcement
learning.

Reinforcement Learning is a feedback-based Machine learning technique in which an agent learns to


behave in an environment by performing the actions and seeing the results of actions. For each good
action, the agent gets positive feedback, and for each bad action, the agent gets negative feedback or
penalty.
In Reinforcement Learning, the agent learns automatically using feedbacks without any labeled data,
unlike supervised learning.

Since there is no labeled data, so the agent is bound to learn by its experience only.

RL solves a specific type of problem where decision making is sequential, and the goal is long-term, such
as game-playing, robotics, etc.

The agent interacts with the environment and explores it by itself. The primary goal of an agent in
reinforcement learning is to improve the performance by getting the maximum positive rewards.

The agent learns with the process of hit and trial, and based on the experience, it learns to perform the
task in a better way. Hence, we can say that "Reinforcement learning is a type of machine learning
method where an intelligent agent (computer program) interacts with the environment and learns
to act within that." How a Robotic dog learns the movement of his arms is an example of Reinforcement
learning.

It is a core part of Artificial intelligence, and all AI agent works on the concept of reinforcement learning.
Here we do not need to pre-program the agent, as it learns from its own experience without any human
intervention.

Example: Suppose there is an AI agent present within a maze environment, and his goal is to find the
diamond. The agent interacts with the environment by performing some actions, and based on those
actions, the state of the agent gets changed, and it also receives a reward or penalty as feedback.

The agent continues doing these three things (take action, change state/remain in the same state,
and get feedback), and by doing these actions, he learns and explores the environment.

The agent learns that what actions lead to positive feedback or rewards and what actions lead to negative
feedback penalty. As a positive reward, the agent gets a positive point, and as a penalty, it gets a negative
point.

Explain in detail about Bayes' Rule and Its Use:

In statistics and probability theory, the Bayes’ theorem (also known as the Bayes’ rule) is a mathematical
formula used to determine the conditional probability of events. Essentially, the Bayes’ theorem describes
the probability of an event based on prior knowledge of the conditions that might be relevant to the event.

The theorem is named after English statistician, Thomas Bayes, who discovered the formula in 1763. It is
considered the foundation of the special statistical inference approach called the Bayes’ inference.

Besides statistics, the Bayes’ theorem is also used in various disciplines, with medicine and pharmacology as
the most notable examples. In addition, the theorem is commonly employed in different fields of finance.
Some of the applications include but are not limited to, modeling the risk of lending money to borrowers or
forecasting the probability of the success of an investment.
Formula for Bayes’ Theorem

The Bayes’ theorem is expressed in the following formula:

Where:

• P(A|B) – the probability of event A occurring, given event B has occurred


• P(B|A) – the probability of event B occurring, given event A has occurred
• P(A) – the probability of event A
• P(B) – the probability of event B

Note that events A and B are independent events (i.e., the probability of the outcome of event A does not
depend on the probability of the outcome of event B).

A special case of the Bayes’ theorem is when event A is a binary variable. In such a case, the theorem is
expressed in the following way:

Example of Bayes’ Theorem

Imagine you are a financial analyst at an investment bank. According to your research of publicly-traded
companies, 60% of the companies that increased their share price by more than 5% in the last three years
replaced their CEOs during the period.

At the same time, only 35% of the companies that did not increase their share price by more than 5% in the
same period replaced their CEOs. Knowing that the probability that the stock prices grow by more than
5% is 4%, find the probability that the shares of a company that fires its CEO will increase by more than
5%.

Before finding the probabilities, you must first define the notation of the probabilities.

• P(A) – the probability that the stock price increases by 5%


• P(B) – the probability that the CEO is replaced
• P(A|B) – the probability of the stock price increases by 5% given that the CEO has been replaced
• P(B|A) – the probability of the CEO replacement given the stock price has increased by 5%.

Using the Bayes’ theorem, we can find the required probability:

Thus, the probability that the shares of a company that replaces its CEO will grow by more than 5% is
6.67%.
What is Semantics of Bayesian Networks. Explain how inference can be achieved in Bayesian
Networks.

Bayesian neural networks are a popular type of neural network due to their ability to quantify the
uncertainty in their predictive output.

In contrast to other neural networks, bayesian neural networks train the model weights as a distribution
rather than searching for an optimal value. This makes them more robust and allows them to generalize
better with less overfitting.

With standard neural networks, the weights between the different layers of the network take single values.
In a bayesian neural network the weights take on probability distributions. The process of finding these
distributions is called marginalization.

One important factor for training these networks is having a large enough set of training data to produce
accurate probability distributions. Want to learn about methods for quickly increasing the size of your
training data set? Check out my post about Data Augmentation!

Probabilistic neural networks (PNNs) are a type of neural network that have outputs which are themselves
a probability distribution.

The standard form of a bayesian neural network still outputs a single point estimate. If the network is run
multiple times with the same inputs, this single point estimate will vary.

This is due to the nature of the network’s weights being probability distributions.

In contrast, a probabilistic neural network will output a distribution as the output. These two techniques
can be combined to produce a probabilistic bayesian neural network where both the network weights and
the network outputs are distributions.

Bayesian (Deep) Learning a.k.a. Bayesian Inference


In statistics, Bayesian inference is a method of estimating the posterior probability of a hypothesis, after
taking into account new evidence. The Bayesian approach to inference is based on the belief that all
relevant information is represented in the data.

In other words, the data contains all the information needed to make a decision. This contrasts with
frequentist inference, which relies on samples from a population.

Bayesian inference starts with a prior probability distribution (the belief before seeing any data), and then
uses the data to update this distribution. The posterior probability is the updated belief after taking into
account the new data.

One of the main benefits of Bayesian inference is that it can be used to model uncertainty, and this
posterior distribution output is the mechanism by which a bayesian probabilistic neural network will create
the posterior distribution as output.

Advantages and Disadvantages of Bayesian Neural Networks


There are many advantages to using Bayesian neural networks. Some of these include:

• They are more robust and able to generalize better than other neural networks.
• They can quantify the uncertainty in their predictive output.
• They can be used for many practical applications.
There are also some disadvantages to using Bayesian neural networks which we will now discuss.
Some disadvantages include:

• They can be more complicated to train than other neural networks, and require knowledge of
the fields of probability and statistics.
• They can be slower to converge than other neural networks and often require more data. Since
the weights of the network are distributions instead of single values, more data is required to
estimate the weights accurately.

Unit 5

1. Distinguish between semantics, pragmatics and discourse:

What is Semantics?

Semantics

Semantics springs out of the Greek word ‘Semanticos’ or ‘sema’ which means meaning. It is defined as the
study of meaning in a communicative human language. Griffiths says “Semantics is the study of the
“toolkit” for meaning: knowledge encoded in the vocabulary of the language and in its patterns for building
more elaborate meanings, up to the level of sentence meanings” (Pg 1).

It is difficult to establish in a very clear term what ‘meaning’ as a word means. This is because one uses
language to teach language. While one uses some words to explain the meaning of another words, there
may be need to also give the meanings of the words used in the definitions. For example, Biology is the study
of living things and their environment. There may be a need to go on defining living, environment, study and
others.

What is Pragmatics?

Pragmatics

We may say that understanding the meaning of a proposition begins at the semantic level, where semantic
analysis fails; Pragmatics and Discuss Analysis come in. This is because Pragmatics and discuss analysis
fetch meaning below the surface. Pragmatics is concerned with meaning within context of use which can
be user or situation related. For instance if a person says, “I will give you a job.” The hearer will examine
the truth of the statement by finding out if the speaker is capable of carrying out he has said.

Semantics is the Study of the “toolkit” for meaning: knowledge encoded in the vocabulary of the language
and in its patterns for building more elaborate meanings, up to the level of sentence
meanings. Pragmatics is concerned with the use of these tools in meaningful communication. Pragmatics
is about the interaction of semantic knowledge with our knowledge of the world, taking into account
contexts of use.
In semantics, we have to consider a speaker’s semantic knowledge which is not an easy task however we
can start by stating that the individual would know the definition of the word-definitions theory.

The meaning of the word must exist in the minds of the speaker and hearer of the language. In the same
way there is need also to know what particular words mean in context.

For instance, ‘it’s getting late’ will be different if said to a friend at a party. It would probably meaning,
‘let’s leave’. In any way we talk about pragmatics and discuss analysis, we are talking about semantics.

Among the things pragmatics study addresses are:

• Speech act theory


• Felicity conditions
• Conversational implicature
• The cooperative principle

DISCOURSE ANALYSIS

The term Discuss Analysis first came into general use in 1952, following publication activities in the media
environment. There was the need for establishing coherence in discourse and explicitness in sentence
transformation to put texts in canonical forms. Works need to be related in terms of their point of
discourse are placed together in columns.

Discourse is made up of sentences used by interlocutors, and through linguistic analysis we have a better
understanding of how discussants get along. Novels, histories, arguments and other type of discourse are
activities with their own character and convectional structures. Discussants draw on discourse knowledge
to construct interpretations. They always share knowledge of previous activities surrounding their subject
of discussion if the discourse must be a success. Discuss analysis is also a linguistic phenomenon that deals
with meaning analysis but from above phonological and syntax level. Meaning is analyzed based on
background knowledge of the subject under discussion share between the interlocutors. Now, a third party
can only analyze the discussion.

Modes of discourse include narrative, descriptive, report, information and argument among others. They
provide data for the discourse analyst.

There are linguistic correlates to the features of discourse. Knowledge of ones language includes
knowledge of forms and knowledge. It is a human activity with language at the centre. It is concerned with
writing, conversation, communicative event and turns at talk.

Give any 3 different evaluation metrics available for text classification?

You might also like