Module 1 - Introduction
Module 1 - Introduction
1
Course Material
• Class notes, ppts.
• Text Books
1. Machine Learning, Tom Mitchell, McGraw Hill, 1997.
2. Ethem Alpaydin, Introduction to Machine Learning, PHI,
2016
• Reference Books
1. T. Hastie, R. Tibshirani, J. Friedman. The Elements of
Statistical Learning, 2e, 2008.
2. Christopher Bishop. Pattern Recognition and Machine
Learning. 2e, 2006.
3. Richard O. Duda, Peter E. Hart, David G. Stork. Pattern
classification, Wiley, New York, 2001.
2
What is Learning?
Learning
The ability to improve behavior based on the experience.
3
What is Learning?
Learning
The ability to improve behavior based on the experience.
4
What is Learning?
5
What is Learning?
6
What is Learning?
7
What is Learning?
Correct 2 3 4
Incorrect 3 2 1
8
What is Machine Learning?
9
Machine Learning
10
Machine Learning to a Layman
11
What is Machine Learning?
Machine Learning
Design of Algorithm that-
• Learn from data or build models using that data
• The learned model can be used to
• Detect patterns/structures/themes/trends etc. in the data
• Make predictions about future data and make decisions
• Modern ML algorithms are heavily “data-driven”
• No need to pre-define and hard-code all the rules (usually
infeasible/impossible anyway).
• The rules are not “static”; can adapt as the ML algorithm
ingests with more and more data.
12
Machine Learning vs Programming
13
When to Use Machine Learning?
• Human expertise is absent
Example: navigating on mars
• Humans are unable to explain their expertise Example:
vision, speech, language
• Requirements and data change over time
Example: Tracking, Biometrics, Personalized
fingerprint recognition
• The problem or the data size is just too large
Example: Web Search
• When not to use it: If you can precisely/mathematically describe
how to solve the task. Just program it.
14
Why Machine Learning?
• Machine Learning term first coined in 1959
• Computer Model based on Neural Network was created in
1943
15
Why Machine Learning?
• Machine Learning term first coined in 1959
• Computer Model based on Neural Network was created in
1943
16
Why Machine Learning?
17
Why Machine Learning?
• Structured Data
• Unstructured Data
• “More than 300 million photos get uploaded per day.
• Every minute there are 510,000 comments posted
and 293,000 statuses updated”
DATA • “Over 2.5 quintillion bytes of data are created
every single day, and it's only going to grow from
there.
• By 2020, it is said that 1.7MB of data has been
created every second for every person on earth”
More than 80% data is unstructured.
18
Why Machine Learning?
Python
Libraries: Pandas, Numpy, Sklearn, Keras
TensorFlow, PyTorch, Theano
OPTIMIZED
ALGORITHMS Less programming more science!
19
Why Machine Learning?
Powerful CPUs
GPU
Parallel and Distributed Computing
COMPUTING
POWER
20
Jargon Difference!
Machine Learning
Data Science
21
Jargon Difference!
22
Types of Learning
• Supervised (inductive) learning: Training data includes desired
outputs.
• Unsupervised learning: Training data does not include desired
outputs, Find hidden/interesting structure in data.
• Semi-supervised learning: Training data includes a few desired
outputs
• Reinforcement learning: the learner interacts with the world
via “actions” and tries to find an optimal policy of behavior
with respect to “rewards” it receives from the environment
23
Types of Learning
24
A Typical Supervised Learning Workflow (for
Classification)
25
A Typical Supervised Learning Workflow (for
Classification)
26
A Typical Un-supervised Learning Workflow (for
Clustering)
27
A Typical Un-supervised Learning Workflow (for
Clustering)
29
Geometric View of Some Basic ML Problems
Regression
Supervised Learning:
Learn a line/curve (the “model”)
using training data consisting of
Input-output pairs (each output is a
real-valued number)
Classification
Clustering
Dimensionality Reduction
Labeled
“dog
Training ”
“dog
Data “dog
”
” Supervised ML p(class|image)
“cat”
“cat”
“cat”
Unlabeled
Training p(image)
Unsupervised ML
Data
32
Machine Learning = Function Approximation
Supervised Learning (“predict y given x ”) can be thought learning a function that maps x to y
Labeled “dog
Training “dog
”
”
Data “dog
Supervised : image class
”
“cat
ML
”
“cat”
“cat”
Unsupervised Learning (“model x ”) can also be thought of as learning a function that maps x to
some useful latent representation of x
Unlabeled
Training
Data latent representation
Unsupervised : image of image (e.g., cluster
ML
id or compressed
version)
34
Machine Learning helps Computer
Vision
35
Machine Learning helps Computer
Vision
36
Machine Learning helps NLP
37
Machine Learning helps NLP
38
Machine Learning helps NLP
39
Machine Learning helps NLP- Search and Info
Retrieval
40
Machine Learning meets Speech Processing
ML algorithms can learn to translate speech in real time
41
Machine Learning helps Chemistry
ML algorithms can understand properties of molecules and learn to
synthesize new molecules
42
Machine Learning helps Chemistry
ML algorithms can “read” databases of matetials and recreate the
Periodic Table within hours
“Recreated” Periodic Table
43
Machine Learning helps in Biology, E-commerce
44
Inductive Learning
45
Inductive Learning
What is Inductive Learning Algorithm?
Inductive Learning Algorithm (ILA) is an iterative algorithm that is used for
generating a set of classification rules, which produces rules of the form “IF-THEN”,
for a set of examples, producing rules at each iteration and appending to the set of rules.
• In other words, the learner infers a general hypothesis from observed
instances.
• Also called as Deterministic Supervised Learning
• In this, first input x, (the verified value) given to a function f, and the output
is f(x).
• Then we can give different set of inputs (raw inputs) to the same function f,
and verify the output f(x).
• By using the outputs we generate (learn) the rules.
46
Need for Inductive Learning
• It enables machines to generalize from limited examples to handle unseen
data.
• Real-world problems cannot be solved using predefined rules; inductive
learning helps discover patterns automatically.
• It supports prediction and decision-making in uncertain and dynamic
environments.
• It reduces the need for explicit programming by learning directly from data.
• It forms the foundation of most machine learning and AI applications such
as classification, regression, and pattern recognition.
47
Importance of Inductive Learning in ML
Inductive learning forms the backbone of many machine learning algorithms,
allowing systems to adapt and improve from exposure to data, thereby enhancing
decision-making processes.
48
Inductive Learning Process
Data Collection:
• Gather labeled examples representing the problem domain.
• Example: Emails labeled as spam or non-spam in a classification task.
Hypothesis Space:
• Define the set of possible hypotheses/models based on the chosen algorithm and
inductive bias.
Hypothesis Generation:
• Construct potential hypotheses using observed examples.
• Analyze instance features to identify patterns or relationships.
Hypothesis Evaluation:
• Assess hypotheses using evaluation metrics or validation techniques.
• Test predictive accuracy on new, unseen examples.
Hypothesis Refinement:
• Refine hypotheses iteratively based on evaluation feedback.
• Update models to enhance performance and generalization.
Generalization:
• Apply the final model to classify or predict new, unseen data instances.
49
Inductive Learning Process
50
Inductive Learning
• Inductive learning or “Prediction”:
– Given examples of a function (X, F(X))
– Predict function F(X) for new examples X
This is the function which we are trying to learn.
• Classification
F(X) = Discrete
• Regression
F(X) = Continuous
• Probability estimation
F(X) = Probability(X):
Output
• A set of predictions y1, y2, y3, ...., yc
• One of the fixed set of constant values
• Eg: {+1, -1}
2. Integer Valued
Example: Number of words in a text
55
Basic Terminologies
Example:
<0.5,2.8,+>
+
+ + +
-
+ + - - -
+ - +
3.0
-
- + + -
- -
2.0
+ -
+ + -
1.0
-
0.0
56
Basic Terminologies
Possible Functions
1. Slanted line with 2 parameters
y= mx +c
-> We need to define both intercept and slope.
2. Polynomial
quadratic function: ax² + bx +c
a,b,c- 3 parameters
3. Complex Function
Note:- We are interested in a function which not only fit the
training data but also works well with future or test data.
57
Basic Terminologies
Representation of Function
• The representation of a hypothesis in machine learning
depends on the chosen features and the function class,
which together determine how input data is mapped to
output predictions.
• Features
Features are the measurable attributes or input variables used
to describe the data. They transform raw data into a suitable
form for learning.
• Function Class (Hypothesis Space)
The function class defines the set of all possible functions
(models) the learning algorithm can choose from, such as
linear functions, decision trees, or neural networks.
58
Basic Terminologies
Representation
59
Basic Terminologies
Representation
60
Basic Terminologies
Hypothesis:
Function for labeling examples
Label: + + Label: -
+ ? + +
-
+ + - - -
+ ? - +
3.0
- ?
- + + -
- -
2.0
+ -
+ + - ?
1.0
-
0.0
61
Hypothesis Space
• There could be many possible functions that explain the given training data.
• It is the set of legal hypothesis
• There could be multiple legal hypothesis or functions set of all such legal
hypothesis is called as hypothesis space.
• Eg: class 1: +ve, class 2: -ve
62
Hypothesis Space
Hypothesis Space:
Set of legal hypotheses
+
+ + +
-
+ + - - -
+ - +
3.0
-
- + + -
- -
2.0
+ -
+ + -
1.0
-
0.0
63
Hypothesis Space
Target Function
It's a function which maps every input x to an output y, we denote it by f.
64
Hypothesis Space
65
Inductive Learning In General
Inducing a general function from training examples.
Constructs a hypothesis h to agree with all the training examples
A hypothesis is consistent if it agrees (works will) with all training
examples.
A hypothesis is said to be generalized if it correctly predicts the value of
y for new examples.
66
Inductive Learning Algorithms
67
Applications of Inductive Learning
68
Challenges in Inductive Learning
69
Supervised Learning
Given: <x, f(x)> for some unknown function f
Learn: A hypothesis H, that approximates f
Example Applications:
• Disease diagnosis
x: Properties of patient (e.g., symptoms, lab test results)
f(x): Predict disease
• Automated steering
x: Bitmap picture of road in front of car
f(x): Degrees to turn the steering wheel
• Credit risk assessment
x: Customer credit history and proposed purchase
f(x): Approve purchase or not
70
71
Learning = Representation + Evaluation
+ Optimization
• Combinations of just three elements
Representation Evaluation Optimization
Instances Accuracy Greedy search
Hyperplanes Precision/Recall Branch & bound
Decision trees Squared error Gradient descent
Sets of rules Likelihood Quasi-Newton
Neural networks Posterior prob. Linear progr.
Graphical models Margin Quadratic progr.
Etc. Etc. Etc.
72
Inductive BIAS
As we can see that hypothesis space is very large. It is not possible to
look at every hypothesis individually to choose the best hypothesis.
So we put some restrictions on hypothesis.
If we restrict the hypothesis, it reflects a bias of the learning
algorithm
74
Generalization & Error
Bias
This is the error introduced due to simplifying assumptions
made by a model
Simplified assumptions limit the model's capacity to learn.
Low Bias
Suggests less assumptions about the form of the target
function.
High Bias
Suggests more assumptions about the form of the target
function.
75
Generalization & Error
Variance
Variance tells that how much a random variable is different
from its expected value.
If the machine learning model performs well with the training
dataset, but does not perform well with the test dataset, then
variance occurs.
Low variance.
Suggests small change to the estimated models with Changes
to the training dataset.
High variance.
Suggests large changes, to the estimated models with Changes
to the training dataset.
76
Bias Variance Trade-off
Test
Train Data
Test Data
77
Bias Variance Trade-off
Complex Model
No error on training data
What about test set?
Test Data
78
Bias Variance Trade-off
Complex Model
No error on training data
Test Data
79
Bias Variance Trade-off
Complex Model
No error on training data
Test Data
80
Bias Variance Trade-off
81
Bias Variance Trade-off
Simple Model
More error on training data
What about test set?
Test Data
82
Bias Variance Trade-off
Simple Model
More error on training data
What about test set?
Test Data
83
Bias Variance Trade-off
Simple Model
More error on training data
What about test set?
Test Data
84
Bias Variance Trade-off
85
Bias Variance Trade-off
86
Bias Variance Trade-off
High Low
Train Error
High Bias Low Bias
High Low
Test Error
High Variance Low Bias
Train Data
Test Data
87
Over-fitting
• Over-fitting & under-fitting are two main errors/problems in the
machine learning model, which cause poor performance in
Machine Learning.
• Over-fitting occurs when the model fits more data than required,
and it tries to capture each and every data point fed to it.
Hence it starts capturing noise and inaccurate data from the
dataset, which degrades the performance of the model.
• An over-fitted model doesn't perform accurately with the
test/unseen dataset and can’t generalize well.
• An over-fitted model is said to have low bias and high variance.
88
How to avoid Overfitting
• Using cross-validation
• Using Regularization techniques
• Implementing Ensemble Techniques.
• Picking a less parameterized/complex model
• Training the model with sufficient data
• Removing features
• Early stopping the training
89
Under-fitting
• Model cannot create a mapping between the input and the target
variable
• Under-observing features leads to a higher error in the training
and unseen data samples.
• Under-fitting becomes obvious when the model is too simple and
cannot create a relationship between the input and the output.
90
How to avoid Under-fitting
91
92
Over-fitting
Over-fitting during training
Model
error Error on
new data
Training error
Number of iterations
93
Regularization and Over-fitting
Adding a regularizer:
Model
error Without regularizer
With regularizer
Number of iterations
94
Cross-Validation
• Cross-validation involves partitioning your data into
distinct training and test subsets.
95
K-fold Cross-Validation
• To get more accurate estimates of performance you
can do this k times.
• Break the data into k equal-sized subsets Ai
• For each i in 1,…,k do:
– Train a model on all the other folds A1,…, Ai-1, Ai+1,…, Ak
– Test the model on Ai
• Compute the average performance of the k runs
96
5-fold Cross-Validation
97
Occam’s Razor
Key points:
• Focuses on parsimony (simplicity)
• Avoids unnecessary assumptions or parameters
• Complex models may cause overfitting
• Simpler models generalize better on unseen data
• Widely used in science, statistics, and machine learning
98
Occam’s Razor
99
Learning as a search
100