1.59k likes | 3.81k Views
** Machine Learning Training with Python: https://www.edureka.co/python ** <br>This Linear Regression Algorithm tutorial is designed in a way that you learn about the algorithm in depth. This tutorial is designed in a way that in the first part you will learn about the algorithm from scratch with its mathematical implementation, then you will drill down to the coding part and implement linear regression using python. Below are the topics covered in this tutorial: <br><br>1. What is Regression? <br>2. Regression Use-case <br>3. Types of Regression u2013 Linear vs Logistic Regression <br>4. What is Linear Regression? <br>5. Finding best-fit regression line using Least Square Method <br>6. Checking goodness of fit using R squared Method <br>7. Implementation of Linear Regression Algorithm using Python (from scratch) <br>8. Implementation of Linear Regression Algorithm using Python (scikit lib) <br>Check out our playlist for more videos: http://bit.ly/2taym8X
E N D
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Linear Regression Algorithm Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Agenda for Today’s Session ▪ What is Regression? ▪ Regression Use-case ▪ Types of Regression – Linear vs Logistic Regression ▪ What is Linear Regression? ▪ Finding best fit regression line using Least Square Method ▪ Checking goodness of fit using R squared Method ▪ Implementation of Linear Regression using Python ▪ Linear Regression Algorithm using Python from scratch ▪ Linear Regression Algorithm using Python (scikit lib) Copyright © 2017, edureka and/or its affiliates. All rights reserved.
“Regression analysis is a form of predictive modelling technique which investigates the relationship between What is Regression? a dependent and independent variable”
Three major uses for regression analysis are ▪ Determining the strength of predictors Uses of Regression ▪ Forecasting an effect, and ▪ Trend forecasting
Basis Linear Regression Logistic Regression Core Concept The data is modelled The probability of some Linear vs Logistic Regression using a straight line obtained event is represented as a linear function of a combination of predictor variables. Used with Continuous Variable Categorical Variable Output/Prediction Value of the variable Probability of occurrence of event Accuracy and measured by loss, R Accuracy, Precision, Recall, Goodness of fit squared, Adjusted R F1 score, ROC curve, squared etc. Confusion Matrix, etc
“Linear Regression is a method to predict dependent variable (Y) based on values of independent variables (X). It can be used for the What isLinear Regression? cases where we want to predict some continuous quantity.”
Linear Regression Selection Criteria ▪ Classification and Regression Capabilities ▪ Data Quality ▪ Computational Complexity ▪ Comprehensible and Transparent
Where is Linear Regression used? ▪ Evaluating Trends and Sales Estimates ▪ Analyzing the Impact of Price Changes ▪ Assessment of risk in financial services and insurance domain
Y Understanding Linear Regression Algorithm Line Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm +ve Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Dependent Variable -ve X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Line Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Linear Regression Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Dependent Variable Observation X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Regression Line Least Square Method Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm error Estimated Value Dependent Variable error Actual Value X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Dependent Variable Minimize the error X Independent Variable Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm +ve Relationship Distance X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm y = mx + c Distance Distance travelled in a fixed duration of time X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Speed of Vehicle y = mx + c Distance X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm y = mx + c Distance m = +ve slope of line X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm y = mx + c Distance c = y - intercept of the line X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Time -ve Relationship X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm y = - mx + c Time Time taken to travel a fixed distance X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Speed of Vehicle y = - mx + c Time X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm y = - mx + c Time m = -ve slope of line X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm c = y - intercept of the line y = - mx + c Time X Speed Machine Learning Training with Python www.edureka.co/python
Y Understanding Linear Regression Algorithm Independent Variable Dependent Variable y = mx + c Dependent Variable X Independent Variable Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 3 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 3 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 3 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 mean : ഥ ? mean: ഥ ? 3 18/5 3.6 3 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 ( , ) 3 3.6 3 mean 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 3 4 2 4 Y Dependent Variable 5 4 5 5 ( , ) 3.6 3 3 mean 2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 y = mx+c 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 m =? (? − ҧ ?)(? − ത ?) ? ? − ҧ ?2 1 X 0 1 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 1 1 0 2 3 4 5 6 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? 1 − 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? 1 − 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? 1 −3 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 2 2 0 1 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 2 − 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 2 − 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 2 −3 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 -1 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 -1 0 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 -1 0 1 3 4 2 4 Y Dependent Variable 5 4 5 5 3 3.6 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? 1 2 3 4 ? − ҧ ? -2 -1 0 1 y = mx+c 3 4 2 4 Y Dependent Variable 5 4 2 5 5 3 3.6 3 mean m =? 2 (? − ҧ ?)(? − ത ?) ? ? − ҧ ?2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm ? ? − ത ? ? 1 2 3 4 ? − ҧ ? -2 -1 0 1 3 4 2 4 Y Dependent Variable 5 4 2 5 5 3 3.6 3 3 mean 2 1 X 0 1 2 4 5 6 3 3 Independent Variable Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning Training with Python www.edureka.co/python