Professional Documents
Culture Documents
What is AI Technique?
68
68
AI Techniques
• The techniques are concerned with how we represent, manipulate and
reason with knowledge in order to solve problems.
Example
• Techniques, not all "intelligent" but used to behave as intelligent
- Describe and match, Constraint satisfaction
- Tree Searching
-Rule based systems
• Biology-inspired AI techniques are currently popular
-Neural Networks- Genetic Algorithms
- Reinforcement learning
69
69
1
3/9/2022
70
70
71
71
2
3/9/2022
72
72
73
73
3
3/9/2022
If we have 2 disks:
•First we move the smaller one (top) disk to aux peg
•Then we move the larger one (bottom) disk to
destination peg
•And finally, we move the smaller one from aux to
destination peg.
74
74
4
3/9/2022
76
77
5
3/9/2022
78
79
79
6
3/9/2022
80
Example: Map-Coloring
81
7
3/9/2022
82
83
83
8
3/9/2022
84
84
85
9
3/9/2022
Working Memory
86
86
Rule Base
• RB contains rules; each rule is a step in a problem solving.
• Rules are domain knowledge and modified only from outside.
• Rule syntax is IF <condition> THEN <action>
e.g. IF <(temperature, over, 20> THEN <add (ocean, swimable, yes)>
• If the conditions are matched to the working memory and if fulfilled
then rule may be fired.
• RB actions are :
- “Add” fact(s) to WM;
-“Remove” fact(s) from WM;
-“Modify” fact(s) in WM;
87
87
10
3/9/2022
Interpreter
▪ It is the domain independent reasoning mechanism for RBS.
▪ It selects rule from Rule Base and applies by performing action.
▪ It operates on a cycle:
Retrieval - Finds the rules that matches the current
WM;
Refinement - Prunes, reorders and resolves conflicts;
Execution - Executes the actions of the rules in the
Conflict Set, then applies the rule by performing action.
88
88
89
11
3/9/2022
90
90
Search Terminology
91
91
12
3/9/2022
Tree Searching
▪ Many problems (e.g. goal reduction, constraint networks) can be described in the form of a
search tree. A solution to the problem is obtained by finding a path through this tree.
▪ A search through the entire tree, until a satisfactory path is found, is called exhaustive
searchش امله.
▪ They are most simple, as they do not need any domain-specific knowledge. They work fine
with small number of possible states.
▪ Requirements−
▪ State description
▪ A set of valid operators
▪ Initial state
▪ Goal state description
• Exhaustive search (or uninformed search or Brute-Force Search Strategies)
–Breadth-first search: Use a queue to implement
• Search nodes each level at a time
–Depth-first search: Use a stack to implement
• Search nodes path at a time
92
92
L M N O P Q
Goal nodes
93
93
13
3/9/2022
Depth-first searching
• A depth-first search (DFS)
explores a path all the way to a
A leaf before backtracking and
exploring another path
• For example, after searching
B C A, then B, then D, the
search backtracks and tries
D E F G another path from B
• Node are explored in the order
A BDEHLMNIOP CF
H I J K
GJKQ
• N will be found before J
L M N O P Q
94
Breadth-first searching
95
14
3/9/2022
96
Backtracking
▪ Backtracking is a technique used to solve problems
with a large search space, by systematically trying
and eliminating possibilities.
▪ similar to the brute force approach where it tries all
of the solutions but the only difference is that it
eliminates/avoids the partial candidate solutions as
soon as it finds that that path cannot lead to a
solution.
▪ A standard example of backtracking would be going
through a maze. At some point in a maze, you might
have two options of which direction to go.
97
97
15
3/9/2022
Portion A
"backtrack"to the junction.
98
98
99
16
3/9/2022
100
101
101
17
3/9/2022
102
102
103
103
18
3/9/2022
104
104
http://www.hbmeyer.de/backtrack/achtdamen/nQueens.htm
https://sadakurapati.wordpress.com/category/game/
105
19
3/9/2022
Solution
▪ In chess, queens can move all
the way down any row, column
or diagonal (so long as
no pieces are in the way). 1 2 3 4
–Due to the first two 1
restrictions, it's clear that each 2
row and column of the board
will have exactly one queen. 3
4
• We can divide this problem
into a sub problem of placing
single queen on the
chess board.
106
106
107
107
20
3/9/2022
X1 X2
1 2 3 4 {1,2,3,4} {1,2,3,4}
1
2
3
4
X3 X4
{1,2,3,4} {1,2,3,4}
108
X1 X2
1 2 3 4 {1,2,3,4} {1,2,3,4}
1
2
3
4
X3 X4
{1,2,3,4} {1,2,3,4}
109
21
3/9/2022
X1 X2
1 2 3 {1,2,3,4} { , ,3,4}
4
1
2
3
4 X3 X4
{ ,2, ,4} { ,2,3, }
110
X1 X2
1 2 3 {1,2,3,4} { , ,3,4}
4
1
2
3
4 X3 X4
{ ,2, ,4} { ,2,3, }
111
22
3/9/2022
X1 X2
1 2 3 {1,2,3,4} { , ,3,4}
4
1
2
3
4 X3 X4
{ , , , } { ,2, , }
112
X1 X2
1 2 3 {1,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{ ,2, ,4} { ,2,3, }
113
23
3/9/2022
X1 X2
1 2 3 {1,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{ ,2, , } { , ,3, }
114
X1 X2
1 2 3 {1,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{ ,2, , } { , ,3, }
115
24
3/9/2022
X1 X2
1 2 3 {1,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{ ,2, , } { , , , }
116
X1 X2
1 2 3 { ,2,3,4} {1,2,3,4}
4
1
2
3
4 X3 X4
{1,2,3,4} {1,2,3,4}
117
25
3/9/2022
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, ,3, } {1, ,3,4}
118
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, ,3, } {1, ,3,4}
119
26
3/9/2022
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, , , } {1, ,3, }
120
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, , , } {1, ,3, }
121
27
3/9/2022
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, , , } { , ,3, }
122
X1 X2
1 2 3 { ,2,3,4} { , , ,4}
4
1
2
3
4 X3 X4
{1, , , } { , ,3, }
123
28
3/9/2022
124
124
A * Search
It is best-known form of Best First search. It avoids expanding paths that
are already expensive, but expands most promising paths first.
f(n) = g(n) + h(n), where
• g(n) the cost (so far) to reach the node
• h(n) estimated cost to get from the node to the goal
• f(n) estimated total cost of path through n to goal. It is implemented using priority
queue by increasing f(n).
125
125
29
3/9/2022
Hill-Climbing Search
It is an iterative algorithm خوارزمية ت كراريةthat starts with an arbitraryت عسفي
solution to a problem and attempts to find a better solution by changing a
single element of the solution incrementallyت دريجيا. If the change produces
a better solution, an incremental change is taken as a new solution. This
process is repeated until there are no further improvements.
126
127
30
3/9/2022
Annealing is the process of heating and cooling a metal to change its internal structure
for modifying its physical properties. When the metal cools, its new structure is seized,
and the metal retains its newly obtained properties. In simulated annealing process, the
temperature is kept variable.
We initially set the temperature high and then allow it to ‘cool' slowly as the algorithm
proceeds. When the temperature is high, the algorithm is allowed to accept worse
solutions with high frequency.
Start
• Initialize k = 0; L = integer number of variables;
• From i →j, search the performance difference Δ.
• If Δ <= 0 then accept else if exp(-Δ/T(k)) > random(0,1) then accept;
• Repeat steps 1 and 2 for L(k) steps.
• k = k + 1;
End
128
128
129
129
31
3/9/2022
CERTAINLY YES
POSSIBLY YES
CANNOT SAY
POSSIBLY NO
CERTAINLY NO
130
130
Sx is Sm all
131
131
32
3/9/2022
Membership Function
Membership functions allow you to quantify linguistic term and represent a fuzzy
set graphically. A membership functionfor a fuzzy set Aon the universe of
discourse X is defined as μA:X →[0,1].
132
132
All membership functions for LP, MP, S, MN,and LNare shown as below
−
The triangular membership function shapes are most common among various
other membership function shapes such as trapezoidal, singleton, and Gaussian.
Here, the input to 5-level fuzzifier varies from -10 volts to +10 volts. Hence
the corresponding output also changes.
133
133
33
3/9/2022
Algorithm
• Define linguistic Variables and terms
(start)
• Construct membership functions for
them. (start)
• Construct knowledge base of rules
(start)
• Convert crisp data into fuzzy data sets
using membership functions.
(fuzzification)
• Evaluate rules in the rule base.
(Inference Engine)
• Combine results from each rule.
(Inference Engine)
• Convert output data into non-fuzzy
values. (defuzzification)
134
134
Development
Step 1−Define linguistic variables and terms
Linguistic variables are input and output variables in the form of simple words
or sentences. For room temperature, cold, warm, hot, etc., are linguistic terms.
Temperature (t) = {very-cold, cold, warm, very-warm, hot}
Every member of this set is a linguistic term and it can cover some portion
of overall temperature values.
135
135
34
3/9/2022
RoomTemp.
/Target Very_Cold Cold Warm Hot Very_Hot
Build a set of rules into the knowledge base in the form of IF-THEN-ELSE structures.
136
137
137
35
3/9/2022
138
138
Advantages of FLSs
• Mathematical concepts within fuzzy reasoning are very simple.
• You can modify a FLS by just adding or deleting rules due to flexibility of
fuzzy logic.
• Fuzzy logic Systems can take imprecise, distorted, noisy input information.
• FLSs are easy to construct and understand.
• Fuzzy logic is a solution to complex problems in all fields of life, including
medicine, as it resembles human reasoning and decision making.
Disadvantages of FLSs
• There is no systematic approach to fuzzy system designing.
• They are understandable only when simple.
• They are suitable for the problems which do not need high accuracy.
139
139
36
3/9/2022
Neural Networks
Yet another research area in AI, neural networks, is inspired from the natural
neural network of human nervous system.
140
140
Neural Networks
Basic Structure of ANNs
The idea of ANNs is based on the belief that working of human brain by making
the right connections, can be imitated using silicon and wires as living neuronsand
dendrites.
The human brain is composed of 86 billion nerve cells called neurons.They are
connected to other thousand cells by Axons.Stimuli from external environment or
inputs from sensory organs are accepted by dendrites. These inputs create electric
impulses, which quickly travel through the neural network. A neuron can then send
the message to other neuron to handle the issue or does not send it forward.
141
141
37
3/9/2022
Neural Networks
ANNs are composed of multiple nodes, which imitate biological neuronsof human
brain. The neurons are connected by links and they interact with each other. The
nodes can take input data and perform simple operations on the data. The result
of these operations is passed to other neurons. The output at each node is called
its activationor node value.
Each link is associated with weight.ANNs are capable of learning, which takes
place by altering weight values. The following illustration shows a simple ANN
−
142
142
Neural Networks
FeedForward ANN
In this ANN, the information flow is unidirectional. A unit sends information to other
unit from which it does not receive any information. There are no feedback loops.
They are used in pattern generation/recognition/classification. They have fixed
inputs and outputs.
143
143
38
3/9/2022
Neural Networks
FeedBack ANN
Here, feedback loops are allowed. They are used in content
addressable memories.
Working of ANNs
In the topology diagrams shown, each arrow
represents a connection between two neurons and
indicates the pathway for the flow of information.
Each connection has a weight, an integer number
that controls the signal between the two neurons.
If the network generates a “good or desired”
output, there is no need to adjust the weights.
However, if the network generates a “poor or
undesired” output or an error, then the system
alters the weights in order to improve subsequent
results.
144
144
Neural Networks
Machine Learning in ANNs
ANNs are capable of learning and they need to be trained. There are several learning
strategies −
• Supervised Learning−It involves a teacher that is scholar than the ANN itself.
For example, the teacher feeds some example data about which the teacher
already knows the answers. For
example, pattern recognizing. The ANN comes up with guesses while
recognizing. Then the teacher provides the ANN with the answers. The network
then compares it guesses with the teacher’s “correct” answers and makes
adjustments according to errors.
• Unsupervised Learning−It is required when there is no example data set with
known answers. For example, searching for a hidden pattern. In this case,
clustering i.e. dividing a set of elements into groups according to some unknown
pattern is carried out based on the existing data sets present.
• Reinforcement Learning−This strategy built on observation. The ANN makes
a decision by observing its environment. If the observation is negative, the
network adjusts its weights to be able to make a different required decision the
next time.
145
39
3/9/2022
Task
- Learn how to behave successfully to achieve a goal
while interacting with an external environment
- Learn via experiences!
Examples
Game playing: player knows whether it win or lose, but not know
how to move at each step
Control: a traffic system can measure the delay of cars, but
not
know how to decrease it.
146
146
Neural Networks
Applications of Neural Networks
They can perform tasks that are easy for a human but difficult for a machine −
• Aerospace−Autopilot aircrafts, aircraft fault detection.
• Automotive−Automobile guidance systems.
• Military−Weapon orientation and steering, target tracking, object discrimination, facial
recognition, signal/image identification.
• Electronics−Code sequence prediction, IC chip layout, chip failure analysis, machine vision,
voice synthesis.
• Financial−Real estate appraisal, loan advisor, mortgage screening, corporate bond rating,
portfolio trading program, corporate financial analysis, currency value prediction, document
readers, credit application evaluators.
• Industrial−Manufacturing process control, product design and analysis, quality inspection
systems, welding quality analysis, paper quality prediction, chemical product design analysis,
dynamic modeling of chemical process systems, machine maintenance analysis, project bidding,
planning, and management.
• Medical−Cancer cell analysis, EEG and ECG analysis, prosthetic design, transplant time
optimizer.
• Speech−Speech recognition, speech classification, text to speech conversion.
• Telecommunications−Image and data compression, automated information services, real-time
spoken language translation.
• Transportation−Truck Brake system diagnosis, vehicle scheduling, routing systems.
• Software−Pattern Recognition in facial recognition, optical character recognition, etc.
• Time Series Prediction−ANNs are used to make predictions on stocks and natural calamities.
• Signal Processing−Neural networks can be trained to process an audio signal and filter it
appropriately in the hearing aids.
• Control−ANNs are often used to make steering decisions of physical vehicles.
• Anomaly Detection−As ANNs are expert at recognizing patterns, they can also be trained to
generate an output when something unusual occurs that misfits the pattern.
147
147
40
3/9/2022
148
149
149
41
3/9/2022
150
150
151
151
42
3/9/2022
152
Regression in AI
153
43
3/9/2022
• Now, the company wants to do the advertisement of $200 in the year 2019and
wants to know the prediction about the sales for this year. So to solve such type of
prediction problems in machine learning, we need regression analysis.
154
155
44
3/9/2022
Types of Regression
156
Linear Regression:
• Linear regression is a statistical regression method which is
used for predictive analysis.
• It is one of the very simple and easy algorithms which works
on regression and shows the relationship between the
continuous variables.
• It is used for solving the regression problem in machine learning.
• Linear regression shows the linear relationship between the
independent variable (X-axis) and the dependent variable (Y-axis),
hence called linear regression.
• If there is only one input variable (x), then such linear regression
is calledsimple linear regression. And if there is more than one
input variable, then such linear regression is calledmultiple linear
regression.
• The relationship between variables in the linear regression
model can be explained using the below image. Here we are
predicting the salary of an employee on the basis ofthe year of
experience.
157
45
3/9/2022
Linear Regression:
158
Logistic Regression:
159
46
3/9/2022
Logistic Regression:
• It uses the concept of threshold levels, values above the threshold level are
rounded up to 1, and values below the threshold level are rounded up to 0.
• There are three types of logistic regression:
–Binary(0/1, pass/fail)
–Multi(cats, dogs, lions)
–Ordinal(low, medium, high)
160
Polynomial Regression:
161
47
3/9/2022
Polynomial Regression:
• The equation for polynomial regression also derived from linear regression
equation that means Linear regression equation Y= b0+ b1x, is transformed
into Polynomial regression equation Y= b0+b1x+ b2x2+ b3x3+.....+ bnxn.
• Here Y is thepredicted/target output, b 0, b1,... bn are the
regression coefficients. x is ourindependent/input variable.
• The model is still linear as the coefficients are still linear with quadratic
162
163
48
3/9/2022
• Here, the blue line is called hyperplane, and the other two lines are known as boundary lines.
164
165
49
3/9/2022
166
167
50
3/9/2022
168
Ridge Regression:
• Ridge regression is one of the most robust versions of linear regression in
which a small amount of bias is introduced so that we can get better long
term predictions.
• The amount of bias added to the model is known asRidge Regression
penalty. We can compute this penalty term by multiplying with the lambda to
the squared weight of each individual features.
• The equation for ridge regression will be:
169
51
3/9/2022
Lasso Regression:
170
52