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

HTTP

   HTTP:- -Http stands for hypertext transfer   protocol. -It is an application layer protocol. -The http is a set of rules for exchanging  files(text, graphics,video, record,images  and other multimedia files) on the   Www(world wide web). -It is an access method to access web   pages used on the internet . -Http is a part of protocol framework   called the internet protocol suite ,which   includes TCP/IP . -Http uses port number 80. Components of Http based system:- Http is a client server protocol , requests are send by one entity,the web user agent.Most of the time the user agent is a web browser. Generally 3 components are in http based based system.Like client, server and proxy . Client and server:- A server is a computing program or device that accepts and responds to requests made over a network.The device the sends request to the server and get response from the s...

MAC Address

MAC stands for media access control. MAC address is also known as physical address or hardware address or BIA(burnt-in-address).BIA is generally written in Cisco router switches.physical address is generally written in laptop/pc.MAC address is generally written in Mobile. MAC address is globally unic.The MAC address of a device is different from other devices.Many people are thinking there is only one mac address of a device but it is actually wrong ,Because there is no mac address of a laptop .There is a Mac address of your NIC(network interface controller) ,which is connected to your laptop .                                (NIC) If you change your NIC,then the Mac address of your laptop will be changed.NIC is a separate hardware component present in your computer used to connect with the network (home network or internet).There are so many ways that you can connect your laptop with the network like...

Differences between TCP and UDP

TCP vs. UDP  -TCP stands for transmission control   protocol whereas UDP stands for user   datagram protocol. -Tcp is a reliable and connection-oriented   Transport protocol whereas UDP is a less   reliable and connection-less protocol. -In tcp , Error control is   mandatory.because checksum is used at   the end of the TCP to detect errors   whereas error control is optional in case   of UDP . -TCP is comparatively slower than UDP. -The header size of TCP is 20-60 bytes   whereas header size of UDP is 8 bytes . -TCP doesn't supports broadcasting   whereas UDP supports broadcasting . -TCP is used by SMTP,FTP,HTTP,HTTPs   etc, whereas UDP is used by DHCP,DNS etc .