Skip to contents

Logistic cost gradient (Geron Eq 4-18, morie.fn grlogg)

Usage

morie_geron_logistic_cost_gradient(X, y, theta)

Arguments

X, y, theta

Design, 0/1 targets and parameters.

Value

List with gradient, grad_norm, probabilities, errors.

Examples

set.seed(5)
X <- cbind(1, rnorm(30))
y <- rbinom(30, 1, plogis(X %*% c(-0.2, 1)))
morie_geron_logistic_cost_gradient(X, y, theta = c(0, 0.5))
#> $gradient
#> [1] 0.034410838 0.005803232
#> 
#> $grad_norm
#> [1] 0.03489675
#> 
#> $probabilities
#>  [1] 0.3964144 0.6664516 0.3480218 0.5087669 0.7017658 0.4252021 0.4412518
#>  [8] 0.4212399 0.4643389 0.5172567 0.6488106 0.4010986 0.3681419 0.4803184
#> [15] 0.3691465 0.4826337 0.4258859 0.2512450 0.5300658 0.4676259 0.6107001
#> [22] 0.6156050 0.6756783 0.5874371 0.6009691 0.4633805 0.6702453 0.6790451
#> [29] 0.4185957 0.3949869
#> 
#> $errors
#>  [1]  0.3964144 -0.3335484 -0.6519782 -0.4912331  0.7017658 -0.5747979
#>  [7] -0.5587482  0.4212399 -0.5356611 -0.4827433  0.6488106  0.4010986
#> [13]  0.3681419 -0.5196816  0.3691465 -0.5173663  0.4258859  0.2512450
#> [19] -0.4699342  0.4676259  0.6107001  0.6156050 -0.3243217 -0.4125629
#> [25] -0.3990309  0.4633805  0.6702453 -0.3209549  0.4185957  0.3949869
#> 
#> $estimate
#> [1] 0.034410838 0.005803232
#> 
#> $n
#> [1] 30
#>