We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b10055 commit 7a5f58cCopy full SHA for 7a5f58c
Linear Regression/README.markdown
@@ -50,9 +50,10 @@ This is how we can represent our straight line:
50
```swift
51
var intercept = 0.0
52
var slope = 0.0
53
-func predictedCarPrice(carAge: Double) -> Double {
+func predictedCarPrice(_ carAge: Double) -> Double {
54
return intercept + slope * carAge
55
}
56
+
57
```
58
Now for the code which will perform the iterations:
59
@@ -63,7 +64,7 @@ let alpha = 0.0001
63
64
65
for n in 1...numberOfIterations {
66
for i in 0..<numberOfCarAdvertsWeSaw {
- let difference = carPrice[i] - predictedCarPrice(carAge: carAge[i])
67
+ let difference = carPrice[i] - predictedCarPrice(carAge[i])
68
intercept += alpha * difference
69
slope += alpha * difference * carAge[i]
70
0 commit comments