
MSE gradient of linear regression (Geron Ch 4, morie.fn hmbgdg)
Source:R/geron_ml_native.R
morie_geron_batch_gd_grad.Rdgrad J = (2/m) X^T (X theta - y); with eta one descent step too.
Examples
morie_geron_batch_gd_grad(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = c(1, 2, 3, 4, 5, 6, 7, 8), theta = 0.5)
#> $gradient
#> [1] -25.5
#>
#> $cost
#> [1] 6.375
#>
#> $residuals
#> [1] -0.5 -1.0 -1.5 -2.0 -2.5 -3.0 -3.5 -4.0
#>
#> $theta
#> [1] 0.5
#>
#> $theta_next
#> NULL
#>
#> $grad_norm
#> [1] 25.5
#>
#> $estimate
#> [1] 6.375
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Gradient of linear-regression MSE cost, (2/m) X^T (X theta - y)"
#>