Unit 22 Aritificial Intelligence (Final)
Unit 22 Aritificial Intelligence (Final)
Artificial Intelligence
Artifical can be defined as…
Artifical Intelligence is concerned with how to make computers do things at which at the moment, people
are better.”
How graphs can be used in AI:
A graph is collection of nodes or vertices between which there can be edges.
Each node has a name, and each edge can have a numerical value. For,
example consider the following. A Graph can be used to represent a variety of scenarios. For example, the nodes can be used
to represent places and the edges can be the distances between these places. Only edges that
form a direct path between a pair of nodes are mentioned in the graph. Such graphs can be
used to find the shortest path between two nodes that are not connected to each other.
For example, we can find the shortest path between A and D by considering the following:
• A TO B TO C TO D (40+10+40 = 90)
• A TO B TO F TO E TO D (40 + 15+ 20+ 5 = 80) this is the shortest.
• A TO F TO E TO D (60+20+5 = 85)
• A TO F TO B TO C TO D (60+15+10+40 = 125)
A graph containing 100 nodes, finding the shortest the path can be time consuming. To
solve such problems we have AI algorithms in place.
Dijkstra’s Algorithm:-
Dijkstra’s Algorithm:-
Shortest Path set Content of the record
Example 2
[] A B C D E F
0 ∞ ∞ ∞ ∞ ∞
[A] A B C D E F
0 10 ∞ ∞ ∞ 25
A-B A-F
[A,B] A B C D E F
0 10 60 ∞ ∞ 25 15
A-B A-B-C A-B-F
[A,B,F] A B C D E F
0 10 60 ∞ 30 15
A-B A-B-C A-B-F-E A-B-F
[A,B,F,E] A B C D E F
0 10 60 38 30 15
AB ABC ABFED ABFE ABF
[A,B,F,E,D] A B C D E F
0 10 40 38 30 ABF
AB ABFEDC ABFED ABFE 15
[A,B,F,E,D,C] A B C D E F
AB ABFEDC ABFED ABFE ABF
0 10 40 38 30 15
Shortest Path Content of the record
set
[] Base T1 T2 T3 T4 T5 T6
0 ∞ ∞ ∞ ∞ ∞ ∞
[B]
4 5 2 ∞ ∞ ∞
[D,T3]
0 3 5 2 ∞ 3 ∞
[B,T3,T1,T4]
0 3 5 2 10 3 ∞
[B,T3,T1,T4,T5
]
0 3 5 2 9 3 8
[B,T3,T1,T5,6]
0 3 5 2 9 3 8
SHORTEST PATH LIST B T1 T2 T3 T4 T5 T6
B 0 ∞ ∞ ∞ ∞ ∞ ∞
B 4 5 2 ∞ ∞ ∞
B,T3 3 5 ∞ 3 ∞
B,T3,T1 5 10 3 ∞
B,T3,T5 5 9 8
B,T2 9 8
B,T3,T5,T6 9
B,T3,T5,T4
FINAL 0 3 5 2 9 3 8
A* Algorithm:
Dijkstra’s algorithm finds the best route from one node to all the remaining nodes. In many
cases the only requirement is to find the best route from one node to just one other node. It
would be possible to modify the Dijkstra algorithm to make it stop once the optimum route
to the target destination node had been established.
As an example of the use of the A* algorithm we can consider a simple example of finding
the shortest route between two towns using the existing roads.
The figure shows a basic map showing the locations of seven towns identified as A – G.
This map is included because it has been drawn by using a pair of x-y coordinates defining
the position of each town.
Pythagoras’s theorem can be used to calculate the direct distance between two positions as
follows:
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89
G 30
The equation mentioned above can serve as the basis of
heurist values. Therefore, for heuristic values for the
distance travelled from A-D will be as follows
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89 ACG = 70 + 30 = 100
AC ACF = 75+89 = 164
G 30 ACB = 95+100 = 195
The equation mentioned above can serve as the basis of
heurist values. Therefore, for heuristic values for the
distance travelled from A-D will be as follows
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89 ACG = 70 + 30 = 100
AC ACF = 75+89 = 164
G 30 ACB = 95+100 = 195
ACG ACGD = 110+0 = 110 (GOAL)
ACGE = 80+15 = 95
The equation mentioned above can serve as the basis of
heurist values. Therefore, for heuristic values for the
distance travelled from A-D will be as follows
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89 ACG = 70 + 30 = 100
AC ACF = 75+89 = 164
G 30 ACB = 95+100 = 195
ACG ACGD = 110+0 = 110 (GOAL)
ACGE = 80+15 = 95
The equation mentioned above can serve as the basis of
heurist values. Therefore, for heuristic values for the
distance travelled from A-D will be as follows
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89 ACG = 70 + 30 = 100
AC ACF = 75+89 = 164
G 30 ACB = 95+100 = 195
ACG ACGD = 110+0 = 110 (GOAL)
ACGE = 80+15 = 95
Nodes h(n)
A 91
100 PARENT PATHS
B
C 51 AC = f(n) = g(n)+h(n) = 45+51 = 96
D 0 A AB = 13+100 = 113
AF = 20+89 = 109
E 15
F 89 ACG = 70 + 30 = 100
AC ACF = 75+89 = 164
G 30 ACB = 95+100 = 195
ACG ACGD = 110+0 = 110 (GOAL)
ACGE = 80+15 = 95
The search engine will learn from its past performance, meaning its ability to carry
out searches becomes more sophisticated and accurate.
Labelled and Unlabelled data
Let us consider what is meant by labelled and unlabelled data:
Vehicles from source 1 are always cars and always come fully
serviced. Vehicles 1, 2, 3 and 4 are all
Vehicles from source 2 are vans and are usually un-serviced. labelled data since we know
Vehicles from source 3 are motorbikes and are usually serviced.
• what type of vehicle they are
Vehicles less than three years old also come with a warranty. • whether they have been serviced
• whether they have a warranty.
Thus, the garage has in stock They are fully defined and
• vehicle 1 – car, serviced, warranty recognisable.
• vehicle 2 – van, no service, no warranty
• vehicle 3 – car, no service, warranty However, vehicles 5, 6 and 7 are
• vehicle 4 – motorbike, serviced, warranty. unlabelled data since we do not
know what type of vehicle they are
Coming into stock in the next few days are and we only know their source and
• vehicle 5 – from source 1, two years old age.
• vehicle 6 – from source 3, four years old
• vehicle 7 – from source 2, one year old. Unlabelled data is data which is
unidentified and needs to be
recognised. Some processing would
need to be done before they could
be recognised as a car, van or
motorbike
Now, suppose you want to automatically count the types of birds seen in
a bird sanctuary. The proposed system will consider bird features such
as shape of beak, colour of feathers, body size, and so on. This
requires the use of labelled data to allow the birds to be recognised by
the system
Supervised Learning:-
In Supervised Learning, the machine learns
under supervision.
Risk Assessment
Supervised learning is used to assess the risk in
financial services or insurance domains to minimize the
risk portfolio of the companies.
Image Classification
Image classification is one of the key use cases of
demonstrating supervised machine learning. For example,
Facebook can recognize your friend in a picture from an
album of tagged photos.
Fraud Detection
To identify whether the transactions made by the user
are authentic or not.
Visual Recognition
The ability of a machine learning model to identify
objects, places, people, actions, and images.
Unsupervised Learning:-
In Unsupervised Learning, the machine uses unlabelled data and
learns on itself without any supervision. The machine tries to
find a pattern in the unlabelled data and gives a response.
Clustering is the method of dividing the objects into “clusters” that are similar
between them and are dissimilar to the objects belonging to another cluster.
For example, finding out which customers made similar product purchases.
So,
- Group B will be given more data
benefit plans
Suppose a telecom company wants to reduce its customer churn rate - Group C will be given cheaper called
(the rate at which customers stop doing business with an call rate plans and group
organisation) by providing personalized call and data plans. The - A will be given the benefit of both.
behaviour of the customers is studied and the model segments the
customers with similar traits. Several strategies are adopted to
minimize churn rate and maximize profit through suitable
promotions and campaigns.
Association
Association is a rule-based machine learning to discover the probability of the co-
occurrence of items in a collection.
Let’s say that a customer goes to a supermarket and buys bread, milk, fruits, and wheat.
Another customer buys bread, milk, rice, and butter.
Now, when another customer comes, it is highly likely that if he buys bread, he will buy
milk too.
Hence, a relationship is established based on customer behaviour and recommendations are
made.
Real-Life Applications of Unsupervised Learning
Semantic Clustering
Semantically similar words share a similar context. People post their queries on websites in their
own ways. Semantic clustering groups all these responses with the same meaning in a cluster to
ensure that the customer finds the information they want quickly and easily. It plays an important
role in information retrieval, good browsing experience, and comprehension.
It is a method that uses a small amount of labelled data and a large amount of unlabelled data (cheaper)
to train a model.
The goal of semi-supervised learning is to learn a function that can accurately predict the output
variable based on the input variables, like supervised learning.
However, unlike supervised learning, the algorithm is trained on a dataset that contains both labelled
and unlabelled data.
Examples of uses include the classification of web pages into sport, science, leisure, finance, and so
on. A web crawler is used to look at large amounts of unlabelled web pages, which is much cheaper than
going through millions of web pages and manually annotating (labelling) them.
Reinforcement learning
The system is not trained. It learns on the basis of
‘reward and punishment’ when carrying out an action
(in other words, it uses trial and error in
algorithms to determine which action gives the 1
highest/optimal outcome).
This type of learning helps to increase the
efficiency of the system by making use of
optimisation techniques.
Reinforcement Learning is a feedback-based approach
in which the “agent” learns by performing actions
and experiencing the outcomes.
2
Reinforcement learning
To understand RL, let’s look at how a dog is house trained.
Where the dog is rewarded for it’s good actions and
“penalised” for bad actions.
1. The dog (agent) is to be house trained (environment). 3
2. The dog will perform actions (fetching) and get rewards
(biscuits).
3. The dog will now perform more actions to get more
rewards.
4. The dog may choose ”Exploration” new actions and may or
may not get penalised. Or it may choose “Exploitation” to
maximise rewards by performing actions it knows that will 4
reward him.
Artificial Neural Networks:-
The neural networks in our brains are responsible for intelligence. Similarly ARTIFICIAL NUERAL
NETWORKS are considered as a foundation for Artificial Intelligence system.
Neural networks are a type of machine learning model or a subset of machine learning, and machine
learning is a subset of artificial intelligence.
The Nodes are represented here by TRIANGLES
Can also be represented by CIRCLES. The nodes receive inputs from one or more previous nodes and
provide outputs to one or more nodes.
At each node, the input is added with a weighting factor. The weighted value is applied to a
mathematical equation to compute a value for output from a node. The input values to nodes must be
numerical. If they are not numerical, they must be converted into a numerical value to allow for
summation.
“Neural Network is essentially a network of mathematical equations”
According to the representation below, a column of nodes on the left receive inputs. The column of
nodes on the right provide an output. The nodes in between form what is referred to as a ”hidden
layer”. For neural networks there are usually two or three, i.e. basic neural network. There can be
several hidden layers (Deep Learning).
Back Propagation of Errors:-
The concept of this algorithm is to adjust the weights minimizing the error between the actual
output and the predicted output
It involves working backwards from the output layer to adjust the weights accordingly and
reduce the average error across all layers.