Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. โ–ช 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) Agenda for Todayโ€™s Session
โ€œRegression analysis is a form of predictive modelling technique which investigates the relationship between a dependent and independent variableโ€What is Regression?
Uses of Regression Three major uses for regression analysis are โ–ช Determining the strength of predictors โ–ช Forecasting an effect, and โ–ช Trend forecasting
Linear vs Logistic Regression Basis Linear Regression Logistic Regression Core Concept The data is modelled using a straight line The probability of some 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 Goodness of fit measured by loss, R squared, Adjusted R squared etc. Accuracy, Precision, Recall, F1 score, ROC curve, 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 cases where we want to predict some continuous quantity.โ€ What is Linear Regression?
โ–ช Classification and Regression Capabilities โ–ช Data Quality โ–ช Computational Complexity โ–ช Comprehensible and Transparent Linear Regression Selection Criteria
โ–ช Evaluating Trends and Sales Estimates โ–ช Analyzing the Impact of Price Changes โ–ช Assessment of risk in financial services and insurance domain Where is Linear Regression used?
Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Line Understanding Linear Regression Algorithm
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python +ve
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python -ve
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Line
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Linear Regression
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Observation
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Regression Line Least Square Method
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Estimated Value Actual Value error error
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Minimize the error
Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python +ve Relationship
Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Distance travelled in a fixed duration of time
Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Speed of Vehicle
Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c m = +ve slope of line
Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c c = y - intercept of the line
Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python -ve Relationship
Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c Time taken to travel a fixed distance
Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c Speed of Vehicle
Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c m = -ve slope of line
Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c c = y - intercept of the line
Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Independent Variable Dependent Variable
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean: เดฅ๐’™ 3 18/53.6 mean : เดฅ๐’š Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6( , ) Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean3( , )3.6 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’ 3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ 3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ 3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3.6 3 โˆ’ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3.6 3 โˆ’ Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3 โˆ’3.6 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.4 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.4 1.4 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 -2y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 where m = ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 -1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 2 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+cy = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -2 -1 0 1 2 -0.6 0.4 -1.6 0.4 1.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ)๐‘ฅ โˆ’ าง๐‘ฅ 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 3.6 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 0.4 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6=0.4x3 + c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6 = 1.2+ c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6 - 1.2 = c Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 c = 2.4 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 c = 2.4 m = 0.4 c = 2.4 y = 0.4x + 2.4 Understanding Linear Regression Algorithm
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line Distance between actual & predicted value error error error error
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Finding the best fit line Machine Learning Training with Python www.edureka.co/python
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Letโ€™s check the Goodness of fit
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. What is R- Square? Machine Learning Training with Python www.edureka.co/python โ–ช R-squared value is a statistical measure of how close the data are to the fitted regression line โ–ช It is also known as coefficient of determination, or the coefficient of multiple determination
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ 1 2 4 5 60 3 1 2 3 4 5 Actual Value 1 2 3 4 5 3 4 2 4 5 ๐‘ฅ ๐‘ฆ mean
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Actual Value mean distance = actual - mean Calculation of ๐‘น ๐Ÿ
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Predicted Value 1 2 3 4 5 2.8 ๐‘ฅ 3.2 4.0 3.6 4.4 Regression line Calculation of ๐‘น ๐Ÿ ๐‘ฆ๐‘
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Distance actual - mean Distance predicted - mean 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value Regression line vs This is nothing but ๐‘…2 = Calculation of ๐‘น ๐Ÿ ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 6.4 1.6 0 1.6 6.4 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 0.36 0.16 2.56 0.16 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 0.64 0.16 0 0.16 0.64 1.6 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 (๐‘ฆ๐‘ โˆ’เดค๐‘ฆ 2 ๐›ด ๐›ด 5.2๐›ด ๐›ด 1.6 5.2 = ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 (๐‘ฆ๐‘ โˆ’โˆ’เดค๐‘ฆ 2 6.4 1.6 0 1.6 6.4 11.32 16 ๐‘…2 โ‰ˆ 0.3
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.3 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.7 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.9 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 1 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.02 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Are Low R-squared values always Machine Learning Training with Python www.edureka.co/python
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. Are High R-squared values always Machine Learning Training with Python www.edureka.co/python
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved. DEMO Letโ€™s learn to code ยฉ MadeByShape Ltd. Web Design Manchester 2018. All Rights Reserved.
Copyright ยฉ 2017, edureka and/or its affiliates. All rights reserved.

Linear Regression Algorithm | Linear Regression in Python | Machine Learning Algorithm | Edureka

  • 1.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.
  • 2.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Linear Regression Algorithm
  • 3.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. โ–ช 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) Agenda for Todayโ€™s Session
  • 4.
    โ€œRegression analysis isa form of predictive modelling technique which investigates the relationship between a dependent and independent variableโ€What is Regression?
  • 5.
    Uses of Regression Three majoruses for regression analysis are โ–ช Determining the strength of predictors โ–ช Forecasting an effect, and โ–ช Trend forecasting
  • 6.
    Linear vs Logistic Regression Basis LinearRegression Logistic Regression Core Concept The data is modelled using a straight line The probability of some 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 Goodness of fit measured by loss, R squared, Adjusted R squared etc. Accuracy, Precision, Recall, F1 score, ROC curve, Confusion Matrix, etc
  • 7.
    โ€œLinear Regression isa method to predict dependent variable (Y) based on values of independent variables (X). It can be used for the cases where we want to predict some continuous quantity.โ€ What is Linear Regression?
  • 8.
    โ–ช Classification andRegression Capabilities โ–ช Data Quality โ–ช Computational Complexity โ–ช Comprehensible and Transparent Linear Regression Selection Criteria
  • 9.
    โ–ช Evaluating Trendsand Sales Estimates โ–ช Analyzing the Impact of Price Changes โ–ช Assessment of risk in financial services and insurance domain Where is Linear Regression used?
  • 10.
    Independent Variable DependentVariable X Y Machine LearningTraining with Python www.edureka.co/python Line Understanding Linear Regression Algorithm
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine LearningTraining with Python www.edureka.co/python Regression Line Least Square Method
  • 18.
    Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine LearningTraining with Python www.edureka.co/python Estimated Value Actual Value error error
  • 19.
  • 20.
  • 21.
    Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Trainingwith Python www.edureka.co/python y = mx + c Distance travelled in a fixed duration of time
  • 22.
    Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Trainingwith Python www.edureka.co/python y = mx + c Speed of Vehicle
  • 23.
    Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Trainingwith Python www.edureka.co/python y = mx + c m = +ve slope of line
  • 24.
    Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Trainingwith Python www.edureka.co/python y = mx + c c = y - intercept of the line
  • 25.
  • 26.
    Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Trainingwith Python www.edureka.co/python y = - mx + c Time taken to travel a fixed distance
  • 27.
    Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Trainingwith Python www.edureka.co/python y = - mx + c Speed of Vehicle
  • 28.
    Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Trainingwith Python www.edureka.co/python y = - mx + c m = -ve slope of line
  • 29.
    Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Trainingwith Python www.edureka.co/python y = - mx + c c = y - intercept of the line
  • 30.
    Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine LearningTraining with Python www.edureka.co/python y = mx + c Independent Variable Dependent Variable
  • 31.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
  • 32.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
  • 33.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ Understanding Linear Regression Algorithm
  • 34.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean: เดฅ๐’™ 3 18/53.6 mean : เดฅ๐’š Understanding Linear Regression Algorithm
  • 35.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6( , ) Understanding Linear Regression Algorithm
  • 36.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean3( , )3.6 Understanding Linear Regression Algorithm
  • 37.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 38.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 Understanding Linear Regression Algorithm
  • 39.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’ Understanding Linear Regression Algorithm
  • 40.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’ 3 Understanding Linear Regression Algorithm
  • 41.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 1 3 โˆ’3 Understanding Linear Regression Algorithm
  • 42.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 Understanding Linear Regression Algorithm
  • 43.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ Understanding Linear Regression Algorithm
  • 44.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ 3 Understanding Linear Regression Algorithm
  • 45.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 2 โˆ’ 3 Understanding Linear Regression Algorithm
  • 46.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 Understanding Linear Regression Algorithm
  • 47.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 Understanding Linear Regression Algorithm
  • 48.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 Understanding Linear Regression Algorithm
  • 49.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 50.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3 Understanding Linear Regression Algorithm
  • 51.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3.6 3 โˆ’ Understanding Linear Regression Algorithm
  • 52.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3.6 3 โˆ’ Understanding Linear Regression Algorithm
  • 53.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ 3 โˆ’3.6 Understanding Linear Regression Algorithm
  • 54.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 Understanding Linear Regression Algorithm
  • 55.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 Understanding Linear Regression Algorithm
  • 56.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 Understanding Linear Regression Algorithm
  • 57.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.4 Understanding Linear Regression Algorithm
  • 58.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.4 1.4 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 59.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ 3 -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 -2y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 where m = ๐›ด Understanding Linear Regression Algorithm
  • 60.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 -1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 61.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 62.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 63.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 2 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 64.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+cy = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 65.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 66.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -2 -1 0 1 2 -0.6 0.4 -1.6 0.4 1.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 67.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ)๐‘ฅ โˆ’ าง๐‘ฅ 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 68.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 69.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 70.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 71.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 3.6 y = mx+c ๐›ด = 10 ๐›ด = 4 = 4 10 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด ๐›ด Understanding Linear Regression Algorithm
  • 72.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 0.4 Understanding Linear Regression Algorithm
  • 73.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3 Understanding Linear Regression Algorithm
  • 74.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6=0.4x3 + c Understanding Linear Regression Algorithm
  • 75.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6 = 1.2+ c Understanding Linear Regression Algorithm
  • 76.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 3.6 - 1.2 = c Understanding Linear Regression Algorithm
  • 77.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 c = 2.4 Understanding Linear Regression Algorithm
  • 78.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ mean 3 3.6 ๐‘ฅ โˆ’ าง๐‘ฅ -2 -1 0 1 2 ๐‘ฆ โˆ’ เดค๐‘ฆ -0.6 0.4 -1.6 0.40.4 1.4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 4 1 0 1 4 (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (๐‘ฅ โˆ’ าง๐‘ฅ)(๐‘ฆ โˆ’ เดค๐‘ฆ) ๐›ด = 10 ๐›ด = 4 ๐‘ฅ โˆ’ าง๐‘ฅ 2 m = ๐›ด = 4 10 c = 2.4 m = 0.4 c = 2.4 y = 0.4x + 2.4 Understanding Linear Regression Algorithm
  • 79.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 80.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 81.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 82.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line Distance between actual & predicted value error error error error
  • 83.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Finding the best fit line Machine Learning Training with Python www.edureka.co/python
  • 84.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Letโ€™s check the Goodness of fit
  • 85.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. What is R- Square? Machine Learning Training with Python www.edureka.co/python โ–ช R-squared value is a statistical measure of how close the data are to the fitted regression line โ–ช It is also known as coefficient of determination, or the coefficient of multiple determination
  • 86.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ 1 2 4 5 60 3 1 2 3 4 5 Actual Value 1 2 3 4 5 3 4 2 4 5 ๐‘ฅ ๐‘ฆ mean
  • 87.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Actual Value mean distance = actual - mean Calculation of ๐‘น ๐Ÿ
  • 88.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Predicted Value 1 2 3 4 5 2.8 ๐‘ฅ 3.2 4.0 3.6 4.4 Regression line Calculation of ๐‘น ๐Ÿ ๐‘ฆ๐‘
  • 89.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Distance actual - mean Distance predicted - mean 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value Regression line vs This is nothing but ๐‘…2 = Calculation of ๐‘น ๐Ÿ ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
  • 90.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
  • 91.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
  • 92.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 6.4 1.6 0 1.6 6.4 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2 ๐›ด ๐›ด
  • 93.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 0.36 0.16 2.56 0.16 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 0.64 0.16 0 0.16 0.64 1.6 ๐‘…2 = ๐‘ฆ โˆ’ เดค๐‘ฆ 2 (๐‘ฆ๐‘ โˆ’เดค๐‘ฆ 2 ๐›ด ๐›ด 5.2๐›ด ๐›ด 1.6 5.2 = ๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ 2
  • 94.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘ฅ 1 2 3 4 5 3 4 2 4 5 ๐‘ฆ โ€“ 0.6 0.4 โ€“1.6 0.4 1.4 ๐‘ฆ โˆ’ เดค๐‘ฆ mean y 3.6 ๐‘ฆ๐‘๐‘ฆ โˆ’ เดค๐‘ฆ 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (๐‘ฆ๐‘ โˆ’ เดค๐‘ฆ) -0.8 -0.4 0 0.4 0.8 (๐‘ฆ๐‘ โˆ’โˆ’เดค๐‘ฆ 2 6.4 1.6 0 1.6 6.4 11.32 16 ๐‘…2 โ‰ˆ 0.3
  • 95.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.3 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 96.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.7 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 97.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.9 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 98.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 1 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 99.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of ๐‘น ๐Ÿ ๐‘…2 โ‰ˆ 0.02 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 100.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Are Low R-squared values always Machine Learning Training with Python www.edureka.co/python
  • 101.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. Are High R-squared values always Machine Learning Training with Python www.edureka.co/python
  • 102.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved. DEMO Letโ€™s learn to code ยฉ MadeByShape Ltd. Web Design Manchester 2018. All Rights Reserved.
  • 103.
    Copyright ยฉ 2017,edureka and/or its affiliates. All rights reserved.