Linear regression
#This was a note noted by WONG Zinhoo,
Reproduced
please
specify
the Source and the original link
#
Question: Price predict.
![](https://app.yinxiang.com/shard/s38/res/af4078e7-59d1-45d6-b608-b56910eb0fbb.png)
![](https://app.yinxiang.com/shard/s38/res/f23e5171-06e2-4581-ab21-b4026f8d9167.png)
![](https://app.yinxiang.com/shard/s38/res/b52bf442-2bd8-419d-8d07-1ac5162542b9.png)
Size in feet2(x)
|
Price ($) in 1000s (y)
|
2104
|
460
|
1416
|
232
|
1534
|
315
|
852
|
178
|
…
|
…
|
![](https://app.yinxiang.com/shard/s38/res/f020f924-be97-4597-bf78-529b1b7c3234.png)
![](https://app.yinxiang.com/shard/s38/res/f620d8bd-ba17-442b-b903-d3e69fba6dd2.png)
The above function is a liner function, with this function; we can present all the line in the 2-demensional plane by changing the parameter
![](https://app.yinxiang.com/shard/s38/res/6ea0ad50-1158-4e57-b031-71a39e4b52f1.png)
.
The question of linear regression is
How to find the best line’s function to fit the training parameters.
Cost Function
![](https://app.yinxiang.com/shard/s38/res/aad2c99f-3b9d-4920-888f-2a5f904f2d03.png)
The construction principle of the COST FUNCTION:
The
![](https://app.yinxiang.com/shard/s38/res/5c674a1b-90f2-413d-a82d-eba790fd5914.png)
in the brackets is the hypothesis value of X when the coefficients was
![](https://app.yinxiang.com/shard/s38/res/b1ab2f9b-c70d-4347-a601-79b6e5035481.png)
and
![](https://app.yinxiang.com/shard/s38/res/176ea03a-ef0f-41a6-acd4-71f6ebb108ab.png)
. Using this hypothesis minus the target value of Y; we got the distance between the hypothesis line and the training value (target) Y. By changing the value of
and
(to hypothesis function
![](https://app.yinxiang.com/shard/s38/res/bf4ed420-6610-4304-a205-bff44455f92a.png)
are coefficients, while, for Cost function they are arguments); we try to find the line which have minimum distance for all targets. So the function is constructed for:
Let
![](https://app.yinxiang.com/shard/s38/res/2baa221d-d776-4bca-89e7-c70d8f244a55.png)
more small,
Which equal to:
![](https://app.yinxiang.com/shard/s38/res/af2175ae-2c5a-4c3c-b1ab-cd77e5721342.png)
more small,
Which equal to
![](https://app.yinxiang.com/shard/s38/res/17da6a7e-0614-4989-9bde-d359d721caef.png)
more small,
Which equal to
![](https://app.yinxiang.com/shard/s38/res/47122555-79d8-4a1d-a560-167427b1ea17.png)
more small,
If we want to find the minimum value of
![](https://app.yinxiang.com/shard/s38/res/8d2bd935-e7b7-4de6-a93a-7bdb5b1c3e2e.png)
we need a derivation of
, for computing process more easier we build the
with
.
Linear regression tools
![](https://app.yinxiang.com/shard/s38/res/3dd70972-c209-4cf2-89ff-9dd9816aff8f.png)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Facebook:
http://www.facebook.com/zinhoowong
twitter:
https://twitter.com/WongZinhoo