New Horizon College of Engineering
Course Name : AI and ML
(Module – 1)
A) Artificial Intelligence (AI)
Artificial Intelligence (AI) is the branch of computer science that focuses on building machines and/or
programs that can perform tasks that normally require human intelligence—such as learning,
reasoning, problem-solving, perception, and language understanding.
A widely accepted definition was given by John McCarthy, who described AI as “the science and
engineering of making intelligent machines.”
Key Capabilities of AI
• Learning from data (Machine Learning)
• Understanding language (Natural Language Processing)
• Recognizing images and speech
• Decision-making and planning
• Problem-solving
Illustration
Think of a spam email filter:
• It observes examples of spam and non-spam emails.
• It learns patterns (keywords, sender behavior).
• It predicts whether a new email is spam.
Another example:
• A self-driving car detects pedestrians using cameras and decides when to stop.
B) Well-Posed Learning Problems
The concept of a well-posed learning problem was clearly defined by Tom M. Mitchell.
According to him:
A computer program is said to learn from experience (E) with respect to some class of tasks (T) and
performance measure (P) if its performance at tasks in T, as measured by P, improves with experience
E.
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 1 of 13
Three Key Components
1. T – Task
o What the system is supposed to do.
o Example: Classify emails as spam or not spam.
2. E – Experience
o The data or interactions used for learning.
o Example: A dataset of labeled spam and non-spam emails.
3. P – Performance Measure
o How success is measured.
o Example: Accuracy (percentage of correctly classified emails).
o Other Measures : Confusion Matrix, Accuracy, Precision, Specificity, F1 Score and Recall
Illustration: Spam Filter Example
• Task (T): Classify emails.
• Experience (E): 10,000 previously labeled emails.
• Performance (P): 95% classification accuracy.
If accuracy improves as more emails are analyzed, the system is learning.
C)Designing a Learning System
Designing a learning system involves specifying how a machine will improve its performance through
experience. According to Tom M. Mitchell, a learning system must clearly define:
1. Task (T) – What needs to be learned.
2. Performance Measure (P) – How improvement is evaluated.
3. Experience (E) – The data used for learning.
Steps in Designing:
• Define the problem (e.g., classification or prediction).
• Select appropriate training data.
• Choose a target function.
• Select a learning algorithm.
• Evaluate performance using a suitable metric.
Example:
For a spam filter:
• T: Classify emails
• P: Accuracy
• E: Labeled email dataset
C.1) Choosing the Training Experience
Training experience refers to the data or interaction used to train the learning system.
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 2 of 13
Key considerations:
1. Direct vs Indirect Experience
o Direct: Real-world data (e.g., actual driving data for self-driving cars, Loan Sanction Data from
Banks).
o Indirect: Simulated data (e.g., chess games played against a computer).
2. Supervised vs Unsupervised Learning
o Supervised: Data includes correct outputs (labels).
o Unsupervised: No labeled outputs.
3. Representativeness
o Training data should represent real-world situations.
4. Size and Quality
o More relevant and clean data improves learning accuracy.
Example:
To train a handwriting recognition system, thousands of labeled handwritten samples are used as
training experience.
C-2) Choosing the Target Function
A target function defines what the system is trying to learn. It maps input examples to output values.
In machine learning, the target function (f) is the best mapping from inputs (X) to outputs (Y) that we
want the system to learn. Since the exact target function is usually unknown, we choose a
representation for approximating it.
It is generally written as:
f:X→Y
Where:
• X = Input space
• Y = Output space
The goal of the learning algorithm is to approximate this unknown target function using a hypothesis
(h).
Example:
In a spam classifier:
• Input (X): Email features (keywords, sender, length).
• Output (Y): Spam or Not Spam.
• Target Function (f): Correct classification rule.
The system learns a hypothesis function that approximates the true target function.
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 3 of 13
Common Representations:
• Decision Trees
• Neural Networks
• Rule-based representations
• Probabilistic models (Example : Gaussian Mixture Model)
Key Considerations:
1. The representation should be expressive enough to model the problem.
2. It should not be too complex (to avoid overfitting).
3. It should match the nature of the problem
Example:
For a spam classifier:
• Inputs: Email features
• Output: Spam / Not spam
• Representation: Decision tree or linear classifier
C-3). Choosing a Function Approximation Algorithm
It is essentially an algorithm to optimize the Target Function so that it best fits the Training Data. Also
known as a learning algorithm
Common Algorithms:
• Gradient Descent (used in neural networks)
• ID3 algorithm (for decision trees)
• k-Nearest Neighbors (k-NN)
• Support Vector Machines (SVM)
Key Considerations:
1. Accuracy of results
2. Computational efficiency
3. Amount of training data required
4. Risk of overfitting
Example:
If using a neural network as representation, gradient descent is used to adjust weights to minimize
error.
Summary
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 4 of 13
Concept Meaning
Form in which target function is expressed
Representation
(e.g., tree, linear model)
Method used to find best hypothesis in
Function Approximation Algorithm
chosen representation
D)Perspectives in Machine Learning
Machine Learning (ML) is a subfield of AI that enables systems to learn from data and improve
performance over time.
1. Statistical Perspective – Learning as statistical inference from data.
2. Computational Perspective – Focus on algorithms and efficiency.
3. Biological Perspective – Inspired by human learning (e.g., neural networks).
4. Symbolic Perspective – Learning rules and logical representations.
The formal framework of learning problems was clearly defined by Tom M. Mitchell using Task (T),
Experience (E), and Performance (P).
Major Issues in Machine Learning
1. Overfitting and Underfitting
2. Noise in Training Data
3. Insufficient Data
4. Choice of Representation
5. Computational Complexity
6. Generalization Ability
Example:
A model trained only on a small dataset of emails may fail to classify new emails correctly due to
overfitting.
E) Problem Spaces and Search
In Artificial Intelligence, many problems are solved using search techniques.
Problem Space
A problem space consists of:
• Initial State
• Goal State
• Operators (Actions)
• State Space (all possible states)
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 5 of 13
A Solution is a sequence of actions that transforms the initial state into the goal state.
Example: 8-Puzzle Problem
• Initial state: Random tile arrangement
• Goal state: Ordered tiles
• Operators: Legal Moves blank tile up, down, left, right
Search explores the state space to find a solution.
What is State Space?
What is Search Space?
F) Blind Search Techniques
Here the search for the Goal State is not guided by any Heuristic function.
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 6 of 13
1. Depth First Search (Example Given)
2. Breadth First Search (Example Given)
G) Heuristic Search Techniques
A heuristic is a rule or strategy that helps guide the search process toward the goal more efficiently.
Heuristic search uses domain-specific knowledge to reduce search time compared to blind search
methods.
Common Heuristic Search Techniques:
3. Best-First Search
4. Hill Climbing
5. A* Search Algorithm
6. AO* Search Algorithm
7. 8-puzzle Problem
For example, in the 8-puzzle:
• A heuristic function may count the number of misplaced tiles.
• The algorithm selects the state with the lowest estimated cost to reach the goal.
Advantages:
• Faster than blind search
• Reduces unnecessary exploration
Disadvantages:
• May not always find optimal solution
• Can get stuck in local maxima (e.g., hill climbing)
Summary Table
Concept Meaning
Perspectives in ML Different viewpoints (statistical, computational, etc.)
Problem Space All possible states of a problem
Heuristic Search Search guided by problem-specific knowledge
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 7 of 13
Annexure
1) Depth First Search (DFS)
DFS Rule: It is a Blink Search Method where we go as deep as possible before backtracking. We use a
Stack to list the nodes to be visited.
State Space : The State Space is as shown in the image below
Step-1
Traversal Order : Use a Stack to list the adjacent nodes
• Start at A
• Go to B
• Go to D (no children → backtrack)
• Back to B
• Go to E
• Go to H (no children → backtrack)
• Back to E
• Go to I (no children → backtrack)
• Back to A
• Go to C
• Go to F (backtrack)
• Go to G
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 8 of 13
Search Space
The order in which search was performed.
2) Breadth First Search (BFS)
BFS Rule: It is a Blink Search Method where we visit nodes level by level using a Queue.
Step 1
Start at A
Queue: [A]
Output: A
Step 2
Dequeue A, enqueue its neighbors B, C
Queue: [B, C]
Output: A
Step 3
Dequeue B, enqueue D, E
Queue: [C, D, E]
Output: A, B
Step 4
Dequeue C, enqueue F, G
Queue: [D, E, F, G]
Output: A, B, C
Step 5
Dequeue D (no children)
Queue: [E, F, G]
Output: A, B, C, D
Step 6
Dequeue E, enqueue H, I
Queue: [F, G, H, I]
Output: A, B, C, D, E
Step 7
Dequeue F
Queue: [G, H, I]
Output: A, B, C, D, E, F
Step 8
Dequeue G
Queue: [H, I]
Output: A, B, C, D, E, F, G
Step 9
Dequeue H
Queue: [I]
Output: A, B, C, D, E, F, G, H
Step 10
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 9 of 13
Dequeue I
Queue: []
Output: A, B, C, D, E, F, G, H, I
Search Space
A→B→C→D→E→F→G→H→I
Search Space of DFS
Search Space of BFS
3) Best First Search
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 10 of 13
Rule:
Always expand the node with the smallest heuristic value h(n) from the OPEN list.
Node h(n)
S 10
A8
B6
C7
D5
E3
F6
H4
I2
G0
Step 1: Start at S
OPEN = {S}
CLOSED = { }
Expand S → Add A, B, C
OPEN = {A(8), B(6), C(7)}
Choose node with smallest h(n): B (6)
Step 2: Expand B
B→F
OPEN = {A(8), C(7), F(6)}
CLOSED = {S, B}
Choose smallest: F (6)
Step 3: Expand F
F→G
OPEN = {A(8), C(7), G(0)}
CLOSED = {S, B, F}
Choose smallest: G (0)
Step 4: Goal Reached
Since G has heuristic 0 and is the goal node, search stops.
Final Path Found : S → B → F → G
4) Hill Climbing Algorithm
Hill Climbing is a local search algorithm used for optimization problems.
It starts with an initial solution and iteratively moves to a better neighboring solution until no better
neighbor exists.
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 11 of 13
It is called hill climbing because it is like climbing a hill step by step — always moving upward until
you reach the top (maximum).
Algorithm (Maximization Version)
1. Start with an initial state S.
2. Evaluate its value f(S).
3. Generate all neighboring states of S.
4. Choose the neighbor with the highest value.
5. If the neighbor’s value is better than current:
o Move to that neighbor.
6. Else:
o Stop (local maximum reached).
Example:
Maximize the function: f(x)=−x2+6x
Initial State
Let’s start with:
Evaluate : x=0, f(0)=0
Check Neighbors
Assume neighbors are x+1 and x-1.
Neighbors of x = 0:
• x = 1
• x = -1
Evaluate: f(1)=−1+6=5, f(−1)=−1−6=−7
Repeat
At x = 1
Neighbors:
• x = 0
• x = 2
f(2)=−4+12=8, f(0)=0
Move to x = 2
At x = 2
Neighbors:
• x = 1
• x = 3
f(3)=−9+18=9, f(3)=−9+18=9
Move to x = 3
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 12 of 13
At x = 3
Neighbors:
• x = 2
• x = 4
f(4)=−16+24=8, f(2)=8
No neighbor has value greater than 9.
So we stop.
Final Answer
Maximum found at: x=3, f(3)=9
____________________________________________________________________________________________________________________________
Compiled by : Narayana Maddala, Professor of Practice, NHCE Page 13 of 13