Skip to contents

If theta is one longer than the columns of X, a leading column of ones is prepended, matching the Python implicit-bias rule.

Usage

morie_geron_linreg_mse_cost(X, y, theta)

Arguments

X

Design matrix.

y

Targets.

theta

Coefficients.

Value

List with cost, mse, gradient, grad_norm, residuals, predictions, estimate, n.

Examples

morie_geron_linreg_mse_cost(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = c(1, 2, 3, 4, 5, 6, 7, 8),
  theta = 0.5)
#> $cost
#> [1] 6.375
#> 
#> $mse
#> [1] 6.375
#> 
#> $gradient
#> [1] -25.5
#> 
#> $grad_norm
#> [1] 25.5
#> 
#> $residuals
#> [1] -0.5 -1.0 -1.5 -2.0 -2.5 -3.0 -3.5 -4.0
#> 
#> $predictions
#> [1] 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
#> 
#> $estimate
#> [1] 6.375
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "MSE cost and analytic gradient for linear regression"
#>