Skip to content

Commit 635925b

Browse files
authored
Merge pull request #858 from larissa95/master
Fixed error in linear regression formula
2 parents 6d936e4 + 27efdda commit 635925b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Linear Regression/README.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ for _ in 1...numberOfIterations {
7575

7676
The program loops through each data point (each car age and car price). For each data point it adjusts the intercept and the slope to bring them closer to the correct values. The equations used in the code to adjust the intercept and the slope are based on moving in the direction of the maximal reduction of these variables. This is a *gradient descent*.
7777

78-
We want to minimise the square of the distance between the line and the points. We define a function `J` which represents this distance - for simplicity we consider only one point here. This function `J` is proportional to `((slope.carAge + intercept) - carPrice)) ^ 2`.
78+
We want to minimise the square of the distance between the line and the points. We define a function `J` which represents this distance - for simplicity we consider only one point here. This function `J` is proportional to `((slope * carAge + intercept) - carPrice)) ^ 2`.
7979

8080
In order to move in the direction of maximal reduction, we take the partial derivative of this function with respect to the slope, and similarly for the intercept. We multiply these derivatives by our factor alpha and then use them to adjust the values of slope and intercept on each iteration.
8181

0 commit comments

Comments
 (0)