
One-vs-Rest multiclass reduction (Geron Ch 3, morie.fn grovr)
Source:R/geron_train_native.R
morie_geron_one_vs_rest.RdK classifiers, each class against the rest, argmax of the scores.
Arguments
- X
(m, n) design.
- y
Integer class labels.
- base_fit
Optional function(X, y_binary) returning a scorer.
- eta, n_iter
Passed to
morie_geron_train_logreg().
Examples
X <- matrix(c(1, 2, 1, 3, 1, 5, 1, 7), 4, byrow = TRUE)
y <- c(2, 3, 6, 9)
th <- c(0.5, 1.1)
morie_geron_elastic_net_cost(X, y, th, 0.4, 0.6)
#> $cost
#> [1] 0.8033
#>
#> $mse
#> [1] 0.4425
#>
#> $l1_penalty
#> [1] 0.264
#>
#> $l2_penalty
#> [1] 0.0968
#>
#> $l1_norm
#> [1] 1.1
#>
#> $l2_norm_sq
#> [1] 1.21
#>
#> $alpha
#> [1] 0.4
#>
#> $r
#> [1] 0.6
#>
#> $estimate
#> [1] 0.8033
#>
#> $n
#> [1] 4
#>
morie_geron_one_vs_rest(X = X, y = y)
#> $predictions
#> [1] 2 3 6 9
#>
#> $scores
#> [,1] [,2] [,3] [,4]
#> [1,] 1.621273 -0.1024271 -1.367815803 -7.463978
#> [2,] -1.979327 -0.6752868 -0.914809972 -5.554783
#> [3,] -9.180526 -1.8210063 -0.008798311 -1.736393
#> [4,] -16.381725 -2.9667257 0.897213350 2.081997
#>
#> $classes
#> [1] 2 3 6 9
#>
#> $n_classifiers
#> [1] 4
#>
#> $accuracy
#> [1] 1
#>
#> $coefficients
#> $coefficients[[1]]
#> [1] 4.411236 4.411236 -3.600599
#>
#> $coefficients[[2]]
#> [1] 0.5216462 0.5216462 -0.5728597
#>
#> $coefficients[[3]]
#> [1] -1.1369137 -1.1369137 0.4530058
#>
#> $coefficients[[4]]
#> [1] -5.641184 -5.641184 1.909195
#>
#>
#> $estimate
#> [1] 2 3 6 9
#>
#> $n
#> [1] 4
#>