8000 Add code formatting to distinguish function name · codee/swift-algorithm-club@be2167c · GitHub
[go: up one dir, main page]

Skip to content

Commit be2167c

Browse files
committed
Add code formatting to distinguish function name
1 parent 9e715c3 commit be2167c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Linear Regression/README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ for n 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 ad 91B8 just 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 minimse 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 proprotional to `((slope.carAge+intercept) - carPrice))^2`.
78+
We want to minimse 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 proprotional 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

@@ -132,7 +132,7 @@ func linearRegression(_ xs: [Double], _ ys: [Double]) -> (Double) -> Double {
132132
return { x in intercept + slope * x }
133133
}
134134
```
135-
This function takes as arguments two arrays of Doubles, and returns a function which is the line of best fit. The formulas to calculate the slope and the intercept can be derived from our definition of the function J. Let's see how the output from this line fits our data:
135+
This function takes as arguments two arrays of Doubles, and returns a function which is the line of best fit. The formulas to calculate the slope and the intercept can be derived from our definition of the function `J`. Let's see how the output from this line fits our data:
136136

137137
![graph3](Images/graph3.png)
138138

0 commit comments

Comments
 (0)
0