Skip to main content

Linear Regression in Power BI

Linear Regression is Predictive model used for finding the linear relationship between a dependent and one or more independent variables. In regression the dependent variable has to be continuous numerical (not categorical like Green, Yellow etc).

In Simple linear regression, we have one independent variable and one dependent variable. It is also known as Univariate linear regression, as there is only one independent variable.

In Multiple linear regressions, we have more than one independent variable and one dependent variable. It is also known as multivariate linear regression, as there is more than one independent variable.

Now our goal is to predict the home price by using the Simple Linear Regression.



(Name of the above table is SimpleLinearRegression)

In this table we have the prices of home based on the Area of that home. Here we have to predict the Price based on the given Area. As we are predicting the price based on the area. So, Price is the dependent variable and Area is the independent variable.

Formula for Predicting the price:-

 Y = mx + b

Here y is the Dependent variable, x is the independent variable, m is the slope means like how much Y changes when x change and b is the intercept of the Y-axis

Now our aim is to predict the price of a home whose area is 4200.Means 4200 is the independent variable(x).

Formula to Find m =





Now in order to find the slope(m) we need few calculated columns and measures.






Here we have added two calculated column to our dataset. These are ;

XY = SimpleLinearRegression[Area(X)]*SimpleLinearRegression[Price(Y)]

x-square = SimpleLinearRegression[Area(X)]^2

 

We have created few measures as well. These are ;

n = Countrows(SimpleLinearRegression)

XYsum = Sum(SimpleLinearRegression[XY])

Area(x)sum = sum(SimpleLinearRegression[Area(X)]) 

Price(Y)Sum = sum(SimpleLinearRegression[Price(Y)])

X-square(Sum) = Sum(SimpleLinearRegression[x-square])

 

Now create a measure in order to find m by simply putting the above existing measure.


m(slope) =

 DIVIDE (

    [n] * [XYsum] - [Area(x)sum] * [Price(Y)Sum],

    [n] * [X-square(Sum)] - [Area(x)sum] * [Area(x)sum],

    0

)

  

Formula to Find b =





Now create a measure in order to find b.

b(Intercept) =

DIVIDE (

    [Price(Y)Sum] * [X-square(Sum)] - [Area(x)sum] * [XYsum],

    [n] * [X-square(Sum)] - [Area(x)sum] * [Area(x)sum],

    0

)

 

 

Now we have values for m, x and b. So, create a measure for finding the predicted price.

Y(Predicted Price) =

[m(slope)] * 4200 + [b(Intercept)]

 


 Now you can see the predicted price in the above card visual. Which is 750924.66.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Comments

Popular posts from this blog

What is FTP ?

  FTP -FTP stands for file transfer protocol. -The Transport protocol of FTP is TCP     because it requires reliability. -The port number of FTP is 20/21.Port 20   performs the task of forwarding and   transferring of data and port 21 performs   the task of transmitting of commands. -It is a standard internet protocol provided   by TCP/IP for transmitting the file(which     may contain any kind of digital   information,such as text document,   movie ,image etc.) from one device to   another. -It is mainly used for transferring the web   page files from their creater to the   computer that acts as a server for other   computer on internet and it is also used   for downloading the files to computer   from other servers. -The main competitor for FTP is Http and   now sites runs Http servers instead of   FT...

What is Hub ?

what is a Hub ? Hub is a networking device which is used to connect multiple devices together in LAN(local area network). Hub works under physical layer of OSI(open system interconnection) model. It is purely hardware device where data reaches from one or, more nodes and is forwarded to one or, more nodes. Traffic is high in hub because it is purely hardware .It has not software to determine the destination address.so,it does only forwarding but not filtering.Lets take an example for better understand:-             If pc1 sends data to pc2,Data will goes to pc2 and also data goes to pc3 and pc4.which means hub can not do filtering .It can do only forwarding.                                                                                  ...

What is SMTP ?

 SMTP  -SMTP stands for simple mail transfer   protocol. -SMTP is an application layer protocol. -The transfer protocol of SMTP is TCP(Transmission control protocol)    because TCP is a reliable and connection Oriented protocol.TCP gurantees e-mail delivery . -It uses TCP port 25. -A few webmail services like G-mail use   unofficial port 465 for SMTP. -SMTP requires each message in 7-bit   ASCII(American Standard Code for   Information Interchange ) format. -SMTP is used by the client to send mail to servers because SMTP is a push protocol.It is used to send mail from sender to senders mail server and it is also used to send mail to receivers mail server from senders mail server . - Recepient download the mail from the mail server using POP3 or, IMAP .They can also just view the mail on the server by using webmail. Some SMTP commands:  •HELO and EHLO:- Command that initiate a new protocol session...