Skip to contents

grad J = (2/m) X^T (X theta - y); with eta one descent step too.

Usage

morie_geron_batch_gd_grad(X, y, theta, eta = NULL)

Arguments

X

Design matrix.

y

Targets.

theta

Parameters.

eta

Optional learning rate.

Value

List with gradient, cost, residuals, theta_next, grad_norm.

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)"
#>