SlideShare a Scribd company logo
1 of 25
D R . S . S H A J U N N I S H A , M C A . , M . P H I L . , M . T E C H . , M B A . , P H . D . ,
A S S I S T A N T P R O F E S S O R & H E A D ,
P G & R E S E A R C H D E P T . O F C O M P U T E R S C I E N C E
S A D A K A T H U L L A H A P P A C O L L E G E ( A U T O N O M O U S ) ,
T I R U N E L V E L I .
S H A J U N N I S H A _ S @ Y A H O O . C O M
+ 9 1 9 9 4 2 0 9 6 2 2 0
MACHINE LEARNING
LINEAR REGRESSION
Agenda
2
• Single Dimension Linear Regression
• Multi Dimension Linear Regression
• Gradient Descent
• Categorical Inputs
What is Linear Regression?
3
• Learning
• A supervised algorithm that learns from a set of training samples.
• Each training sample has one or more input values and a single output
value.
• The algorithm learns the line, plane or hyper-plane that best fits the
training samples.
• Prediction
• Use the learned line, plane or hyper-plane to predict the output value for
any input sample.
Single Dimension Linear
Regression
4
Single Dimension Linear Regression
5
• Single dimension linear regression
has pairs of x and y values as input
training samples.
• It uses these training sample to derive a
line that predicts values of y.
• The training samples are used to
derive the values of a and b that
minimise the error between actual
and predicated values of y.
Single Dimension Linear Regression
6
• We want a line that minimises
the error between the Y values
in training samples and the Y
values that the line passes
through.
• Or put another way, we want
the line that “best fits’ the
training samples.
• So we define the error function
for our algorithm so we can
minimise that error.
Single Dimension Linear Regression
7
• To determine the value of a that
minimises the error E, we look
for where the partial differential
of E with respect to a is zero.
Single Dimension Linear Regression
8
• To determine the value of b that
minimises the error E, we look
for where the partial differential
of E with respect to b iszero.
Single Dimension Linear Regression
9
• By substituting the final
equations from the previous two
slides we derive equations for a
and b that minimise the error
Single Dimension Linear Regression
10
• We also define a function which we
can use to score how well derived
line fits.
• A value of 1 indicates a perfect fit.
• A value of 0 indicates a fit that is no
better than simply predicting the
mean of the input y values.
• A negative value indicates a fit that
is even worse than just predicting
the mean of the input y values.
Multi Dimension
Linear Regression
11
Multi Dimension Linear Regression
12
• Each training sample has an x made
up of multiple input values and a
corresponding y with a single
value.
• The inputs can be represented as
an X matrix in which each row
is sample and each column is a
dimension.
• The outputs can be represented as
y matrix in which each row is a
sample.
Multi Dimension Linear Regression
13
• Our predicated y values are
calculated by multiple the X
matrix by a matrix of weights, w.
• If there are 2 dimension, then this
equation defines plane. If there
are more dimensions then it
defines a hyper-plane.
Multi Dimension Linear Regression
14
• We want a plane or hyper-plane
that minimises the error between
the y values in training samples
and the y values that the plane or
hyper-plane passes through.
• Or put another way, we want
the plane/hyper-plane that
“best fits’ the training samples.
• So we define the error function
for our algorithm so we can
minimise that error.
Multi Dimension Linear Regression
15
• To determine the value of w that
minimises the error E, we look
for where the differential of E
with respect to w is zero.
• We use the Matrix Cookbook
to help with the
differentiation!
Multi Dimension Linear Regression
16
• We also define a function which we
can use to score how well derived
line fits.
• A value of 1 indicates a perfect fit.
• A value of 0 indicates a fit that is no
better than simply predicting the
mean of the input y values.
• A negative value indicates a fit that
is even worse than just predicting
the mean of the input y values.
Multi Dimension Linear Regression
17
• In addition to using the X matrix to represent basic features our training data,
we can can also introduce additional dimensions (i.e. columns in our X
matrix) that are derived from those basic feature values.
• If we introduce derived features whose values are powers of basic
features, our multi-dimensional linear regression can then derive
polynomial curves, planes and hyper-planes.
Multi Dimension Linear Regression
18
• For example, if we have just one
basic feature in each sample of X,
we can include a range of powers
of that value into our X matrix like
this:
• In non-matrix form our
multi- dimensional linear
equation is:
• Inserting the powers of the basic
feature that we have introduced
this becomes a polynomial.
Gradient Descent
19
• Gradient descent is a technique we can use to find the minimum of
arbitrarily complex error functions.
• In gradient descent we pick a random set of weights for our algorithm and
iteratively adjust those weights in the direction of the gradient of the error
with respect to each weight.
• As we iterate, the gradient approaches zero and we approach the
minimum error.
• In machine learning we often use gradient descent with our error function
to find the weights that give the lowest errors.
Gradient Descent
20
• Here is an example with a very simple
function:
• The gradient of this function is given by:
• We choose an random initial value for x and a
learning rate of
0.1 and then start descent.
• On each iteration our x value is decreasing
and the gradient (2x) is converging towards 0.
Gradient Descent
21
• The learning rate is a what is know as a hyper-parameter.
• If the learning rate is too small then convergence may take a very long
time.
• If the learning rate is too large then convergence may never happen because
our iterations bounce from one side of the minima to the other.
• Choosing a suitable value for hyper-parameters is an art so try different
values and plot the results until you find suitable values.
Multi Dimension Linear Regression with
Gradient Descent
22
• For multi dimension linear
regression our error function is:
• Differentiating this with respect to
the weights vector gives:
• We can iteratively reduce the error by
adjusting the weights in the direction
of these gradients.
Categorical
Inputs
23
One-hot Encoding
24
• When some inputs are categories (e.g. gender) rather than numbers (e.g. age) we
need to represent the category values as numbers so they can be used in our
linear regression equations.
• In one-hot encoding we allocate each category value it's own dimension in the
inputs. So, for example, we allocate X1 to Audi, X2 to BMW & X3 to Mercedes.
• For Audi X = [1,0,0]
• For BMW X = [0,1,0])
• For Mercedes X = [0,0,1]
25

More Related Content

What's hot

Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...Edureka!
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine LearningKuppusamy P
 
Linear regression with gradient descent
Linear regression with gradient descentLinear regression with gradient descent
Linear regression with gradient descentSuraj Parmar
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine Learningbutest
 
Unsupervised learning
Unsupervised learningUnsupervised learning
Unsupervised learningamalalhait
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Simplilearn
 
Perception in artificial intelligence
Perception in artificial intelligencePerception in artificial intelligence
Perception in artificial intelligenceMinakshi Atre
 
Support Vector Machines
Support Vector MachinesSupport Vector Machines
Support Vector Machinesnextlib
 
Support vector machine
Support vector machineSupport vector machine
Support vector machineRishabh Gupta
 
Types of Machine Learning
Types of Machine LearningTypes of Machine Learning
Types of Machine LearningSamra Shahzadi
 
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...Edureka!
 
Linear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaLinear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaEdureka!
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Simplilearn
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision treesKnoldus Inc.
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningLior Rokach
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...Sebastian Raschka
 
Machine Learning Course | Edureka
Machine Learning Course | EdurekaMachine Learning Course | Edureka
Machine Learning Course | EdurekaEdureka!
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine LearningKnoldus Inc.
 

What's hot (20)

Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
 
supervised learning
supervised learningsupervised learning
supervised learning
 
Linear regression with gradient descent
Linear regression with gradient descentLinear regression with gradient descent
Linear regression with gradient descent
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine Learning
 
Unsupervised learning
Unsupervised learningUnsupervised learning
Unsupervised learning
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
 
Perception in artificial intelligence
Perception in artificial intelligencePerception in artificial intelligence
Perception in artificial intelligence
 
Support Vector Machines
Support Vector MachinesSupport Vector Machines
Support Vector Machines
 
Support vector machine
Support vector machineSupport vector machine
Support vector machine
 
Types of Machine Learning
Types of Machine LearningTypes of Machine Learning
Types of Machine Learning
 
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...
Scikit Learn Tutorial | Machine Learning with Python | Python for Data Scienc...
 
Linear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaLinear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | Edureka
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
 
Regularization
RegularizationRegularization
Regularization
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision trees
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
 
Machine Learning Course | Edureka
Machine Learning Course | EdurekaMachine Learning Course | Edureka
Machine Learning Course | Edureka
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine Learning
 

Similar to Linear regression in machine learning

07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descentSubhas Kumar Ghosh
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptxarsh260174
 
Regression Analysis Techniques.pptx
Regression Analysis Techniques.pptxRegression Analysis Techniques.pptx
Regression Analysis Techniques.pptxYutaItadori
 
Lecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxLecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxajondaree
 
Model Selection and Validation
Model Selection and ValidationModel Selection and Validation
Model Selection and Validationgmorishita
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.pptRufesh
 
REGRESSION METasdfghjklmjhgftrHODS1.pptx
REGRESSION METasdfghjklmjhgftrHODS1.pptxREGRESSION METasdfghjklmjhgftrHODS1.pptx
REGRESSION METasdfghjklmjhgftrHODS1.pptxcajativ595
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionMartinHogg9
 
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?Smarten Augmented Analytics
 
WEKA:Credibility Evaluating Whats Been Learned
WEKA:Credibility Evaluating Whats Been LearnedWEKA:Credibility Evaluating Whats Been Learned
WEKA:Credibility Evaluating Whats Been Learnedweka Content
 
WEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedWEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedDataminingTools Inc
 
Unit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptxUnit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptxsmithashetty24
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptxHadrian7
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdfAmir Saleh
 
Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptxhiblooms
 

Similar to Linear regression in machine learning (20)

working with python
working with pythonworking with python
working with python
 
07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
 
Regression Analysis Techniques.pptx
Regression Analysis Techniques.pptxRegression Analysis Techniques.pptx
Regression Analysis Techniques.pptx
 
Lecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptxLecture 3.1_ Logistic Regression.pptx
Lecture 3.1_ Logistic Regression.pptx
 
2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data 2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data
 
Model Selection and Validation
Model Selection and ValidationModel Selection and Validation
Model Selection and Validation
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.ppt
 
REGRESSION METasdfghjklmjhgftrHODS1.pptx
REGRESSION METasdfghjklmjhgftrHODS1.pptxREGRESSION METasdfghjklmjhgftrHODS1.pptx
REGRESSION METasdfghjklmjhgftrHODS1.pptx
 
Regression ppt
Regression pptRegression ppt
Regression ppt
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Machine learning
Machine learningMachine learning
Machine learning
 
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?
What is Isotonic Regression and How Can a Business Utilize it to Analyze Data?
 
3ml.pdf
3ml.pdf3ml.pdf
3ml.pdf
 
WEKA:Credibility Evaluating Whats Been Learned
WEKA:Credibility Evaluating Whats Been LearnedWEKA:Credibility Evaluating Whats Been Learned
WEKA:Credibility Evaluating Whats Been Learned
 
WEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedWEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been Learned
 
Unit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptxUnit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptx
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptx
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdf
 
Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptx
 

More from Shajun Nisha

Google meet and its extensions sac
Google meet and its extensions sacGoogle meet and its extensions sac
Google meet and its extensions sacShajun Nisha
 
Dip fundamentals 2
Dip fundamentals 2Dip fundamentals 2
Dip fundamentals 2Shajun Nisha
 
Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3Shajun Nisha
 
25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rights25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rightsShajun Nisha
 
Basics of research in research methodology
Basics of research in research methodologyBasics of research in research methodology
Basics of research in research methodologyShajun Nisha
 
Auto encoders in Deep Learning
Auto encoders in Deep LearningAuto encoders in Deep Learning
Auto encoders in Deep LearningShajun Nisha
 
Teaching Aptitude in Research Methodology
Teaching Aptitude in Research MethodologyTeaching Aptitude in Research Methodology
Teaching Aptitude in Research MethodologyShajun Nisha
 
Perceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsPerceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsShajun Nisha
 
Mc Culloch Pitts Neuron
Mc Culloch Pitts NeuronMc Culloch Pitts Neuron
Mc Culloch Pitts NeuronShajun Nisha
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringShajun Nisha
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Shajun Nisha
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)Shajun Nisha
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab workShajun Nisha
 
introduction to cloud computing
 introduction to cloud computing introduction to cloud computing
introduction to cloud computingShajun Nisha
 
online learning NPTEL
online learning NPTELonline learning NPTEL
online learning NPTELShajun Nisha
 

More from Shajun Nisha (18)

Google meet and its extensions sac
Google meet and its extensions sacGoogle meet and its extensions sac
Google meet and its extensions sac
 
Dip syntax 4
Dip syntax 4Dip syntax 4
Dip syntax 4
 
Dip fundamentals 2
Dip fundamentals 2Dip fundamentals 2
Dip fundamentals 2
 
Dip application 1
Dip application 1Dip application 1
Dip application 1
 
Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3
 
ICT tools
ICT  toolsICT  tools
ICT tools
 
25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rights25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rights
 
Basics of research in research methodology
Basics of research in research methodologyBasics of research in research methodology
Basics of research in research methodology
 
Auto encoders in Deep Learning
Auto encoders in Deep LearningAuto encoders in Deep Learning
Auto encoders in Deep Learning
 
Teaching Aptitude in Research Methodology
Teaching Aptitude in Research MethodologyTeaching Aptitude in Research Methodology
Teaching Aptitude in Research Methodology
 
Perceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsPerceptron and Sigmoid Neurons
Perceptron and Sigmoid Neurons
 
Mc Culloch Pitts Neuron
Mc Culloch Pitts NeuronMc Culloch Pitts Neuron
Mc Culloch Pitts Neuron
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filtering
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab work
 
introduction to cloud computing
 introduction to cloud computing introduction to cloud computing
introduction to cloud computing
 
online learning NPTEL
online learning NPTELonline learning NPTEL
online learning NPTEL
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 

Linear regression in machine learning

  • 1. D R . S . S H A J U N N I S H A , M C A . , M . P H I L . , M . T E C H . , M B A . , P H . D . , A S S I S T A N T P R O F E S S O R & H E A D , P G & R E S E A R C H D E P T . O F C O M P U T E R S C I E N C E S A D A K A T H U L L A H A P P A C O L L E G E ( A U T O N O M O U S ) , T I R U N E L V E L I . S H A J U N N I S H A _ S @ Y A H O O . C O M + 9 1 9 9 4 2 0 9 6 2 2 0 MACHINE LEARNING LINEAR REGRESSION
  • 2. Agenda 2 • Single Dimension Linear Regression • Multi Dimension Linear Regression • Gradient Descent • Categorical Inputs
  • 3. What is Linear Regression? 3 • Learning • A supervised algorithm that learns from a set of training samples. • Each training sample has one or more input values and a single output value. • The algorithm learns the line, plane or hyper-plane that best fits the training samples. • Prediction • Use the learned line, plane or hyper-plane to predict the output value for any input sample.
  • 5. Single Dimension Linear Regression 5 • Single dimension linear regression has pairs of x and y values as input training samples. • It uses these training sample to derive a line that predicts values of y. • The training samples are used to derive the values of a and b that minimise the error between actual and predicated values of y.
  • 6. Single Dimension Linear Regression 6 • We want a line that minimises the error between the Y values in training samples and the Y values that the line passes through. • Or put another way, we want the line that “best fits’ the training samples. • So we define the error function for our algorithm so we can minimise that error.
  • 7. Single Dimension Linear Regression 7 • To determine the value of a that minimises the error E, we look for where the partial differential of E with respect to a is zero.
  • 8. Single Dimension Linear Regression 8 • To determine the value of b that minimises the error E, we look for where the partial differential of E with respect to b iszero.
  • 9. Single Dimension Linear Regression 9 • By substituting the final equations from the previous two slides we derive equations for a and b that minimise the error
  • 10. Single Dimension Linear Regression 10 • We also define a function which we can use to score how well derived line fits. • A value of 1 indicates a perfect fit. • A value of 0 indicates a fit that is no better than simply predicting the mean of the input y values. • A negative value indicates a fit that is even worse than just predicting the mean of the input y values.
  • 12. Multi Dimension Linear Regression 12 • Each training sample has an x made up of multiple input values and a corresponding y with a single value. • The inputs can be represented as an X matrix in which each row is sample and each column is a dimension. • The outputs can be represented as y matrix in which each row is a sample.
  • 13. Multi Dimension Linear Regression 13 • Our predicated y values are calculated by multiple the X matrix by a matrix of weights, w. • If there are 2 dimension, then this equation defines plane. If there are more dimensions then it defines a hyper-plane.
  • 14. Multi Dimension Linear Regression 14 • We want a plane or hyper-plane that minimises the error between the y values in training samples and the y values that the plane or hyper-plane passes through. • Or put another way, we want the plane/hyper-plane that “best fits’ the training samples. • So we define the error function for our algorithm so we can minimise that error.
  • 15. Multi Dimension Linear Regression 15 • To determine the value of w that minimises the error E, we look for where the differential of E with respect to w is zero. • We use the Matrix Cookbook to help with the differentiation!
  • 16. Multi Dimension Linear Regression 16 • We also define a function which we can use to score how well derived line fits. • A value of 1 indicates a perfect fit. • A value of 0 indicates a fit that is no better than simply predicting the mean of the input y values. • A negative value indicates a fit that is even worse than just predicting the mean of the input y values.
  • 17. Multi Dimension Linear Regression 17 • In addition to using the X matrix to represent basic features our training data, we can can also introduce additional dimensions (i.e. columns in our X matrix) that are derived from those basic feature values. • If we introduce derived features whose values are powers of basic features, our multi-dimensional linear regression can then derive polynomial curves, planes and hyper-planes.
  • 18. Multi Dimension Linear Regression 18 • For example, if we have just one basic feature in each sample of X, we can include a range of powers of that value into our X matrix like this: • In non-matrix form our multi- dimensional linear equation is: • Inserting the powers of the basic feature that we have introduced this becomes a polynomial.
  • 19. Gradient Descent 19 • Gradient descent is a technique we can use to find the minimum of arbitrarily complex error functions. • In gradient descent we pick a random set of weights for our algorithm and iteratively adjust those weights in the direction of the gradient of the error with respect to each weight. • As we iterate, the gradient approaches zero and we approach the minimum error. • In machine learning we often use gradient descent with our error function to find the weights that give the lowest errors.
  • 20. Gradient Descent 20 • Here is an example with a very simple function: • The gradient of this function is given by: • We choose an random initial value for x and a learning rate of 0.1 and then start descent. • On each iteration our x value is decreasing and the gradient (2x) is converging towards 0.
  • 21. Gradient Descent 21 • The learning rate is a what is know as a hyper-parameter. • If the learning rate is too small then convergence may take a very long time. • If the learning rate is too large then convergence may never happen because our iterations bounce from one side of the minima to the other. • Choosing a suitable value for hyper-parameters is an art so try different values and plot the results until you find suitable values.
  • 22. Multi Dimension Linear Regression with Gradient Descent 22 • For multi dimension linear regression our error function is: • Differentiating this with respect to the weights vector gives: • We can iteratively reduce the error by adjusting the weights in the direction of these gradients.
  • 24. One-hot Encoding 24 • When some inputs are categories (e.g. gender) rather than numbers (e.g. age) we need to represent the category values as numbers so they can be used in our linear regression equations. • In one-hot encoding we allocate each category value it's own dimension in the inputs. So, for example, we allocate X1 to Audi, X2 to BMW & X3 to Mercedes. • For Audi X = [1,0,0] • For BMW X = [0,1,0]) • For Mercedes X = [0,0,1]
  • 25. 25