Module 03
Module 03
Module 03
Module – 03
• Learning is a process by which one can acquire knowledge and construct new ideas or
concepts based on the experiences.
• Machine learning is an intelligent way of learning general concept from training examples
without writing a program.
• There are many machine learning algorithms through which computers can intelligently
learn from past data or experiences, identify patterns, and make predictions when new
data is fed.
Learning Objectives
Understand the basics of learning theory and the key elements of machine learning.
Introduce Concept learning to obtain an abstraction and generalization from the data.
Learn about hypothesis representation language and to explore searching the hypothesis
space using Find-S algorithm and its limitations.
Study about version spaces, List-Then-Eliminate algorithm and Candldate Elimination
algorithm. Introduce Inductive bias, a set of prior assumptions considered by a learning
algorithm beyond the training data in order to perform induction.
Discuss the tradeoff between the two factors called bias and variance which exist when
modelling a machine learning algorithm.
Understand the different challenges in model selection and model evaluation. Study
popular re-sampling model selection method called Cross-Validation (K-fold, LOOCYV,
etc.) to tune machine learning model.
Introduce the various learning frameworks and learn to evaluate hypothesis.
Let. the unknown target function be f: X = Y, that maps the input space to output space.
The objective of the learning Program is to pick a function, g: y — Y to approximate
hypothesis f. All the possible formulae form a hypothesis space.
In short, let H be the set of all formulae from which the learning algorithm chooses. The
choice is good when the hypothesis g replicates f for all samples. This is shown in Figure
3.1.
These values are processed and a hypothesis is generated as output model. This model is
then used for making predictions.
The predicted values are consumed by the environment. In contrast to the classical
systems, adaptive systems interact with the input for getting labelled data as direct inputs
are not available.
This process is called reinforcement learning. In reinforcement learning, a learning agent
interacts with the environment and in return gets feedback.
Based on the feedback, the learning agent generates input samples for learning, which are
used for generating the learning model.
Such learning agents are not static and change their behavior according to the external
signal received from the environment.
The feedback is known as reward and learning here is the ability of the learning agent
adapting to the environment based on the reward. These are the characteristics of an
adaptive system.
Learning
Types There are different types of learning. Some of the different learning methods are as
follows:
Acquiring general concept from specific instances of the training dataset is the main
challenge of machine learning.
These questions are the basis of a field called ‘Computational Learning Theory’ or in
short (COLT). It is a specialized field of study of machine learning.
COLT deals with formal methods used for learning systems. It deals with frameworks for
quantifying learning tasks and learning algorithms.
It provides a fundamental basis for study of machine learning.
Computational Learning Theory uses many concepts from diverse areas such as
Theoretical Computer Science, Artificial Intelligence and Statistics.
The core concept of COLT is the concept of learning framework. One such important
framework is PAC.
It deals with Probably Approximate Learning (PAC) and Vapnik-Chervonenkis (VC)
dimensions.
The learning framework is discussed in a detailed manner in COLT focuses on supervised
learning tasks. Since the complexity of analyzing is difficult, normally, binary
classification tasks are considered for analysis.
Training Experience
Let us consider designing of a chess game. In direct experience, individual board states
and correct moves of the chess game are given directly.
In indirect system, the move sequences and results are only given. The training
experience also depends on the presence of a supervisor who can label all valid moves for
a board state.
In the absence of a supervisor, the game agent plays against itself and learns the good
moves, if the training samples cover all scenarios, or in other words, distributed enough
for performance computation.
If the training samples and testing samples have the same distribution, the results would
be good.
Here, b is the sample and v(b) is the predicted hypothesis. The approximation is carried, "
out as:
Output — Target concept or Target function f. It is a mapping function f(x) from input x to
output y. It is to determine the specific features or common features to identify an object.
Representation of a Hypothesis
hypothesis ‘h’ approximates a target function ‘f’ to represent the relationship between the
independent attributes and the dependent attribute of the training instances.
The hypothesis is the predicted approximate model that best maps the inputs to outputs.
Each hypothesis is represented as a conjunction of attribute conditions in the antecedent
part.
For example, (Tail = Short) A (Color = Black).... The set of hypothesis in the search
space is called as hypotheses. Hypotheses are the plural form of hypothesis.
Generally ‘H’ is used to represent the hypotheses and ‘i’ is used to represent a candidate
hypothesis.
Thus, concept learning can also be called as Inductive Learning that tries to induce a
general function from specific training instances.
That is why a hypothesis is an approximate target function that best maps the inputs to
outputs.
Hypothesis Space
Hypothesis space is the set of all possible hypotheses that approximates the target
function f. In other words, the set of all possible approximations of the target function can
be defined as hypothesis space.
From this set of hypotheses in the hypothesis space, a machine learning algorithm would
determine the best possible hypothesis that would best describe the target function or best
fit the outputs.
Generally, a hypothesis representation language represents a larger hypothesis space.
Every machine learning algorithm would represent the hypothesis space in a different
manner about the function that maps the input variables to output variables.
For example, a regression algorithm represents the hypothesis space as a linear function
whereas a decision tree algorithm represents the hypothesis space as a tree.
The set of hypotheses that can be generated by a learning algorithm can be further
reduced by specifying a language bias.
The subset of hypothesis space that is consistent with all-observed training instances is
called as Version Space. Version space represents the only hypotheses that are used for
the classification.
For example, each of the attribute given in the Table 3.1 has the following possible set of
values.
Hypothesis ordering is also important wherein the hypotheses are ordered from the most
specific one to the most general one in order to restrict searching the hypothesis space
exhaustively.
Heuristic search methods will generate a possible hypothesis that can be a solution in the
hypothesis spacer or a path from the initial state.
In order to understand about how we construct this concept hierarchy, Jet us apply this
general principle of generalization/specialization relation.
By generalization of the most specific hypothesis and by specialization of the most
general hypothesis, the hypothesis space can be searched for an approximate hypothesis
that matches all positive instances but does not match any negative instance.
Example:- Consider the training instances shown in Table 3.1 and illustrate Specific to
General Learning.
illustrate learning by Specialization — General to Specific Learning for the data instances
shown in Table 3.1. Solution: Start from the most general hypothesis which will make true all
positive and negative instances.
Example:- Consider the training dataset of 4 instances shown in Table 3.2. It contains the
details of the performance of students and their likelihood of getting a job offer or not in their
final semester. Apply the Find-S algorithm.
Version Spaces
The version space contains the subset of hypotheses from the hypothesis space that is
consistent with all training instances in the training dataset.
List-Then-Eliminate Algorithm
The principle idea of this learning algorithm is to initialize the version space to contain all
hypotheses and then eliminate any hypothesis that is found inconsistent with any training
instances.
Initially, the algorithm starts with a version space to contain all hypotheses scanning each
training instance, The hypotheses that are inconsistent with the training instance are
eliminated.
Finally, the algorithm outputs the list of remaining hypotheses that are all consistent.
This algorithm works fine if the hypothesis space is finite but practically it is difficult to
deploy this algorithm. Hence, a variation of this idea is introduced in the Candidate
Elimination algorithm.
Version space learning is to generate all consistent hypotheses around. This algorithm
computes the version space by the combination of the two cases namely,
The algorithm defines two boundaries called 'general boundary’ which is a set of all
hypotheses that are the most general and “specific boundary’ which is a set of all
hypotheses that are the most specific.
Thus, the algorithm limits the version space to contain only those hypotheses that are
most general and most specific. Thus, it provides a compact representation of List-then
algorithm.
We need to take the combination of sets in ‘G and check that with ‘S’. When the combined
set fields are matched with fields in °S’, the only that is included in the version space as
consistent hypothesis.
Example:-
Consider the same set of instances from the training dataset shown in Table 33 and generate
version space as consistent hypothesis.
Since it is a negative instance, specialize G2 to exclude the negative example but stay
consistent with S2. Generate hypothesis for each of the non-matching attribute value
in S2 and fill with the attribute value of S2.
There is no inconsistent hypothesis in 52 with the negative instance, hence S3 remains the
same.
Similarity-based Learning is a supervised learning technique that predicts the class label
of a test instance by gauging the similarity of this test instance with training instances.
Similarity-based learning refers to a family of instance-based learning which is used to
solve both classification and regression problems.
Similarity-based classification is useful in various fields such as image processing, text
classification, pattern recognition, bio informatics, data mining, information retrieval,
natural language processing, etc.
A practical application of this learning is predicting daily stock index price changes.
Learning Objectives
NEAREST-NEIGHBOR LEARNING
A natural approach to similarity-based classification is k-Nearest-Neighbors (k-NN),
which is a non-parametric method used for both classification and regression problems.
It is a simple and powerful non-parametric algorithm that predicts the category of the test
instance according to the ‘K’ training samples which are closer to Q the test instance and
classifies it to that category which has the largest probability.
A visual representation x of this learning is shown in Figure 4.1. There are two classes of
objects called C, and C, in the given figure.
When given a test instance T, the category of this test instance is determined by looking
at the class of k =3 nearest neighbors. thus, the class of this test instance k-Nearest
Neighbor Learning T is predicted as C,.
The k-Nearest Neighbor (k-NN) algorithm has some serious limitations as its performance
is solely dependent on choosing the k nearest neighbors, the distance metric used and the
decision rule. The idea is that weights are inversely proportional to distances.
The selected k nearest neighbors can be assigned uniform weights, which means all the
instances in each neighborhood are weighted equally or weights can be assigned by the
inverse of their distance.
Learning Objectives
INTRODUCTION TO REGRESSION
Regression analysis is the premier method of supervised learning. This is one of the most
popular and oldest supervised learning technique.
Given a training dataset D containing N training points (x, y,), where i = 1...N, regression
analysis is used to model the relationship between one or more independent variables x,
and a dependent variable y.
The relationship between the dependent and independent variables can be represented as a
function as follows: y=f(x)
Here, the feature variable x is also known as an explanatory variable, exploratory
variable, a predictor variable, an independent variable, a covariate, or a domain point. y is
a dependent variable. Dependent variables are also called as labels, target variables, or
response variables.
This is used to determine the relationship each of the exploratory variables exhibits. Thus,
regression analysis is used for prediction and forecasting.
Regression is used to predict continuous variables or quantitative variables such as price
and revenue. Thus, the primary concern of regression analysis is to find answer to
questions such as:
❖ Linear Regression It is a type of regression where a line is fitted upon given data for
finding the linear relationship between one independent variable and one dependent
variable to describe relationships.
❖ Multiple Regression It is a type of regression where a line.is fitted for finding the linear
relationship between two or more independent variables and one dependent variable to
describe relationships among variables.
❖ Polynomial Regression It is a type of non-linear regression method of describing
relationships among variables where N™ degree polynomial is used to model the
relationship between one independent variable and one dependent variable. Polynomial
multiple regression is used to model two or more independent variables and one
dependent variable.
❖ Logistic Regression-It is used for predicting categorical variables that involve one or
more independent variables and one dependent variable. This is also known as a binary
classifier.
❖ Lasso and Ridge Regression Methods These are special variants of regression method
where regularization methods are used to limit the number and size of coefficients of the
independent variables.
The idea of linear regression is based on Ordinary Least Square (OLS) approach. This
method is also known as ordinary least squares method. In this method, the data points
are modelled using a straight line.
The squares of the individual errors can also be computed and added to give a sum of
squared error. The line with the lowest sum of squared error is called line of best fit.
Standard Error
Residuals or error is the difference between the actual (y) and predicted value (7). If the
residuals have normal distribution, then the mean is zero and hence it is desirable. This is a
measure of variability in finding the coefficients.
Relative MSE
Coefficient of Variation
Coefficient of Determination
To understand the coefficient of determination, one needs to understand the total variation of
coefficients in regression analysis. The sum of the squares of the differences between the y-value of
the data pair and the average of y is called total variation. Thus, the following variations can be
defined.
Example: -
Let us consider the data given in the Table 5.3 with actual and predicted values. Find standard
error estimate.
Module 3
Topics: Basics of Learning theory, Similarity Based Learning, Regression Analysis
Textbook 2: Chapter 3 - 3.1 to 3.4, Chapter 4, chapter 5.1 to 5.4
Chapter 4
Similarity Based Learning
4.1 Similarity or Instance-based Learning
a) KNN
b) Variants of KNN
c) Locally weighted regression
d) Learning vector quantization
e) Self-organizing maps
f) RBF networks
In the above diagram 4.1, 2 classes of objects called C1 and C2. When given a test
instance T,the category of this test instance is determined by looking at the class ofk=3
nearest neighbors. Thus, the class of this test instance T ispredicted as C2.
Consider the student performance training, dataset of 8 data instances shown in Table 4.2
which describes the performance of individual students in a course and their CGPA
obtained in the previous semesters. The independent attributes are CGPA, Assessment and
Project. The target variable is ‘Result’ which is a discrete valued variable that takes two
values ‘Pass’ or ‘Fail. Based on the performance of a student, classify whether a student
will pass or fail in that course.
Where, г is called the bandwidth parameter and controls the rate at which wi reduces to
zero with distance from xi.
CHAPTER 5
REGRESSION ANALYSIS
5.1 Introduction to Regression
Regression analysis is a fundamental concept that consists of a set of machine learning
methods that predict a continuous outcome variable (y) based on the value of one or
multiple predictor variables (x). OR
Regression analysis is a statistical method to model the relationship between a
dependent (target) and independent (predictor) variables with one or more independent
variables.
Regression is a supervised learning technique which helps in finding the correlation
between variables.
It is mainly used for prediction, forecasting, time series modelling, and determining the
causal- effect relationship between variables.
Regression shows a line or curve that passes through all the datapoints on target-
predictor graph in such a way that the vertical distance between the datapoints and the
regression line is minimum." The distance between datapoints and line tells whether a
model has captured a strong relationship or not.
• Function of regression analysis is given by: Y=f(x)
Here, y is called dependent variable and x is called independent variable.
Applications of Regression Analysis
1) Sales of a goods or services
2) Value of bonds in portfolio management
3) Premium on insurance companies
4) Yield of crop in agriculture
5) Prices of real estate
5.2 INTRODUCTION TO LINEARITY, CORRELATION AND CAUSATION
A correlation is the statistical summary of the relationship between two sets of
variables. It is a core part of data exploratory analysis, and is a critical aspect of
numerous advanced machine learning techniques. Correlation between two variables
can be found using a scatter plot.
There are different types of correlation:
• Positive Correlation: Two variables are said to be positively correlated when their
values move in the same direction. For example, in the image below, as the value
for X increases, sodoes the value for Y at a constant rate.
• Negative Correlation: Finally, variables X and Y will be negatively correlated
when their values change in opposite directions, so here as the value for X increases,
the value for Y decreases at a constant rate.
• Neutral Correlation: No relationship in the change of variables X and Y. In this
case, the values are completely random and do not show any sign of correlation,
as shown in the following image:
Causation
Causation is about relationship between two variables as x causes y. This is called x
implies b.Regression is different from causation. Causation indicates that one event is
the result of the occurrence of the other event; i.e. there is a causal relationship between
the two events.
Linear and Non-Linear Relationships
• The relationship between input features (variables) and the output (target) variable is
fundamental. These concepts have significant implications for the choice of algorithms,
model complexity, and predictive performance.
• Linear relationship creates a straight line when plotted on a graph, a Non-Linear
relationship does not create a straight line but instead creates a curve.
• Example:
Linear-the relationship between the hours spent studying and the grades obtained in a
class.
Non-Linear- GPS Signal
• Linearity:
Linear Relationship: A linear relationship between variables means that a change in
one variable is associated with a proportional change in another variable.
Mathematically, it can be represented as y = a * x + b, where y is the output, x is the
input, and a and b are constants.
Linear Models: Goal is to find the best-fitting line (plane in higher dimensions) to the
data points. Linear models are interpretable and work well when the relationship
between variablesis close to being linear.
Limitations: Linear models may perform poorly when the relationship between
variables is non-linear. In such cases, they may underfit the data, meaning they are too
simple to capture the underlying patterns.
• Non-Linearity:
Non-Linear Relationship: A non-linear relationship implies that the change in one
variable isnot proportional to the change in another variable. Non-linear relationships
can take various forms, such as quadratic, exponential, logarithmic, or arbitrary shapes.
Non-Linear Models: Machine learning models like decision trees, random forests,
support vector machines with non-linear kernels, and neural networks can capture non-
linear relationships. These models are more flexible and can fit complex data patterns.
Benefits: Non-linear models can perform well when the underlying relationships in the
data are complex or when interactions between variables are non-linear. They have the
capacity to capture intricate patterns.
Types of Regression
Linear Regression:
Single Independent Variable: Linear regression, also known as simple linear
regression, is used when there is a single independent variable (predictor) and one
dependent variable (target).
Purpose: Linear regression is used to establish a linear relationship between two
variables and make predictions based on this relationship. It's suitable for simple
scenarios where there's onlyone predictor.
Multiple Regression:
Multiple Independent Variables: Multiple regression, as the name suggests, is used
when there are two or more independent variables (predictors) and one dependent
variable (target).
Purpose: Multiple regression allows you to model the relationship between the
dependent variable and multiple predictors simultaneously. It is used when there are
multiple factors that may influence the target variable, and you want to understand their
combined effect and makepredictions based on all these factors.
Polynomial Regression:
Polynomial regression is an extension of multiple regression used when the relationship
between the independent and dependent variables is non-linear.
Logistic Regression:
Logistic regression is used when the dependent variable is binary (0 or 1). It models the
probability of the dependent variable belonging to a particular class.
Lasso Regression (L1 Regularization):
Lasso regression is used for feature selection and regularization. It penalizes the
absolutevalues of the coefficients, which encourages sparsity in the model.
A linear regression model used for determining the value of the response variable, ŷ,
can berepresented as the following equation.
y = b0 + b1x1 + b2x2 + … + bnxn + e
where: y - is the dependent variable, b0 is the intercept, e isthe error term
b1, b2, …, bn are the coefficients of the independentvariables x1, x2, …, xn
The coefficients b1, b2, …, bn can also be called the coefficientsof determination. The
goal of the OLS method can be used to estimate the unknown parameters (b1, b2, …,
bn) by minimizingthe sum of squared residuals (RSS). The sum of squared residualsis
also termed the sum of squared error (SSE).
This method is also known as the least-squares method for regression or linear
regression.Mathematically the line of equations for points are:
y1=(a0+a1x1)+e1
y2=(a0+a1x2)+e2 ……. yn=(a0+a1xn)+en.
In general ei=yi - (a0+a1x1)
Coefficient of Determination