0% found this document useful (0 votes)
937 views62 pages

Artificial Intelligence and Machine Learning

This document contains a question bank with solutions for an Artificial Intelligence and Machine Learning course. It includes 15 questions in Unit 1 on basics of AI such as definitions of AI, applications, machine learning, types of machine learning, and tools used for machine learning. Unit 2 covers state space search and heuristic search techniques. Unit 3 discusses knowledge representation issues. Later units focus on machine learning topics such as supervised vs unsupervised learning, linear regression, K-nearest neighbors, and neural networks. The document provides short 2-mark answers to questions on these topics.
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)
937 views62 pages

Artificial Intelligence and Machine Learning

This document contains a question bank with solutions for an Artificial Intelligence and Machine Learning course. It includes 15 questions in Unit 1 on basics of AI such as definitions of AI, applications, machine learning, types of machine learning, and tools used for machine learning. Unit 2 covers state space search and heuristic search techniques. Unit 3 discusses knowledge representation issues. Later units focus on machine learning topics such as supervised vs unsupervised learning, linear regression, K-nearest neighbors, and neural networks. The document provides short 2-mark answers to questions on these topics.
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/ 62

PARUL POLYTECHNIC INSTITUTE

COMPUTER DEPARTMENT

6th SEMESTER

QUESTION BANK WITH SOLUTION

ARTIFICIAL INTELLIGENCE AND MACHINE

LEARNING

(03606387)
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT 1: Basics of AI

1. Define Artificial Intelligence. (2M)

2. List out application of Artificial Intelligence. (2M)

3. Define machine learning. (2M)

4. Why was machine learning introduced? (2M)

5. Why is the Machine Learning trend emerging so fast? (2M)

6. What are the different types of Machine Learning? (2M)

7. Which Tools can be used for Machine Learning. (2M)

8. Define: 1) Dependent Variable 2) Independent Variable (2M)

9. Write application of Neural Network. (2M)

10. List out Production characteristics for State Space Search. (2M)

11. List out Production characteristics for Heuristic Search Techniques. (2M)

12. What is Product reduction? (2M)

13. What is knowledge representation? (2M)

14. Explain the type of Artificial Intelligence in detail. (4M)

15. Evolving Stages of Artificial Intelligence. (4M)

16. Artificial Intelligence vs. Machine Learning. (4M)

17. Explain AI problem.(3 M)

PIET - DS (CE) 2
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT 2: State Space Search & Heuristic Search Techniques

1. Explain Problems as A State Space Search. (3M)

2. Draw diagram and explain production system. (4M)

3. List out Production Systems characteristics for State Space Search. (3M)

4. List out Production Systems types. (3M)

5. Explain Heuristic Search Techniques with example. (4M)

6. Explain Hill Climbing method. (4M)

7. Explain Depth first search (DFS) with example. (4M)

8. Explain Breadth first search (BFS) with example. (4M)

9. Explain Constraint satisfaction. (3M)

10. Explain Means-end analysis with example. (4M)

UNIT 3: Knowledge Representation Issues

1. What are the types of knowledge? Explain each in detail? (4M)

2. What is the relation between knowledge and intelligence?

3. What is the AI knowledge cycle? Also draw diagram.(3M)

4. What are the approaches to knowledge representation? (3M)

5. What are the requirements for knowledge representation? (3M)

PIET - DS (CE) 3
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT: 4 Introduction to Machine Learning

1. Applications of Machine Learning. (3M)

2. What Are the Three Stages of Building a Model in Machine Learning? (3M)

3. What Are the Differences Between Machine Learning and Human Learning?(3M)

4. Explain Reinforcement learning?(3M)

UNIT: 5 Supervised and Unsupervised

1. Differentiate between Supervised and unsupervised learning. (3M)

2. Explain Linear Regression. (3M)

3. Explain K-nearest Neighbors. (4M)

4. Explain K-means.(4M)

5. Explain Apriori Algorithm.(3M)

6. Explain Advantage and Disadvantage of Unsupervised learning. (4M)

7. Explain Neural Network.(4M)

PIET - DS (CE) 4
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

2 MARKS QUESTIONS

1. Define Artificial Intelligence. (2M)


 Artificial intelligence leverages computers and machines to mimic the problem-solving and
decision-making capabilities of the human mind.
 AI is implemented in machine to perform tasks that actually require human intelligence.

2. List out application of Artificial Intelligence. (2M)


 AI-powered Assistants
 Fraud Prevention
 Social Media
 Automotive
 Agriculture
 Robotics
 E-Commerce
 Gaming

3. Define machine learning. (2M)


 Machine Learning is defined as a technology that is used to train machines to perform
various actions such as predictions, recommendations, estimations, etc., based on historical
data or past experience.
 Machine learning is a technique in which we trained the model based on historical data or
information and predict the output for test data.
 Machine learning is a subset of AI, which enables the machine to automatically learn from
data, improve performance from past experiences, and make predictions. 

4. Why was machine learning introduced? (2M)


 Machine learning was introduced to understand the structure of data and fit that data into
models that can be understand and utilized by people. As ML algorithms are able to detect
patterns in data and learn from them in order to make their own predictions

5. Why is the Machine Learning trend emerging so fast? (2M)


ML trend is emerging fast because:
 Increase of processing power that allows fast training of ML models for a couple of years
we hold in our pockets smartphones which pretty much surpass supercomputer from 20-30
years ago in terms of processing power.
 Decrease of storage costs that allow us to store very cheaply data that could be used laters
to train ML models. 

6. What are the different types of Machine Learning? (2M)


 Supervised Learning
 Unsupervised Learning
 Semi-supervised Learning
 Reinforcement Learning

PIET - DS (CE) 5
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

7. Which Tools can be used for Machine Learning. (2M)


 PyTorch
 TensorFlow
 Google Cloud ML Engine
 Amazon Machine Learning
 Jupyter
 Weka

8. Define: 1) Dependent Variable 2) Independent Variable (2M)


 Dependent Variable - The dependent variable is the variable that is measured or tested in
an experiment. It is the result of the participants’ actions, which can be changed according
to the outcome of the action performed by the participant.
 Independent Variable - An Independent variable is exactly according to its name. It
means it stands along with a variable that cannot be changed by another variable.
Independent variables are also known as predictions or factors.

9. Write application of Neural Network. (2M)


 Facial Recognition
 Stock Market Prediction
 Social Media
 Aerospace
 Healthcare
 Signature Verification and Handwriting Analysis
 Weather Forecasting

10. List out Production characteristics for State Space Search. (2M)
 Implicity
 Modifiability
 Modularity
 knowledge-intensive

11. List out Production characteristics for Heuristic Search Techniques. (2M)
 Heuristics are knowledge about the domain, which help search and reasoning in its
domain.
 Heuristic search incorporates domain knowledge to improve efficiency over blind
search.
 A heuristic is a function that, when applied to a state, returns the value as estimated
merit of state, with respect to the goal.
• Heuristics might (for reasons) underestimate or overestimate the merit of a state
with respect to the goal.
• Heuristics that underestimate are desirable and called admissibly.
 The heuristic evaluation function estimates the likelihood of a given state leading to the
goal state.

PIET - DS (CE) 6
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

12. What is Product reduction? (2M)


Problem reduction is an algorithm design technique that takes a complex problem and
reduces it to a simpler one. The simpler problem is then solved and the solution of the simpler
problem is then transformed to the solution of the original problem.
 Problem reduction is a powerful technique that can be used to simplify complex problems
and make them easier to solve. It can also be used to reduce the time and space complexity
of algorithms.

13. What is knowledge representation? (2M)


 Knowledge and Representation are two distinct entities. They play central but
distinguishable Roles in intelligent system.
 Knowledge is a description of the world. It determines a system's competence by what it
knows.
 Representation is the way knowledge is encoded. It defines a system's performance in
doing something.
 Different types of knowledge require different kinds of representation.
 The Knowledge Representation models/mechanisms are often based on:
a. Logic
b. Rules
c. Frames
d. Semantic Net

14. Explain the type of Artificial Intelligence in detail. (4M)

Based On Capabilities:-

Weak AI or Narrow AI:-


• This type of AI which is able to perform a dedicated task with intelligence.
• The most common and currently available AI is Narrow AI in the world of Artificial
Intelligence.
• Narrow AI cannot perform beyond its field or limitations, as it is only trained for one
specific task. Hence it is also termed as weak AI. Narrow AI can fail in unpredictable
ways if it goes beyond its limits.
• Apple Siriis a good example of Narrow AI, but it operates with a limited pre- defined
range of functions.

Weak AI or Narrow AI:-


• This type of intelligence which could perform any intellectual task with efficiencylike
a human.
• The idea behind the general AI to make such a system which could be smarter and
think like a human by its own.
• Currently, there is no such system exist which could come under general AI andcan
perform any task as perfect as a human.
• The worldwide researchers are now focused on developing machines with GeneralAI.
PIET - DS (CE) 7
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

• As systems with general AI are still under research, and it will take lots of efforts and
time to develop such systems.

Weak AI or Narrow AI:-


• Super AI is a level of Intelligence of Systems at which machines could surpass human
intelligence, and can perform any task better than human with cognitive properties. It
is an outcome of general AI.
• Some key characteristics of strong AI include capability include the ability to think, to
reason,solve the puzzle, make judgments, plan, learn, and communicate by its own.
• Super AI is still a hypothetical concept of Artificial Intelligence. Development of
such systems in real is still world changing task.

Based On Functionality:-

1. Reactive Machines:-
 Purely reactive machines are the most basic types of artificial intelligence.
 Such AI system do not store memories or past experiences for future actions.

 These machines only focus on current scenarios and react on it as per possible best
action.
 IBM’s deep Blue System, Google’s etc. is an example of reactive machines.

2. Limited Memory:-
 Limited memory machines can store data for a short period of time.
 These machines can use stored data for a limited time period only.
 Example of limited memory is self-driving cars are the best example.

3. Theory of Mind:-
 Theory of mind AI should understand the human emotions people, beliefs and be
able to interact socially like humans.
 This type of AI machines are still not developed but researchers are making lots of
efforts and improvement for developing such AI machines.

4. Self-Awareness:-
 This type of AI is the future of artificial intelligence.
 This type of machine have their own consciousness, sentiments and self-awareness.
 This type of machine will be smarter than human mind.
 Self-awareness AI does not exist in reality still and it is a hypothetical concept.

PIET - DS (CE) 8
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

15. Evolving Stages of Artificial Intelligence. (4M)


Stage 1- Rule Bases System

 In this stage, AI surrounds us in everything from Robot Process Automation used in


business to autopilots used in aircraft.

Stage 2- Context-awareness and Retention

 The machines based on algorithms are trained on the best human knowledge and
experience with knowledge based on specific domains. The existing knowledge base can
be updated once new queries and solutions arise. The most common application to be
Robo-advisors or chatbots which can be used in a forward customer inquiry that can help
human in everything.

Stage 3- Domain-specific aptitude

 In this stage, the advanced systems can develop mastery in particular domains. Due to the
capability to store and process a wide volume of information to make decisions the
capabilities of these machines can be more than humans. Cancer diagnosis is one of the
applications and Google Deepmind's system that defeated 18 times world go champion Lee
Sadol proved the domain-specific expertise.

Stage 4- Reasoning systems

 This machine algorithm has a concept of intellect, intentions, knowledge, and their own
logic. They have the capacity to reason, interact and, deal with other machines and humans
too. Such algorithms will be in the commercial arena in some years.

Stage 5- Artificial General Intelligence

 This is the main objective of many scientists working in the field of AI- to develop a
machine with intelligence like humans. The artificial general intelligence or self-aware
systems are not in application to date but not many years left to discover this avenue. This
is the stage represented in many sci-fiction movies that machines are leading humans in
intelligence.

Stage 6- Artificial Super Intelligence(ASI)

 This stage is one notch of the Artificial General Intelligence, the algorithms will be capable
of defeating smartest of the humans in all the domains. This stage can be the real solution
to the problems that are still complex for the human mind like poverty, hunger, and climate
change. This will be the stage where machines made by humans will outsmart humans too.
PIET - DS (CE) 9
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Stage 7- Singularity and Excellency

 The development path led by ASI will lead us to the point in time where the capabilities of
humans will see the tremendous extension. With the help of this ASI, technology humans
would be able to connect the minds of each other and be like the human internet. The
technology would be much like an imaginary life where ideas, and thoughts could be shared
by just one flick of mind. Humans would be capable of connecting with other forms of life
like animals, plants, and other natural activities. While some argue that humans will never
reach such levels and some say that it is feasible and with this exponential growth rate
would be achieved somewhere in 2045.

16. Artificial Intelligence vs. Machine Learning. (4M)

Sr no Artificial Intelligence Machine Learning

1 Artificial intelligence is a Machine learning is a subset of AI


technology which
which enables a machine to allows a machine to automatically learn
simulatehuman behavior. frompast data without programming
explicitly.
2 The goal of AI is to make a smart The goal of ML is to allow machines to
computer system like humans to learnfrom data so that they can give
solve accurate
complex problems. output.
3 In AI, we make intelligent systems In ML, we teach machines with data
toperform any task like a human. toperform a particular task and give an
accurate
result.
4 Machine learning and deep learning Deep learning is a main subset of
are machine
the two main subsets of AI. learning.
5 AI has a very wide range of scope. Machine learning has a limited scope.

6 AI is working to create an Machine learning is working to


intelligent create
system which can perform various machines that can perform only
complex tasks. thosespecific tasks for which they are
trained.
7 AI system is concerned Machine learning is mainly concerned
about about
maximizing the chances of success. accuracy and patterns.

PIET - DS (CE) 1
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

8 The main applications of AI are Siri, The main applications of machine


customer support using catboats, learning are Online recommender
Expert System, Online game system, Google search algorithms,
playing, Facebook auto friend
intelligent humanoid robot, etc. tagging suggestions, etc.
9 On the basis of capabilities, AI can Machine learning can also be divided
be divided into three types, into mainly three types that are
which are, Weak AI, General AI, Supervised learning, Unsupervised
and Strong lear
AI. ning,
and Reinforcement learning.
10 It includes learning, reasoning, It includes learning and self-correction
and when
self-correction. introduced with new data.
11 AI completely deals with Machine learning deals with Structured
Structured, and
semi-structured, and unstructured semi-structured data.
data.

17. Explain AI problem. (3 M)

 Every technology has some disadvantages, and the same goes for Artificial intelligence.
Being so advantageous technology still, it has some disadvantages which we need to keep
in our mind while creating an AI system. Following are the disadvantages of AI:
 High Cost: The hardware and software requirement of AI is very costly as it requires lots
of maintenance to meet current world requirements. Can't think out of the box: Even we
are making smarter machines with AI, but still they cannot work out of the box, as the robot
will only do that work for which they are trained, or programmed.
 No feelings and emotions: AI machines can be an outstanding performer, but still it does
not have the feeling so it cannot make any kind of emotional attachment with human, and
may sometime be harmful for users if the proper care is not taken.
 Increase dependency on machines: With the increment of technology, people are getting
more dependent on devices and hence they are losing their mental capabilities.
 No Original Creativity: As humans are so creative and can imagine some new ideas but
still AI machines cannot beat this power of human intelligence and cannot be creative and
imaginative.

PIET - DS (CE) 1
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT 2: State Space Search & Heuristic Search Techniques

1. Explain Problems as A State Space Search. (3M)

 State-space search is used to locate a goal state with the desired feature.
 In artificial intelligence, a process known as state space search is used to explore all
potential configurations or states of an instance until one with the necessary feature is
found.
 A state is a time snapshot representing some aspect of the problem. It is common to practise
modelling a problem as a state space or a collection of possible states to understand it better.
If an operation can change one state into another, then the two states are connected in the
set of states' graph.
 Because the state space is implicit—a typical state space graph would be too vast to build
and maintain in-memory—state space search often deviates from conventional computer
science search techniques. Instead, new nodes are created as they are visited and then
frequently destroyed. In combinatorial search, a solution can be either the final state or
a sequence of states that lead from an initial state to the final state.

Features:
 A state space is a set of all possible states that it can reach from the current state.
 The nodes of a state space represent states, and the arcs connecting them represent
actions.
 A path is a set of states and the actions that link them in the state space.
 A problem's solution is a node in the graph representing all possible states of the
problem.
 Most AI techniques are based on state space representation.

Advantages:
 It is very useful in AI because of it provides a set of all possible states, operations and
goals.
 If the entire state space is for a problem then it is possible to trace the path from the initial
to the goal state and identify the sequence of operation required for doing it.

Disadvantages:
 It is not possible to visualize all states for a problem.
 The resources of the computer system are very limited to handle huge combinational state
space.

2. Draw diagram and explain production system. (4M)


 A production system in AI helps create AI-based computer programs. With the help of it,
the automation of various types of machines has become an easy task. The types of
machines can be a computer, mobile applications, manufacturing tools, or more. The set of

PIET - DS (CE)
12
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

rules in a production system in Artificial Intelligence defines the behaviour of the


machine. It helps the machine respond to the surroundings.

 A production system in AI is a type of cognitive architecture that defines specific actions


as per certain rules. The rules represent the declarative knowledge of a machine to respond
according to different conditions. Today, many expert systems and automation
methodologies rely on the rules of production systems. Below is the basic architecture of
production systems in AI:

 The rules in a production system are determined by LHS (left-hand side) and RHS (right-
hand side) equations, where LHS denotes the specific condition to be applied, and RHS
shows the output of the applied condition.

 The representation of knowledge in AI comprises various components used for making


intelligent machines. In the next section, we will discuss the important components of a
production system in Artificial Intelligence.

3. List out Production Systems characteristics for State Space Search. (3M)
There are mainly four characteristics of the production system in AI that Is-

1. Implicity
2. Modifiability
3. Modularity
4. knowledge-intensive.

PIET - DS (CE)
13
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Simplicity

 The production rule in AI is in the form of an ‘IF-THEN’ statement. Every rule in the
production system has a unique structure. It helps represent knowledge and reasoning in
the simplest way possible to solve real-world problems. Also, it helps improve the
readability and understanding of the production rules.

Modularity

 The modularity of a production rule helps in its incremental improvement as the production
rule can be in discrete parts. The production rule is made from a collection of information
and facts that may not have dependencies unless there is a rule connecting them together.
The addition or deletion of single information will not have a major effect on the output.
Modularity helps enhance the performance of the production system by adjusting the
parameters of the rules.

Modifiability

 The feature of modifiability helps alter the rules as per requirements. Initially, the skeletal
form of the production system is created. We then gather the requirements and make
changes in the raw structure of the production system. This helps in the iterative
improvement of the production system.

Knowledge-intensive

 Production systems contain knowledge in the form of a human spoken language, i.e.,
English. It is not built using any programming languages. The knowledge is represented in
plain English sentences. Production rules help make productive conclusions from these
sentences.

PIET - DS (CE)
14
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

4. List out Production Systems types. (3M)


 Monotonic Production System: the application of a rule never prevents the later
application of another rule that could also have been applied at the time the first rule was
selected. i.e., rules are independent.
 Non-Monotonic Production system is one in which this is not true.
 Partially commutative Production system: a production system with the property that
if application of a particular sequence of rules transforms state x to state y, then allowable
permutation of those rules, also transforms state x into state y.
 Commutative Production system: A Commutative production system is a production
system that is both monotonic and partially commutative.

5. Explain Heuristic Search Techniques with example. (4M)

Heuristic techniques - two categories:

1. Direct Heuristic Search techniques in AI

 It includes Blind Search, Uninformed Search, and Blind control strategy. These search
techniques are not always possible as they require much memory and time. These
techniques search the complete space for a solution and use the arbitrary ordering of
operations.
 The examples of Direct Heuristic search techniques include Breadth-First Search (BFS)
and Depth First Search (DFS).

2. Weak Heuristic Search techniques in AI

 It includes Informed Search, Heuristic Search, and Heuristic control strategy. These
techniques are helpful when they are applied properly to the right types of tasks. They
usually require domain-specific information.

PIET - DS (CE)
15
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 The examples of Weak Heuristic search techniques include Best First Search (BFS) and
A*.

Generate-and-Test
 Generate-and-test search algorithm is a very simple algorithm that guarantees to find
solution if done systematically and there exists a solution.
Algorithm:
1. Generate a possible solution. For some problems, this means generating a particular
point in the problem space. For others it means generating a path from a start stat.
2. Test to see if this is actually a solution by comparing the chosen point or the endpoint
of the chosen path to the set of acceptable goal states.
3. If a solution has been found, quit, Otherwise return to step 1.
It is a depth first search procedure since complete solutions must be generated before they can
be tested.
In its most systematic form, it is simply an exhaustive search of the problem space.
It operates by generating solutions randomly.

6. Explain Hill Climbing method. (4M)


Simple Hill Climbing
 Hill climbing is a variant of generate-and test in which feedback from the test procedure
is used to help the generator decide which direction to move in search space.
 The test function is augmented with a heuristic function that provides an estimate of how
close a given state is to the goal state.
 Hill climbing is often used when a good heuristic function is available for evaluating
states but when no other useful knowledge is available. 
 The key difference between Simple Hill climbing and Generate-and-test is the use of
evaluation function as a way to inject task specific knowledge into the control process.
Algorithm:
1. Evaluate the initial state. If it is also goal state, then return it and quit. Otherwise
continue with the initial state as the current state.
2. Loop until a solution is found or until there are no new operators left to be
applied in the current state:
a. Select an operator that has not yet been applied to the current state and
apply it to produce a new state.
b. Evaluate the new state
If it is the goal state, then return it and quit.
.If it is not a goal state but it is better than the current state, then
make it the current state.
i. If it is not better than the current state, then continue in the loop
● Hill Climbing has three well-known drawbacks:
Local Maxima: a local maximum is a state that is better than all its neighbors
but is not better than some other states further away.
Plateau: a plateau is a flat area of the search space in which, a whole set of
neighboring states have the same values.
PIET - DS (CE)
16
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Local Maxima Plate Ri


au dge

Ridge: is a special kind of local maximum. It is an area of the search space that is higher than
surrounding areas and that itself has slop.
 In each of the previous cases (local maxima, plateaus & ridge), the algorithm
reaches a point at which no progress is being made.
 A solution is,
1. Backtrack to some earlier node and try going in a different direction.
2. Make a big jump to try to get in a new section.
3. Moving in several directions at once.

1. Local Maxima: a local maximum is a state that is better than all its neighbors but is not
better than some other states further away.
2. Plateau: a plateau is a flat area of the search space in which, a whole set of neighboring
states have the same values.

7. Explain Depth first search (DFS) with example. (4M)


 Here, the search systematically proceeds to some depth d, before another path is
considered.
 If the maximum depth of search tree is reached and if the solution has not been found,
then the search backtracks to the previous level and explores any remaining alternatives
at this level, and so on.
Algorithm:
1. If the initial state is a goal state, quit and return success
2. Otherwise, do the following until success or failure is signaled:
. Generate a successor, E, of initial state. If there are no more successors, signal failure.
a. Call Depth-First Search, with E as the initial state
b. If success is returned, signal success. Otherwise continue in this loop.
Example Which solution would DFS find to move from node S to node G if run on the graph
below?

PIET - DS (CE)
17
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Solution. The equivalent search tree for the above graph is as follows. As DFS traverses the tree
“deepest node first”, it would always pick the deeper branch until it reaches the solution (or it runs
out of nodes, and goes to the next branch). The traversal is shown in blue arrows.

S - Path: > A -> B -> C -> G

8. Explain Breadth first search (BFS) with example. (4M)


Breadth-First Search Strategy (BFS)
 This is an exhaustive search technique. 
 The search generates all nodes at a particular level before proceeding to the next level of
the tree.
 The search systematically proceeds testing each node that is reachable from a parent node
before it expands to any child of those nodes.
 Search terminates when a solution is found and the test returns true.
Algorithm:
1. Create a variable called NODE-LIST and set it to initial state.
2. Until a goal state is found or NODE-LIST is empty do:
Remove the first element from NODE-LIST and call it E. If NODE-LIST was empty, quit.
PIET - DS (CE)
18
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

.For each way that each rule can match the state described in E do:
. Apply the rule to generate a new state.
a. If the new state is a goal state, quit and return this state.
b. Otherwise, add the new state to the end of NODE-LIST.

Example: What is the Water Jug Problem?


 Here is the problem statement for Water Jug Problem:
 You are given 2 jugs with the capacity 'm' and 'n' respectively. Initially, they are given
empty. There is an unlimited supply of water. You can either fill the whole jug or a quantity
that is less than the given capacity of jugs. Now, you are also given a third positive
integer 'd'. Using the 2 given jugs, you need to come up with a solution to have 'd' amount
of water in them and return the number of steps you took to reach that capacity.
 Now that we have chosen what to work with, let's understand how you can actually make
it work. Well, for starters you can have (a, b) which represents the amount of water
currently in jug 1 and jug 2 respectively. Initially, both the components will be (0, 0) since
the jugs are empty in the beginning. The final state of the jugs will be either (0, d) or (d,
0) as both add up to give a total of the required quantity.

The following operations can be performed on the jugs:

Empty a jug (a, b) -> (0, b)


Fill a jug (0, b) -> (a, b)
Transfer water from one jug to another.

9. Explain Constraint satisfaction. (3M)


Constraint satisfaction is a search procedure that operates in a space of constraint sets.
The initial state contains the constraints that are originally given in the problem description.

PIET - DS (CE)
19
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 A goal state is any state that has been constrained “enough” where “enough” must be
defined for each problem.
 For example, in cryptarithmetic problems, enough means that each letter has been
assigned a unique numeric value.
 Constraint Satisfaction problems in AI have goal of discovering some problem state
that satisfies a given set of constraints.
 Design tasks can be viewed as constraint satisfaction problems in which a design must
be created within fixed limits on time, cost, and materials.
 Constraint Satisfaction is a two-step process:
o First constraints are discovered and propagated as far as possible throughout the
system.
o Then if there is still not a solution, search begins. A guess about something is
made and added as a new constraint.
Algorithm: Constraint Satisfaction
1. Propagate available constraints. To do this first set OPEN to set of all objects that must have
values assigned to them in a complete solution. Then do until an inconsistency is detected or
until OPEN is empty:
a) Select an object OB from OPEN. Strengthen as much as possible the set of constraints
that apply to OB.
b) If this set is different from the set that was assigned the last time OB was examined or
if this is the first time OB has been examined, then add to OPEN all objects that share
any constraints with OB.
c) Remove OB from OPEN.
2. If the union of the constraints discovered above defines a solution, then quit and report the
solution.
3. If the union of the constraints discovered above defines a contradiction, then return the
failure. 4. If neither of the above occurs, then it is necessary to make a guess at something in
order to proceed. To do this loop until a solution is found or all possible solutions have been
eliminated:
a) Select an object whose value is not yet determined and select a way of strengthening
the constraints on that object.
b) Recursively invoke constraint satisfaction with the current set of constraints augmented
by strengthening constraint just selected.

10. Explain Means-end analysis with example. (4M)

 Collection of strategies presented so far can reason either forward or backward, but for a
given problem, one direction or the other must be chosen.
 A mixture of the two directions is appropriate. Such a mixed strategy would make it
possible to solve the major parts of a problem first and then go back and solve the small
problems that arise in “gluing” the big pieces together.
 The technique of Means-Ends Analysis (MEA) allows us to do that.

PIET - DS (CE)
20
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 MEA process centers around the detection of differences between the current state and the
goal state.
 Once such a difference is isolated, an operator that can reduce the difference must be found.
 If the operator cannot be applied to the current state, we set up a sub-problem of getting to
a state in which it can be applied.
 The kind of backward chaining in which operators are selected and then sub-goals are set
up to establish the preconditions of the operators is called operator sub-goaling.

Algorithm: Means-Ends Analysis

1. Compare CURRENT to GOAL. If there are no differences between them then return.
2. Otherwise, select the most important difference and reduce it by doing the following until
success or failure is signaled:
a) Select an as yet untried operator O that is applicable to the current difference. If there are
no such operators, then signal failure.
b) Attempt to apply O to CURRENT. Generate descriptions of two states: OSTART, a state
in which O’s preconditions are satisfied and O-RESULT, the state that would result if O
were applied in O-START.
c) If (FIRST-PART  MEA( CURRENT, O-START)) and (LAST-PART  MEA(O-
RESULT, GOAL)) are successful, then signal success and return the result of
concatenating FIRST-PART, O, and LAST-PART.

Example of Mean-Ends Analysis

we know the initial state and goal state as given below. In this problem, we need to get the goal
state by finding differences between the initial state and goal state and applying operators.

Solution:

To solve the above problem, we will first find the differences between initial states and goal states,
and for each difference, we will generate a new state and will apply the operators. The operators
we have for this problem are:

 Move
 Delete
 Expand

PIET - DS (CE)
21
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

1. Evaluating the initial state: In the first step, we will evaluate the initial state and will compare
the initial and Goal state to find the differences between both states.

2. Applying Delete operator: As we can check the first difference is that in goal state there is no
dot symbol which is present in the initial state, so, first we will apply the Delete operator to remove
this dot.

3. Applying Move Operator: After applying the Delete operator, the new state occurs which we
will again compare with goal state. After comparing these states, there is another difference that is
the square is outside the circle, so, we will apply the Move Operator.

4. Applying Expand Operator: Now a new state is generated in the third step, and we will compare
this state with the goal state. After comparing the states there is still one difference which is the
size of the square, so, we will apply Expand operator, and finally, it will generate the goal state.

PIET - DS (CE)
22
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT 3: Knowledge Representation Issues

1. What are the types of knowledge? Explain each in detail? (4M)

1. Declarative Knowledge:

 Declarative knowledge is to know about something.


 It includes concepts, facts, and objects.
 It is also called descriptive knowledge and expressed in declarativesentences.
 It is simpler than procedural language.

2. Procedural Knowledge

 It is also known as imperative knowledge.


 Procedural knowledge is a type of knowledge which is responsible for knowing how to do
something.
 It can be directly applied to any task.
 It includes rules, strategies, procedures, agendas, etc.
 Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:

 Knowledge about the other types of knowledge is called Meta-knowledge.

PIET - DS (CE)
23
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

4. Heuristic knowledge:

 Heuristic knowledge is representing knowledge of some experts in a filed or subject.


 Heuristic knowledge is rules of thumb based on previous experiences, awareness of
approaches, and which are good to work but not guaranteed.

5. Structural knowledge:

 Structural knowledge is basic knowledge to problem-solving.


 It describes relationships between various concepts such as kind of, part of, and grouping
of something.
 It describes the relationship that exists between concepts or objects.

2. What is the relation between knowledge and intelligence? (3M)


 Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial
intelligence. Knowledge plays an important role in demonstrating intelligent behaviour in
AI agents. An agent is only able to accurately act on some input when he has some
knowledge or experience about that input.
 Let's suppose if you met some person who is speaking in a language which you don't know,
then how you will able to act on that. The same thing applies to the intelligent behaviour
of the agents.
 As can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it
cannot display intelligent behaviour.

PIET - DS (CE)
24
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

3. What is the AI knowledge cycle? Also draw diagram. (3M)


An Artificial intelligence system has the following components for displaying intelligent behavior:

 Perception
 Learning
 Knowledge Representation and Reasoning
 Planning
 Execution

 The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence.
 AI system has Perception component by which it retrieves information from its
environment. It can be visual, audio or another form of sensory input.
 The learning component is responsible for learning from data captured by Perception
comportment.
 In the complete cycle, the main components are knowledge representation and Reasoning.
These two components are involved in showing the intelligence in machine-like humans.
These two components are independent with each other but also coupled together. The
planning and execution depend on analysis of Knowledge representation and reasoning.

PIET - DS (CE)
25
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

4. What are the approaches to knowledge representation? (3M)

1. Simple relational knowledge:


 It is the simplest way of storing facts which uses the relational method, and each fact about
a set of the object is set out systematically in columns.
 This approach of knowledge representation is famous in database systems where the
relationship between different entities is represented.
 This approach has little opportunity for inference.
 Example: The following is the simple relational knowledge representation.

Player Weight Age

Player1 65 23

Player2 58 18

Player3 75 24

2. Inheritable knowledge:
 In the inheritable knowledge approach, all data must be stored into a hierarchy of classes.
 All classes should be arranged in a generalized form or a hierarchal manner. 
 In this approach, we apply inheritance property. 
 Elements inherit values from other members of a class.
 This approach contains inheritable knowledge which shows a relation between instance
and class, and it is called instance relation. 
 Every individual frame can represent the collection of attributes and its value. 
 In this approach, objects and values are represented in Boxed nodes. 
 We use Arrows which point from objects to their values
 Example:

PIET - DS (CE)
26
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

3. Inferential knowledge:
 Inferential knowledge approach represents knowledge in the form of formal logics.
 This approach can be used to derive more facts.
 It guaranteed correctness. 
 Example: Let's suppose there are two statements:
o Marcus is a man
o All men are mortal
Then it can represent as;
man(Marcus)
∀x = man (x) --------- > mortal (x)s

4. Procedural knowledge:
 Procedural knowledge approach uses small programs and codes which describes how to do
specific things, and how to proceed.
 In this approach, one important rule is used which is If-Then rule. 
 In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
 We can easily represent heuristic or domain-specific knowledge using this approach.
 But it is not necessary that we can represent all cases in this approach.

PIET - DS (CE)
27
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

5. What are the requirements for knowledge representation? (3M)

A good knowledge representation system must possess the following properties.

1. Representational Accuracy:

 KR system should have the ability to represent all kind of required knowledge.

2. Inferential Adequacy:

 KR system should have ability to manipulate the representational structures to produce new
knowledge corresponding to existing structure.

3. Inferential Efficiency:

 The ability to direct the inferential knowledge mechanism into the most productive
directions by storing appropriate guides.

4. Acquisitional efficiency

 The ability to acquire the new knowledge easily using automatic methods.

PIET - DS (CE)
28
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT: 4 INTRODUCTIONS TO MACHINE LEARNING

1. Applications of Machine Learning. (3M)


Below are some most trending real-world applications of Machine Learning:

Image Recognition:
 Example Facebook Automatic friend tagging suggestion

Speech Recognition:
 Example Google assistant, Siri, Cortana, and Alexa

Traffic prediction:
 Example

Traffic prediction:
 Example Google Map

Product recommendation
 Example Amazon, Netflix

Self-driving cars
 Example Tesla

Email span and malware filtering


 Example Gmail

Virtual Personal Assistant

PIET - DS (CE)
29
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 Example Google assistant, Alexa, Cortana and Siri


Online Fraud Detection
 Example fake accounts, fake ids, and steal money

Stock Market trading


 Example different prediction systems

Medical Diagnosis
 Example 3D models that can predict the exact position of lesions in the brain

Automatic Language Translation


 Example Google's GNMT (Google Neural Machine Translation)

2. What Are the Three Stages of Building a Model in Machine Learning? (3M)
Machine learning typically follows three phases:

1. Training: A training set of examples of correct behavior is analyzed and some representation
of the newly learnt knowledge is stored. This is some form of rules.

2. Validation: The rules are checked and, if necessary, additional training is given. Sometimes
additional test data are used, but instead, a human expert may validate the rules, or some other
automatic knowledge based component may be used. The role of the tester is often called the
opponent.

3. Application: The rules are used in responding to some new situation.

3. What Are the Differences Between Machine Learning and Human Learning?
(3M)

Feature Machine Learning Human Learning


Emergence ML is an advancement made by human On the other hand, human creatures are
insights; its early improvement is made with the intrinsic capacity to
credited to Norbert Weiner who think, reason, review, etc.
theorized on criticism mechanisms
Nature ML strives to build machines that can Human intelligence seeks to adapt to
mimic human behavior and carry out new situations by combining a variety
human-like tasks. of cognitive processes.
State Machines are digital. The human brain is analogous.
Function ML-powered machines rely on input of Humans use their brains’ memory,
data and instructions. processing power, and cognitive
abilities.
Pace/Rate As compared to people, computers can In terms of speed, humans cannot beat
handle more data at a speedier rate. For the speed of AI or machines.
occurrence, in the event that the human
PIET - DS (CE)
30
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

intellect can solve a math problem in 5


minutes, AI can solve 10 problems in a
minute
Learning As machines are unable to reason Learning from various events and prior
ability abstractly or draw conclusions from experiences is the foundation of human
the past. They can only acquire intelligence.
knowledge through information and
frequent training, but they will never
develop a human-specific thinking
process.
Decision ML is profoundly objective in choice Human choices may be affected by
Making making because it analyzes based on subjective components which are not
absolutely accumulated data. based on figures alone.
Perfection ML frequently produces precise comes For human insights, there’s more often
about because its capacities are based on a than not room for “human error” as
set of modified rules. certain subtle elements may be missed
at one point or the other.
Modification ML takes much more time to adjust to Human insights can be adaptable in
unused changes. reaction to the changes in their
environment. This makes individuals
able to memorize and ace different
skills.

4. Explain Reinforcement learning? (3M)

 Reinforcement learning works on a feedback-based process, in which an AI agent (A


software component) automatically explore its surrounding by hitting & trail, taking action,
learning from experiences, and improving its performance.
 Agent gets rewarded for each good action and get punished for each bad action; hence the
goal of reinforcement learning agent is to maximize the rewards.
 In reinforcement learning, there is no labelled data like supervised learning, and agents
learn from their experiences only.

 Advantages
 It helps in solving complex real-world problems which are difficult to be solved by
general techniques.
 The learning model of RL is similar to the learning of human beings; hence most
accurate results can be found.
 Helps in achieving long term results.
 Disadvantage
 RL algorithms are not preferred for simple problems.
 RL algorithms require huge data and computations.
 Too much reinforcement learning can lead to an overload of states which can weaken
the results.
PIET - DS (CE)
31
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

UNIT: 5 SUPERVISED & UNSUPERVISED

1. Differentiate between Supervised and unsupervised learning. (3M)

Sr Supervised learning Unsupervised learning


No
1 Supervised learning algorithms are trained Unsupervised learning algorithms are
using labeled data. trained using unlabeled data.
2 Supervised learning model takes direct Unsupervised learning model does not take
feedback to check if it is predicting correct any feedback.
output or not
3 Supervised learning model predicts the Unsupervised learning model finds the
output. hidden patterns in data.
4 In supervised learning, input data is In unsupervised learning, only input data is
provided to the model along with the provided to the model.
output.
5 The goal of supervised learning is to train
The goal of unsupervised learning is to find
the model so that it can predict the output
the hidden patterns and useful insights from
when it is given new data. the unknown dataset.
6 Supervised learning needs supervision toUnsupervised learning does not need any
train the model. supervision to train the model.
7 Supervised learning can be categorized in
Unsupervised Learning can be classified in
Classification and Regression problems. Clustering and Associations problems.
8 Supervised learning can be used for those
Unsupervised learning can be used for those
cases where we know the input as well ascases where we have only input data and no
corresponding outputs. corresponding output data.
9 Supervised learning model produces an Unsupervised learning model may give less
accurate result. accurate result as compared to supervised
learning.
10 It includes various algorithms such as It includes various algorithms such as
Linear Regression, Logistic Regression, Clustering, KNN, and Apriori algorithm.
Support Vector Machine, Multi-class
Classification, Decision tree, Bayesian
etc.

2. Explain Linear Regression. (3M)


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

PIET - DS (CE)
32
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 If there is only one input variable (x), then such linear regression is called simple linear
regression. And if there is more than one input variable, then such linear regression is called
multiple 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 of the year
of experience. 

 Below is the mathematical equation for Linear regression:


Y= aX+b Here, Y = dependent variables (target variables), X= Independent variables
(predictor variables), a and b are the linear coefficients. Applications of linear regression:
 Analyzing trends and sales estimates
 Salary forecasting
 Real estate prediction
 Arriving at ETAs in traffic 

3. Explain K-nearest Neighbors. (4M)


 K-Nearest Neighbour is one of the simplest Machine Learning algorithms based on
Supervised Learning technique.
 K-NN algorithm assumes the similarity between the new case/data and available cases and
put the new case into the category that is most similar to the available categories.
 K-NN algorithm stores all the available data and classifies a new data point based on the
similarity. This means when new data appears then it can be easily classified into a well
suite category by using K- NN algorithm.
 K-NN algorithm can be used for Regression as well as for Classification but mostly it is
used for the Classification problems.
 K-NN is a non-parametric algorithm, which means it does not make any assumption on
underlying data.
 It is also called a lazy learner algorithm because it does not learn from the training set
immediately instead it stores the dataset and at the time of classification, it performs an
action on the dataset.
 KNN algorithm at the training phase just stores the dataset and when it gets new data, then
it classifies that data into a category that is much similar to the new data.

PIET - DS (CE)
33
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 Example: Suppose, we have an image of a creature that looks similar to cat and dog, but
we want to know either it is a cat or dog. So for this identification, we can use the KNN
algorithm, as it works on a similarity measure. Our KNN model will find the similar
features of the new data set to the cats and dogs images and based on the most similar
features it will put it in either cat or dog category

The K-NN working can be explained on the basis of the below algorithm:

Step-1: Select the number K of the neighbours.


Step-2: Calculate the Euclidean distance of K number of neighbours.
Step-3: Take the K nearest neighbours as per the calculated Euclidean distance.
Step-4: Among these k neighbours, count the number of the data points in each category.
Step-5: Assign the new data points to that category for which the number of is maximum.

Applications of KNN:
 Text Mining
 Agriculture
 Finance
 Medical
 Facial Recognition
 Recommendation systems(Amazon, Hulu, Netflix, etc)

Advantages of KNN Algorithm:


 It is simple to implement.
 It is robust to the noisy training data
 It can be more effective if the training data is large.

Disadvantages of KNN Algorithm:


 Always needs to determine the value of K which may be complex some time.
 The computation cost is high because of calculating the distance between the data points
for all the training samples

PIET - DS (CE)
34
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

4. Explain K-means. (4M)


 K-means clustering algorithm computes the centroids and iterates until us it finds optimal
centroid. It assumes that the number of clusters are already known. It is also called flat
clustering algorithm. The number of clusters identified from data by algorithm is
represented by ‘K’ in K-means.
 In this algorithm, the data points are assigned to a cluster in such a manner that the sum of
the squared distance between the data points and centroid would be minimum. It is to be
understood that less variation within the clusters will lead to more similar data points within
same cluster.

Working of K-Means Algorithm


 Step 1 − First, we need to specify the number of clusters, K, need to be generated by
this algorithm.
 Step 2 − Next, randomly select K data points and assign each data point to a cluster. In
simple words, classify the data based on the number of data points.
 Step 3 − Now it will compute the cluster centroids.
 Step 4 − Next, keep iterating the following until we find optimal centroid which is the
assignment of data points to the clusters that are not changing any more −

Advantages
 It is very easy to understand and implement.
 If we have large number of variables then, K-means would be faster than Hierarchical
clustering.
 On re-computation of centroids, an instance can change the cluster.
 Tighter clusters are formed with K-means as compared to Hierarchical clustering.

Disadvantages
 It is a bit difficult to predict the number of clusters i.e. the value of k.
 Output is strongly impacted by initial inputs like number of clusters (value of k).
 Order of data will have strong impact on the final output.
 It is very sensitive to rescaling. If we will rescale our data by means of normalization or
standardization, then the output will completely change.final output.
 It is not good in doing clustering job if the clusters have a complicated geometric shape.

Applicatins of K-Means Clustering


 Academic performance
 Diagnostic systems
 Search engines
 Wireless sensor networks

PIET - DS (CE)
35
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

5. Explain Apriori Algorithm. (3M)

 The Apriori Algorithm is an influential algorithm for mining frequent itemsets for boolean
association rules.
 Apriori uses a "bottom up" approach, where frequent subsets are extended one item at a
time (a step known as candidate generation, and groups of candidates are tested against
the data.
 Apriori is designed to operate on database containing transactions (for example, collections
of items bought by customers, or details of a website frequentation).
 Frequent Itemsets: All the sets which contain the item with the
 minimum support (denoted by 𝐿𝑖 for 𝑖𝑡ℎ itemset).
 Apriori Property: Any subset of frequent itemset must be frequent.
 Join Operation: To find 𝐿𝑘, a set of candidate k-itemsets is generated by joining 𝐿𝑘−1 with
 itself.

STEPS TO PERFORM APRIORI ALGORITHM

STEP 1
Scan the transaction data base to get the support of S each 1-itemset, compare S with min_sup, and
get a support of 1-itemsets, L1

STEP 2
Use 𝐿𝑘−1 join 𝐿𝑘−1 to generate a set of candidate k-itemsets. And use Apriori property to prune
the unfrequented k-itemsets from this set.

STEP 3
Scan the transaction database to get the support S of each candidate k-itemset in the find set,
compare S with min_sup, and get a set of frequent k-itemsets 𝐿𝑘

PIET - DS (CE)
36
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

STEP 4
The candidate set = Null
STEP 5
For each frequent itemset 1, generate all nonempty subsets of 1
STEP 6
For every nonempty subset s of 1, output the rule “s=>(1-s)” if confidence C of the rule “s=>(1-
s)” (=support s of 1/support S of s)’ min_conf

6. Explain Advantage and Disadvantage of Unsupervised learning. (4M)

Advantages of Unsupervised Learning:


 Labeling of data demands a lot of manual work and expenses. Unsupervised learning solves
the problem by learning the data and classifying it without any labels.
 The labels can be added after the data has been classified which is much easier.
 It is very helpful in finding patterns in data, which are not possible to find using normal
methods.
 Dimensionality reduction can be easily accomplished using unsupervised learning.
 This is the perfect tool for data scientists, as unsupervised learning can help to understand
raw data.
 We can also find up to what degree the data are similar. This can be accomplished
with probabilistic methods.
 This type of learning is similar to human intelligence in some way as the model learns
slowly and then calculates the result.

Disadvantages of Unsupervised Learning


 You cannot get precise information regarding data sorting, and the output as data used in
unsupervised learning is labeled and not known
 Less accuracy of the results is because the input data is not known and not labeled by
people in advance. This means that the machine requires to do this itself.
 The spectral classes do not always correspond to informational classes.
 The user needs to spend time interpreting and label the classes which follow that
classification.
 Spectral properties of classes can also change over time so you can’t have the same class
information while moving from one image to another.

7. Explain Neural Network. (4M)


A neural network is a method in artificial intelligence that teaches computers to process
data in a way that is inspired by the human brain. It is a type of machine learning process, called
deep learning, that uses interconnected nodes or neurons in a layered structure that resembles the
human brain.

PIET - DS (CE)
37
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 It creates an adaptive system that computers use to learn from their mistakes and improve
continuously. Thus, artificial neural networks attempt to solve complicated problems, like
summarizing documents or recognizing faces, with greater accuracy.
 Neural networks can help computers make intelligent decisions with limited human
assistance. This is because they can learn and model the relationships between input and
output data that are nonlinear and complex. For instance, they can do the following tasks.

Types of neural networks

1. Feedforward neural networks

 Feedforward neural networks process data in one direction, from the input node to the
output node. Every node in one layer is connected to every node in the next layer. A
feedforward network uses a feedback process to improve predictions over time.

2. Backpropagation algorithm

Artificial neural networks learn continuously by using corrective feedback loops to improve their
predictive analytics. Only one path is the correct one that maps the input node to the correct output
node. To find this path, the neural network uses a feedback loop, which works as follows:

 Each node makes a guess about the next node in the path.
 It checks if the guess was correct. Nodes assign higher weight values to paths that lead to
more correct guesses and lower weight values to node paths that lead to incorrect guesses.
 For the next data point, the nodes make a new prediction using the higher weight paths and
then repeat Step 1.

3. Convolutional neural networks

 The hidden layers in convolutional neural networks perform specific mathematical


functions, like summarizing or filtering, called convolutions.

 They are very useful for image classification because they can extract relevant features
from images that are useful for image recognition and classification. The new form is easier
to process without losing features that are critical for making a good prediction. Each
hidden layer extracts and processes different image features, like edges, color, and depth.

PIET - DS (CE)
38
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

EXAMPLES WITH SOLUTION

1. Solve following algorithm with KNN algorithm(4M)


Test - (Het,30,M) where K = 5

Name Age Gender Sports

Kenn 35 Male cricket

20
Rima Female Football

Ana 15 Female cricket

Rushi 40 Male cricket

Yash 38 Male Football

Man 27 Male Football

Tisha 45 Female cricket

Nisha 51 Female Football

Ishita 33 Female cricket

PIET - DS (CE)
39
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

PIET - DS (CE)
40
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

PIET - DS (CE)
41
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

PIET - DS (CE)
42
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

2. EXAMPLE:(4M)
Apply KNN classification on the following dataset and predict the quality of paper_5 having Acid
Durability = 7 and Strength = 5 for K= 3 (Nearest Neighbor). (4M) The below table shows
four training samples

Sample Paper Acid Durability Strength Quality

Paper_1 7 4 Good

Paper_2 7 3 Good

Paper_3 3 4 Bad

Paeper_4 5 3 Bad

PIET - DS (CE)
43
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

PIET - DS (CE)
44
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

PIET - DS (CE)
45
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

3. EXAMPLE:(4M)
Apply KNN classification on the following dataset and predict the quality
of paper_5 having AcidDurability = 7 and Strength = 5 for K= 3 (Nearest
Neighbor). (4M)The below table shows four training samples

Sample Paper Acid Durability Strength Quality

Paper_1 7 4 Good

Paper_2 7 3 Good

Paper_3 3 4 Bad

Paeper_4 5 3 Bad

PIET - DS (CE)
46
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Step 1
 First, Number of parameters K = Number of nearest neighbors.
 Therefore, from the given data K = 3
Step 2
 Calculate the distance between the query instance and all the training samples. 
 Here query instance is (3,7) and calculates the distance by using the Euclidean Distance
formula
 The below table shows the Euclidean Distance for every paper from the query instance (3,
7):

Step 3
 Sort the distance and determine the nearest neighbors based on Kth
 minimum distance
 The below table shows the sorted distance and according to that nearest neighbor is decided
for each paper:

PIET - DS (CE)
47
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Step 4
 Collect the Quality of the nearest neighbors. Hence in the below, table Quality for Paper_2
is not included because the rank of this paper item is more than 3.
 The below table shows the quality of each paper based on the nearest neighbor:

 Here, it got 2 Good and 1 Bad value


 Based on the Majority Class is GOOD

4. EXAMPLE:(4M)
“ Restaurant A” sells burgers with optional flavors: Pepper, Ginger, and Chilly. Every day
this week you have tried a burger (A to E) and kept a record of which you liked show how
the 3NN classifier with majority voting would classify
{ pepper: false, ginger: true, chilly: true}

Training Examples:

PIET - DS (CE)
48
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Pepper Ginger Chilly Liked

A True True True False

B True False False True

C False True True False

D False True False True

 The following table shows the distance between the new example and the training example,
calculated using hamming distance.

Pepper Ginger Chilly Liked Distance

A True True True False 1+0+0=1

B True False False True 1+1+1=3

C False True True False 0+0+0=0

D False True False True 0+0+1=1

E True False False True 1+1+1=3

 Next, Based on the distance we find 3 nearest neighbors (3NN), which are marked in the
last column.

Pepper Ginger Chilly Liked Distance 3NN

PIET - DS (CE)
49
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

1+0+0
A True True True False 2
=1

1+1+1
B True False False True
=3

0+0+0
C False True True False 1
=0

0+0+1
D False True False True 2
=1

1+1+1
E True False False True
=3

 Finally, majority voting is used to assign the classification label to the new example. In this
case, we have, two False and one True nearest examples. Hence the new example is
classified as FLASE.

5. EXAMPLE: (4M)
Find a linear regression equation for the following two sets of data:

x 2 4 6 8

y 3 7 5 10
Solution:
Construct the table and find the value

X y x² xy

2 3 4 6

4 7 16 28

6 5 36 30

8 10 64 80

Σx = Σy = Σx² = Σxy =
20 25 120 144

The formula of the linear equation is y=a+bx.


PIET - DS (CE)
50
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 Hence we got the value of a = 1.5 and b = 0.95


 The linear equation is given by
Y = a + bx
 Now put the value of a and b in the equation
 Hence equation of linear regression is y = 1.5 + 0.95x

6. Example (4M)
The values of y and their corresponding values of y are shown in the table below

x 0 1 2 3 4

y 2 3 5 4 6

a) Find the least square regression line y = a x + b.


b) Estimate the value of y when x = 10.

Solution
a) We use a table to calculate a and b.

PIET - DS (CE)
51
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

X y xy x2

0 2 0 0

1 3 3 1

2 5 10 4

3 4 12 9

4 6 24 16

Σx = Σy = Σx y = Σx2 =
10 20 49 30

We now calculate a and b using the least square regression formulas for a and b.

a = (nΣx y - ΣxΣy) / (nΣx2 - (Σx)2) = (5*49 - 10*20) / (5*30 - 102) = 0.9

b = (1/n)(Σy - a Σx) = (1/5)(20 - 0.9*10) = 2.2


Now put the value of a and b in the equation

Hence equation of linear regression is y = 0.9 x + 2.2


b) Now that we have the least square regression line y = 0.9 x + 2.2, substitute x by 10 to
find the value of the corresponding y.
y = 0.9 * 10 + 2.2 = 11.2

7. Example: (4M)
Suppose we have the following dataset that has various transactions, and from this dataset,
we need to find the frequent itemsets and generate the association rules using the Apriori
algorithm:

PIET - DS (CE)
52
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Solution:
Step-1: Calculating C1 and L1:
 In the first step, we will create a table that contains support count (The frequency of each
itemset individually in the dataset) of each itemset in the given dataset. This table is called
the Candidate set or C1.

 Now, we will take out all the itemsets that have the greater support count that the Minimum
Support (2). It will give us the table for the frequent itemset L1.
Since all the itemsets have greater or equal support count than the minimum support, except
the E, so E itemset will be removed.

Step-2: Candidate Generation C2, and L2:

 In this step, we will generate C2 with the help of L1. In C2, we will create the pair of the
itemsets of L1 in the form of subsets.
 After creating the subsets, we will again find the support count from the main transaction
table of datasets, i.e., how many times these pairs have occurred together in the given
dataset. So, we will get the below table for C2:

 Again, we need to compare the C2 Support count with the minimum support count, and
after comparing, the itemset with less support count will be eliminated from the table C2.
It will give us the below table for L2

PIET - DS (CE)
53
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Step-3: Candidate generation C3, and L3:


 For C3, we will repeat the same two processes, but now we will form the C3 table with
subsets of three itemsets together, and will calculate the support count from the dataset. It
will give the below table:

 Now we will create the L3 table. As we can see from the above C3 table, there is only one
combination of itemset that has support count equal to the minimum support count. So, the
L3 will have only one combination, i.e., {A, B, C}.

Step-4: Finding the association rules for the subsets:

 To generate the association rules, first, we will create a new table with the possible rules
from the occurred combination {A, B.C}. For all the rules, we will calculate the Confidence
using formula sup( A ^B)/A. After calculating the confidence value for all rules, we will
exclude the rules that have less confidence than the minimum threshold(50%).
 Consider the below table:

Rules Support Confidence


A ^B → C 2 Sup{(A ^B) ^C}/sup(A ^B)= 2/4=0.5=50%

B^C → A 2 Sup{(B^C) ^A}/sup(B ^C)= 2/4=0.5=50%

A^C → B 2 Sup{(A ^C) ^B}/sup(A ^C)= 2/4=0.5=50%

C→ A ^B 2 Sup{(C^( A ^B)}/sup(C)= 2/5=0.4=40%

PIET - DS (CE)
54
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

A→ B^C 2 Sup{(A^( B ^C)}/sup(A)= 2/6=0.33=33.33%

B→ B^C 2 Sup{(B^( B ^C)}/sup(B)= 2/7=0.28=28%

 As the given threshold or minimum confidence is 50%, so the first three rules A ^B → C,
B^C → A, and A^C → B can be considered as the strong association rules for the given
problem.

8. Example: (4M)
Support threshold=50%, Confidence= 60%
TABLE-1
Transaction List of items
T1 I1,I2,I3
T2 I2,I3,I4
T3 I4,I5
T4 I1,I2,I4
T5 I1,I2,I3,I5
T6 I1,I2,I3,I4

Solution:

Support threshold=50% => 0.5*6= 3 => min_sup=3


1. Count Of Each Item

TABLE-2
Item Count
I1 4
I2 5
I3 4
I4 4
I5 2

TABLE -2 shows that I5 item does not meet min_sup=3, thus it is deleted, only I1, I2, I3,
I4 meet min_sup count.

TABLE-3
Item Count
I1 4
I2 5
I3 4

PIET - DS (CE)
55
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Item Count
I4 4

Form 2-itemset. From TABLE-1 find out the occurrences of 2-itemset.


TABLE-4
Item Count
I1,I2 4
I1,I3 3
I1,I4 2
I2,I3 4
I2,I4 3
I3,I4 2

TABLE -4 shows that item set {I1, I4} and {I3, I4} does not meet min_sup, thus it is
deleted.
TABLE-5
Item Count
I1,I2 4
I1,I3 3
I2,I3 4
I2,I4 3

Form 3-itemset. From the TABLE- 1 find out occurrences of 3-itemset. From TABLE-5,
find out the 2-itemset subsets which support min_sup.
We can see for itemset {I1, I2, I3} subsets, {I1, I2}, {I1, I3}, {I2, I3} are occurring
in TABLE-5 thus {I1, I2, I3} is frequent.
We can see for itemset {I1, I2, I4} subsets, {I1, I2}, {I1, I4}, {I2, I4}, {I1, I4} is not
frequent, as it is not occurring in TABLE-5 thus {I1, I2, I4} is not frequent, hence it is
deleted.
TABLE-6
Item
I1,I2,I3
I1,I2,I4
I1,I3,I4
I2,I3,I4
Only {I1, I2, I3} is frequent.

6. Generate Association Rules: From the frequent itemset discovered above the
association could be:
{I1, I2} => {I3}
Confidence = support {I1, I2, I3} / support {I1, I2} = (3/ 4)* 100 = 75%
{I1, I3} => {I2}
Confidence = support {I1, I2, I3} / support {I1, I3} = (3/ 3)* 100 = 100%
{I2, I3} => {I1}
Confidence = support {I1, I2, I3} / support {I2, I3} = (3/ 4)* 100 = 75%
PIET - DS (CE)
56
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

{I1} => {I2, I3}


Confidence = support {I1, I2, I3} / support {I1} = (3/ 4)* 100 = 75%
{I2} => {I1, I3}
Confidence = support {I1, I2, I3} / support {I2 = (3/ 5)* 100 = 60%
{I3} => {I1, I2}
Confidence = support {I1, I2, I3} / support {I3} = (3/ 4)* 100 = 75%
This shows that all the above association rules are strong if minimum confidence threshold
is 60%.

9. Example: (4M)
Let us solve a numerical problem on k means clustering. The problem is as follows. You are given
15 points in the Cartesian coordinate system as follows. K=3

Point Coordinates
A1 (2,10)
A2 (2,6)
A3 (11,11)
A4 (6,9)
A5 (6,4)
A6 (1,2)
A7 (5,10)
A8 (4,9)
A9 (10,12)
A10 (7,5)
A11 (9,11)
A12 (4,6)
A13 (3,10)
A14 (3,8)
A15 (6,11)

PIET - DS (CE)
57
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

First, we will randomly choose 3 centroids from the given data. Let us consider A2 (2,6), A7
(5,10), and A15 (6,11) as the centroids of the initial clusters. Hence, we will consider that
 Centroid 1=(2,6) is associated with cluster 1.
 Centroid 2=(5,10) is associated with cluster 2.
 Centroid 3=(6,11) is associated with cluster 3.

Now we will find the euclidean distance between each point and the centroids. Based on the
minimum distance of each point from the centroids, we will assign the points to a cluster.

Now, we will calculate the new centroid for each cluster.

PIET - DS (CE)
58
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 In cluster 1, we have 6 points i.e. A2 (2,6), A5 (6,4), A6 (1,2), A10 (7,5), A12 (4,6), A14
(3,8). To calculate the new centroid for cluster 1, we will find the mean of the x and y
coordinates of each point in the cluster. Hence, the new centroid for cluster 1 is (3.833,
5.167).
 In cluster 2, we have 5 points i.e. A1 (2,10), A4 (6,9), A7 (5,10) , A8 (4,9), and A13 (3,10).
Hence, the new centroid for cluster 2 is (4, 9.6)
 In cluster 3, we have 4 points i.e. A3 (11,11), A9 (10,12), A11 (9,11), and A15 (6,11).
Hence, the new centroid for cluster 3 is (9, 11.25).
 Now that we have calculated new centroids for each cluster, we will calculate the distance
of each data point from the new centroids. Then, we will assign the points to clusters based
on their distance from the centroids.

PIET - DS (CE)
59
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

Now, we will calculate the new centroid for each cluster for the third iteration.

 In cluster 1, we have 5 points i.e. A2 (2,6), A5 (6,4), A6 (1,2), A10 (7,5), and A12 (4,6).
To calculate the new centroid for cluster 1, we will find the mean of the x and y coordinates
of each point in the cluster. Hence, the new centroid for cluster 1 is (4, 4.6).
 In cluster 2, we have 7 points i.e. A1 (2,10), A4 (6,9), A7 (5,10) , A8 (4,9), A13 (3,10),
A14 (3,8), and A15 (6,11). Hence, the new centroid for cluster 2 is (4.143, 9.571)
 In cluster 3, we have 3 points i.e. A3 (11,11), A9 (10,12), and A11 (9,11). Hence, the new
centroid for cluster 3 is (10, 11.333).
PIET - DS (CE)
60
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

 In cluster 1, we have 5 points i.e. A2 (2,6), A5 (6,4), A6 (1,2), A10 (7,5), and A12 (4,6).
To calculate the new centroid for cluster 1, we will find the mean of the x and y coordinates
of each point in the cluster. Hence, the new centroid for cluster 1 is (4, 4.6).
 In cluster 2, we have 7 points i.e. A1 (2,10), A4 (6,9), A7 (5,10) , A8 (4,9), A13 (3,10),
A14 (3,8), and A15 (6,11). Hence, the new centroid for cluster 2 is (4.143, 9.571)
 In cluster 3, we have 3 points i.e. A3 (11,11), A9 (10,12), and A11 (9,11). Hence, the new
centroid for cluster 3 is (10, 11.333).
Here, you can observe that no point has changed its cluster compared to the previous iteration. Due
to this, the centroid also remains constant. Therefore, we will say that the clusters have been
PIET - DS (CE)
61
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING (03606387)

stabilized. Hence, the clusters obtained after the third iteration are the final clusters made from the
given dataset. If we plot the clusters on a graph, the graph looks like as follows.

PIET - DS (CE)
62

You might also like