Linear Regression PDF
Document Details
Uploaded by IrreproachableMossAgate5603
Tags
Summary
This document explains linear regression, a statistical method used to model the relationship between a dependent variable and one or more independent variables. It covers mathematical models, calculations, and an example for the regression analysis method. The concepts of understanding linear regression and calculating R-values are included in the document. The document intends to teach the concepts and theory behind linear regression.
Full Transcript
Linear Regression Regression A statistical measure that determine the strength of the relationship between the one dependent variable (y) and other independent variables (x1, x2, x3……) This is done to gain information about one through knowing values of the others. It is basically used fo...
Linear Regression Regression A statistical measure that determine the strength of the relationship between the one dependent variable (y) and other independent variables (x1, x2, x3……) This is done to gain information about one through knowing values of the others. It is basically used for predicting and forecasting. Linear Regression The simplest mathematical linear relationship between two variables x and y. The change in one variable make the other variable change. In other words a dependency of one variable to other. Linear Regression Mathematical Model y = mx + c 𝑌 = 𝑏0 + 𝑏1 ∗ 𝑋+ ∈ Y = Dependent Variable X = Independent Variable b0 = Y - Intercept b1 = Slope of the line ∈ = Error Variable Linear Regression Mathematical Model Linear Regression Mathematical Model Linear Regression Mathematical Model y = mx + c 3.6 = 0.2*3 + c → c=3 y = 0.2x + 3 Understanding Linear Regression y = mx + c x y x-ẋ y - ẏ (x − ẋ )2 (x - ẋ)(y - ẏ) 3.6 = 0.2*3 + c → c=3 1 3 -2 -0.6 4 1.2 6 2 4 -1 0.4 1 -0.4 5 3 4 0 0.4 0 0 4 2 1 -1.6 1 -1.6 4 5 5 2 1.4 4 2.8 Y - AXIS 3 Mean 3 3.6 = 10 = 2 2 σ x − ẋ (y − ẏ ) 2 1 m= = σ (x − ẋ )2 10 0 0 1 2 3 X - AXIS 4 5 6 y = 0.2x + 3 Linear Regression Mathematical Model Linear Regression Mathematical Model x y y-ẏ (y - ẏ)2 yp yp - ẏ (yp − ẏ )2 1 3 -0.6 0.36 3.2 -0.4 0.16 y = 0.2x + 3 2 4 0.4 0.16 3.4 -0.2 0.04 3 4 0.4 0.16 3.6 0 0 4 2 -1.6 2.56 3.8 0.2 0.04 5 5 1.4 1.96 4.0 0.4 0.16 Linear Regression Mathematical Model x y x - ẋ y - ẏ (x − ẋ (x - ẋ)(y - )2 ẏ) 1 3 -2 -0.6 4 1.2 2 4 -1 0.4 1 -0.4 3 4 0 0.4 0 0 4 2 1 -1.6 1 -1.6 5 5 2 1.4 4 2.8 y = 0.2x + 3 Mean Square Error 6 m = 0.2 c=3 y = 0.2x + 3 5 5 4 4 4 3.8 4 For these values, the predicted values 3.6 3.2 3.4 for y for x = (1,2,3,4,5) will be - 3 Line Of Regression Y - AXIS 3 y = 0.2 * 1 + 3 = 3.2 2 2 y = 0.2 * 2 + 3 = 3.4 y = 0.2 * 3 + 3 = 3.6 1 y = 0.2 * 4 + 3 = 3.8 0 y = 0.2 * 5 + 3 = 4.0 0 1 2 3 4 5 6 X - AXIS R - Square R – Squared value is a measure of how close the data is to the fitted regression line. It is also known as Coefficient of Determination. σ (yp − ẏ )2 R2 = σ (y − ẏ )2 Calculation 0f R2 x y y-ẏ (y - ẏ)2 yp yp - ẏ (yp − ẏ )2 1 3 -0.6 0.36 3.2 -0.4 0.16 2 4 0.4 0.16 3.4 -0.2 0.04 3 4 0.4 0.16 3.6 0 0 4 2 -1.6 2.56 3.8 0.2 0.04 5 5 1.4 1.96 4.0 0.4 0.16 Mean 3 3.6 = 5.2 = 0.4 𝟎. 𝟒 R2 = 𝟓. 𝟐 ≈ 0.08 Line drawn not accurate then by using equation y=mx+c , by changing m value we have to calculate accuracy for each m. Whenever you get the maximum accuracy that will be the best & final line Above example tell how leaner regression model works Practical approach(LR model) : predicating salary of employee according to the work experience. We are gating 0.08=8% its poor accuracy due less number sample of data Basically, R square model not good approach its used only once in the model Line drawn not accurate then by using equation y=mx+c , by changing m value we have to calculate accuracy for each m. Whenever you get the maximum accuracy that will be the best & final line Above example tell how leaner regression model works Practical approach(LR model) : predicating salary of employee according to the work experience. Line drawn not accurate then by using equation y=mx+c , by changing m value we have to calculate accuracy for each m. Whenever you get the maximum accuracy that will be the best & final line Above example tell how leaner regression model works This step of optimizing the model is known as gradient descent optimization >> Neural Network it will come in Deep Learning