
One-vs-One multiclass reduction (Geron Ch 3, morie.fn grovo)
Source:R/geron_train_native.R
morie_geron_one_vs_one.RdK(K-1)/2 pairwise duels; a positive score votes for the SECOND class of the pair, ties in the vote count go to the lowest class index.
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_one(X = X, y = y)
#> $predictions
#> [1] 2 3 6 9
#>
#> $votes
#> [,1] [,2] [,3] [,4]
#> [1,] 3 2 1 0
#> [2,] 2 3 1 0
#> [3,] 0 1 3 2
#> [4,] 0 1 2 3
#>
#> $classes
#> [1] 2 3 6 9
#>
#> $pairs
#> $pairs[[1]]
#> [1] 2 3
#>
#> $pairs[[2]]
#> [1] 2 6
#>
#> $pairs[[3]]
#> [1] 2 9
#>
#> $pairs[[4]]
#> [1] 3 6
#>
#> $pairs[[5]]
#> [1] 3 9
#>
#> $pairs[[6]]
#> [1] 6 9
#>
#>
#> $n_classifiers
#> [1] 6
#>
#> $accuracy
#> [1] 1
#>
#> $ties
#> [1] 0
#>
#> $estimate
#> [1] 2 3 6 9
#>
#> $n
#> [1] 4
#>