Machine Learning Concepts
Machine Learning Concepts
Machine Learning Concepts
TOPICS TO BE COVERED
Machine Learning?
Basic types of Machine Learning .
Machine Learning Models.
Regression vs. Classification
One supervised approach:
Linear Regression
Naïve Bayes Classifier
One unsupervised approach
Clustering approach: K Means
Overview of reinforcement approach
Splitting the Train Sample:
Training
Testing
Validation
Over fitting and Under fitting
MACHINE LEARNING
Machine Learning
Labeled Data algorithm
Training
Prediction
Learned
Labeled Data Prediction
model
BASIC TYPES OF MACHINE LEARNING
• Supervised:
Supervised learning with labeled data
– Example: email classification, image classification
– Example: regression for predicting real-valued outputs
• Unsupervised:
Unsupervised discover patterns in unlabeled data
– Example: cluster similar data points
• Reinforcement learning:
learning learn to act based on feedback/reward
– Example: learn to play Go
class A
class B
Regression Clustering
Classification
Supervised Learning
The basic idea behind regression is to find the best-fitting line (or
curve) that describes the relationship between the variables.
RECALL: COVARIANCE
∑ ( x − X )( y
i =1
i i −Y )
cov ( x , y ) =
n −1
INTERPRETING COVARIANCE
cov ariance( x, y )
r=
var x var y
CORRELATION
X X X
r = -1 r = -.6 r=0
Y
Y Y
X X X
r = +1 r = +.3 r=0
LINEAR CORRELATION
Y Y
X X
Y Y
X X
ASSUMPTIONS
Linear regression assumes that…
1. The relationship between X and Y is linear
2. Y is distributed normally at each value of X
3. The variance of Y at every value of X is the same (homogeneity
of variances)
4. The observations are independent
PREDICTION
If you know something about X, this knowledge
helps you predict something about Y.
Regression equation…
Expected value of y at a given level of x=
E ( y i / xi) = α + β xi
EXAMPLE: LEAST SQUARES REGRESSION
MODEL
NUMERICAL EXAMPLE
Example: Sam found how many hours of sunshine vs how
many ice creams were sold at the shop from Monday to Friday:
"x" "y"
Hours of Ice First: Let us find the best m (slope) and b (y-intercept) that
Sunshin Creams suits that data y = mx + b
e Sold
2 4 Sum x, y, x2 and xy (gives us Σx, Σy, Σx2 and Σxy):
3 5
5 7
7 10
9 15
12 ?????
As Prediction Model
For the Timing i.e. Hour 12:
Y = 1.518*12 + 0.305
Y = 18.521 (approx)
As Classification Model
AS CLASSIFICATION MODEL
It works by making the total of the square of
the errors as small as possible (that is why
it is called "least squares").
3 No Single 70K No ij
1 −
( 120−110 ) 2
Inter-cluster
Intra-cluster distances are
distances are maximized
minimized
NOTION OF A CLUSTER CAN BE AMBIGUOUS
Steps:
1. Find the distance between data with the centers C1, C2 and C3.
2. Assign the data point to nearest cluster using the minimum distance value.
3. Repeat this step for all data points.
4. Update the centers by taking average of data points present in each cluster.
5. Repeat this step for “N” number of iterations or till convergence.
UPDATE THE CENTER
Updated Centers
Agent
Reward
Action
State
Environment
SETUP FOR REINFORCEMENT LEARNING
MARKOV DECISION PROCESS POLICY
(ENVIRONMENT) (AGENT’S BEHAVIOR)
Score: 100
0
0, 0 1, 0 2, 0
100
0, 1 1, 1 2, 1
0, 2 1, 2 2, 2
POLICIES
Policy Evaluating Policies
0, 0 1, 0 2, 0
12.5 100
0, 1 1, 1 2, 1
50
0, 2 1, 2 2, 2
Policy could be
better
SPLITTING THE DATASET
Training Dataset:
The training dataset is the portion of the data used to train the model. It consists of
input-output pairs where the input is the data used to make predictions, and the
output is the corresponding target or label.
Testing Dataset:
The testing dataset is a separate portion of the data that is held out from the training
process. It is used to evaluate the performance of the trained model.
Validation Dataset:
The validation dataset is another independent portion of the data used during the
model development process.
Complete Dataset
Training/Development Phase
Testing Phase
Training Set
Testing Set
Validation Set
OVER FITTING AND UNDER FITTING
Overfitting:
It occurs when a model learns to fit the training data too closely, capturing
noise or random fluctuations in the data rather than the underlying pattern.
As a result, an overfitted model performs well on the training data but fails
to generalize to new, unseen data.
Underfitting:
IT happens when a model is too simple to capture the underlying structure
of the data.
It fails to capture the patterns in the training data and also performs poorly
on new data.
BIAS AND VARIANCE VS. OVERFITTING AND
UNDERFITTING
Bias:
It is the error caused because the model can not represent the concept.
Bias measures how much the average prediction of the model differs from
the true value it's trying to predict.
The difference between the training observations and the best fit line
is the Training Error. The Training Error is also called Bias.
Variance:
It is the error caused because the learning algorithm overreacts to small
changes (noise) in the training data
The difference between the testing observations and the best fit line is
the Testing Error. The Testing Error is also called a Variance.
OVERFITTING UNDERFITTING