BE02000041 Funda of AI Unit 3 Basics of ML
BE02000041 Funda of AI Unit 3 Basics of ML
(BE02000041)
Unit – 3
Basics of Machine Learning
• All the insights and patterns derived during Data Exploration are
used to build the Machine Learning Model.
• This stage always begins by splitting the data set into two parts,
training data, and testing data.
• The training data will be used to build and analyze the model.
The logic of the model is based on the Machine Learning
Algorithm that is being implemented.
• In the case of predicting rainfall, since the output will be in the
form of True (if it will rain tomorrow) or False (no rain
tomorrow), we can use a Classification Algorithm such as Logistic
Regression.
• Choosing the right algorithm depends on the type of problem
you’re trying to solve, the data set and the level of complexity of
the problem.
Machine Learning Life Cycle
Step 7: Predictions
• Once the model is evaluated and improved, it is finally used
to make predictions.
• The final output can be a Categorical variable (eg. True or
False) or it can be a Continuous Quantity (eg. the predicted
value of a stock).
• In our case, for predicting the occurrence of rainfall, the
output will be a categorical variable.
Types of Machine Learning
• Logistic Regression
• K-Nearest Neighbors
• Support Vector Machines
• Kernel SVM
• Naïve Bayes
• Decision Tree Classification
• Random Forest Classification
Difference
Regression Algorithm Classification Algorithm
In Regression, the output In Classification, the output
variable must be of variable must be a discrete
continuous nature or real value.
value.
Yi 0 1 X i i
where
y = dependent variable
x = independent variable
b0= y-intercept
b1= slope of the line
e = error variable
Simple Linear Model
Yi 0 1Xi i
This model is
– Simple: only one X
– Linear in the parameters: No parameter appears
as exponent or is multiplied or divided by another
parameter
– Linear in the predictor variable (X): X appears
only in the first power.
60
Examples
• Multiple Linear Regression:
Yi 0 1X1i 2X 2i i
• Polynomial Linear Regression:
Yi 0 1Xi 2 X 2i i
• Linear Regression:
log 10 (Yi ) 0 1Xi 2 exp( Xi ) i
• Nonlinear Regression:
Yi 0 /(1 1 exp( 2Xi )) i
Linear or nonlinear in parameters 61
Deterministic Component of Model
50 y ˆ0 ˆ1x
45
40
y-intercept 3530 ∆y
ˆ1 (slope)=∆y/∆x
25
∆x
ˆ020
15
10
5
0 x
0 5 10 15 20
Mathematical vs Statistical Relation
50 ^
45 y = - 5.3562 + 3.3988x
40
35
30
25
20
15
10
5
0 x
x
0 5 10 15 20
Error
• Yi = β0 + β1Xi + ei
• Ŷi = b0 + b1Xi
– b0 is the estimated intercept
– b1 is the estimated slope
• ei : residual for ith case
• ei = Yi – Ŷi = Yi – (b0 + b1Xi)
e82=Y82-Ŷ82
Ŷ82=b0 + b182
X=82
e82
Least Squares Solution
b1
(X X )(Y Y )
i i
(X X )
i
2
b 0 Y b1 X
n n
Minimize i2 ( yi 0 i xi )2
i 1 i 1
• Representation:
Lecture Notes for E Alpaydın
2004 Introduction to Machine
74
Learning © The MIT Press
What is support vector?
Support Vectors
• Support vectors are the data points, which are
closest to the hyperplane. These points will
define the separating line better by calculating
margins.
• These points are more relevant to the
construction of the classifier.
Hyperplane
• A hyperplane is a decision plane which separates
between a set of objects having different class
memberships.
Definitions
• Margin
– A margin is a gap between the two lines on the
closest class points.
– This is calculated as the perpendicular distance
from the line to support vectors or closest
points.
– If the margin is larger in between the classes,
then it is considered a good margin, a smaller
margin is a bad margin.
How SVM works ?