0% found this document useful (0 votes)
17 views31 pages

Unit 22 Aritificial Intelligence (Final)

The document discusses Artificial Intelligence (AI), focusing on its definition, applications, and algorithms such as Dijkstra's and A* for finding shortest paths in graphs. It also covers the concepts of machine learning, including supervised, unsupervised, and reinforcement learning, along with examples of labelled and unlabelled data. Additionally, it explains regression and classification methods used in AI for predictive analysis.

Uploaded by

Mazen Zaheer
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)
17 views31 pages

Unit 22 Aritificial Intelligence (Final)

The document discusses Artificial Intelligence (AI), focusing on its definition, applications, and algorithms such as Dijkstra's and A* for finding shortest paths in graphs. It also covers the concepts of machine learning, including supervised, unsupervised, and reinforcement learning, along with examples of labelled and unlabelled data. Additionally, it explains regression and classification methods used in AI for predictive analysis.

Uploaded by

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

Unit 22

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:

The x-y coordinates for the towns A – G


A* algo will make use of the following equation determine the shortest path at each stage.
f(n) will be referred to as “fitness number”
The graph for this problem is shown here. This
or the cost of travelling from one node to
is drawn as before using edges to define which
adjacent node.
towns have an existing road linking the town to
g(n) will be the actual cost of travelling.
another town. The label for each edge shows the
And h(n) will be heuristic value or
distance of travel along that road.
ESTIMATED value/distance from
current node to destination node.
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
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

ACGE ACGED = 95+0 = 95 (GOAL)


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

ACGE ACGED = 95+0 = 95 (GOAL)


AI is often split into three categories. Examples of AI include
1. Narrow AI is when a machine has superior • news generation based on live
performance to a human when doing one news feeds (this will involve
specific task. some form of human interaction)
2. General AI is when a machine is similar in • smart home devices (such as
its performance to a human in any Amazon Alexa, Google Now, Apple
intellectual task. Siri and Microsoft Cortana)
3. Strong AI is when a machine has superior
performance to a human in many tasks.
Machine learning
Machine learning is a subset of AI, in which the
algorithms are ‘trained’ and learn from their
past experiences and examples. It is possible
for the system to make predictions or even take
decisions based on previous scenarios

A good example is a search engine:

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:

Suppose a garage selling vehicles obtains them from three sources.

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

Machine learning recognises the birds as labelled data, allowing it to be trained.


Once trained, it can recognise each type of bird from the original data set.
Algorithms are used to analyse the incoming data (by comparing it to bird features
already recognised by the model) and to learn from this data.
Other examples of machine learning include
• spam detection (the system learns to recognise spam emails without the need of any human
interactions)
• search engines refining searches based on earlier searches carried out (the system
learns from its mistakes).
Machine Learning:-
Machine Learning can be of the following types:-
- Supervised
- Unsupervised
- Reinforcement
- Semi-Supervised also known as Active Learning

Supervised Learning:-
In Supervised Learning, the machine learns
under supervision.

It contains a model that can predict with


the help of a labelled dataset.

A labelled dataset is one where you


already know the target answer.

In this case, we have images that are labelled a spoon or a


knife.

This known data is fed to the machine, which analyses and


learns the association of these images based on its features Supervised learning can be further
such as shape, size, sharpness, etc. divided into two types:
1.Classification
Now when a new image is fed to the machine without any label, 2.Regression
the machine can predict accurately that it is a spoon with the
help of the past data.
Regression:-
AI can be used to predict and
provide outcomes based on An example could be an AI system being used to
previously input data values. predict marks for candidates in an A Level Computer
For regression analysis the system Science exam. There may be an expectation that
has to be provided with input there would be a correlation between a candidate’s
values and their associated output marks in an A Level Computer Science exam and their
values. marks in an IGCSE Mathematics exam

The system will then attempt to


investigate any correlation with
the INPUT and OUTPUT values.
The formula for the
If found, a mathematical formula line can sensibly be
can be used to represent the used to predict
correlation thereby allowing the
future marks for the
prediction of outputs any future
A Level Computer
inputs. Science paper from
the marks scored in
an IGCSE Mathematics
paper.
Classification:-
Classification is used when the
output variable is categorical i.e.
with 2 or more classes.

For example, yes or no, male or


female, true or false, etc.
To predict whether a mail is spam or not, we need
to first teach the machine what a spam mail is
by:-

• reviewing the content of the mail, reviewing


the mail header, and then searching if it
contains any false information.
• Looking for certain keywords from already
blacklisted spammers.

Afterwards, mails are given a “spam score”.

The lower the total spam score of the email, the


more likely that it is not a spam.

Based on this scoring system, further emails will


also be categorised.
Real-Life Applications of Supervised Learning

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.

Let's take a similar example is


before, but this time we do not tell
the machine whether it's a spoon or a
knife.
The machine identifies patterns from
the given set and groups them based
on their patterns, similarities, etc.

Unsupervised learning can be further grouped


into types:
1.Clustering
2.Association
Clustering

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.

On the left side of the image, you can


see a graph where customers are
grouped.
Group A customers use more data and
have high call durations.

Group B customers are heavy Internet


users.

Group C customers have high call


duration.

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.

For example, finding out which products were purchased together.

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

Market Basket Analysis


It is a machine learning model based on the algorithm that if you buy a certain group of items,
you are less or more likely to buy another group of items.

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.

Delivery Store Optimization


Machine learning models are used to predict the demand and keep up with supply. They are also used
to open stores where the demand is higher and optimizing roots for more efficient deliveries
according to past data and behaviour.

Identifying Accident Prone Areas


Unsupervised machine learning models can be used to identify accident-prone areas and introduce
safety measures based on the intensity of those accidents.
Semi Supervised Learning (Active Learning)
Makes use of both labelled and unlabelled data (mostly unlabelled) for training algorithms.

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.

This process is repeated until the output error is minimized.

With increased computing power, artificial neural networks can be


created with many hidden layers. This is known as DEEP LEARNING.
Some of the latest smartphones
cameras use deep learning to
give DSLR quality to the
photographs. The technology was
developed by taking the same
photos using a smartphone and
then using a DSLR camera. The
deep learning system was then
trained by comparing the two
photographs.
Many photographs already taken
by a DSLR camera (but not by the
smartphone) were then used to
test the model.
Deep learning can be used to turn
monochrome (black and white)
photographs into coloured
photographs. This is a
sophisticated system which produces
a better photograph than simply
Chatbots interact through instant turning grey-scale values into an
messaging, artificially approximated colour. The deep
replicating patterns of human learning system is trained by
interactions using machine searching websites for data which
learning. Typed messages or voice allows it to recognise features and
recordings make use of predefined then map a particular colour to a
scripts and machine learning: when photograph/object thus producing an
a question is asked, a chatbot accurate coloured image.
responds using the information
known at the time.
What will happen in the future?

You might also like