High School

Linear Regression

Suppose the following are prices of recently sold houses in some neighborhood:

House area in square feet: 1235, 1691, 1824, 2000
Sold at price (in US$ 1k): 630, 780, 825, 999

Use linear regression to fit these data with a line: [tex]y = w_1x + w_0[/tex], i.e., calculate the two weights. Then, predict the price of a new house on the market with an area of 1900 square feet.

Answer :

The predicted price of the new house on the market with an area of 1900 square feet is $697,620.The Linear Regression model is a supervised learning algorithm that predicts the target variable as a continuous value.

In the problem above, the Linear Regression algorithm is used to predict the prices of a house based on its square footage.

The regression equation,

y = wx + b, represents the equation of a straight line,

where w represents the slope of the line, and b represents the y-intercept. The two weights are w1 and w0.

In order to calculate the two weights, we need to follow the below steps:

First, we need to find the mean of both x (house area in square feet) and y (sold price).

x = [1235, 1691, 1824, 2000]

y = [630, 780, 825, 999]

mean_x = (1235 + 1691 + 1824 + 2000)/4

= 1687.5

mean_y = (630 + 780 + 825 + 999)/4

= 808.5

Next, we need to calculate the covariance of x and y.covariance

= ∑(xi - mean_x)(yi - mean_y) / (n - 1)

where n is the number of observations.covariance

= ((1235 - 1687.5)(630 - 808.5) + (1691 - 1687.5)(780 - 808.5) + (1824 - 1687.5)(825 - 808.5) + (2000 - 1687.5)(999 - 808.5)) / (4 - 1)

covariance = 72245.8333

Next, we need to calculate the variance of x.

variance =[tex]sum_{n - 1}^{xi - mean_x\^2[/tex]

variance =[tex]((1235 - 1687.5)^2 + (1691 - 1687.5)^2 + (1824 - 1687.5)^2 + (2000 - 1687.5)^2) / (4 - 1)[/tex]

variance = 175722.9167

Now we can calculate w1 and w0.w1

= covariance / variancew1

= 72245.8333 / 175722.9167w1

= 0.4119w0

= mean_y - w1 * mean_xw0

= 808.5 - 0.4119 * 1687.5w0

= -142.58

So the equation of the line is:y = 0.4119x - 142.58

Finally, to predict the price of a new house on the market with an area of 1900 sf,

we substitute x = 1900 in the equation and solve for y:

y = 0.4119 * 1900 - 142.58y

= 697.62

Therefore, the predicted price of the new house on the market with an area of 1900 square feet is $697,620.

To know more about Linear Regression visit:

https://brainly.com/question/30401933

#SPJ11

Other Questions