
One-hot encoding (Geron Ch 2, morie.fn grohe)
Source:R/geron_train_native.R
morie_geron_one_hot_encoding_grohe.RdOne-hot encoding (Geron Ch 2, morie.fn grohe)
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_one_hot_encoding_grohe(V)
#> $encoded
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 1 0 0 0 0 0 0 0
#> [2,] 0 1 0 0 0 0 0 0
#> [3,] 0 0 1 0 0 0 0 0
#> [4,] 0 0 0 1 0 0 0 0
#> [5,] 0 0 0 0 1 0 0 0
#> [6,] 0 0 0 0 0 1 0 0
#> [7,] 0 0 0 0 0 0 1 0
#> [8,] 0 0 0 0 0 0 0 1
#>
#> $levels
#> [1] 1 2 3 4 5 6 7 8
#>
#> $columns
#> [1] 1 2 3 4 5 6 7 8
#>
#> $n_columns
#> [1] 8
#>
#> $estimate
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 1 0 0 0 0 0 0 0
#> [2,] 0 1 0 0 0 0 0 0
#> [3,] 0 0 1 0 0 0 0 0
#> [4,] 0 0 0 1 0 0 0 0
#> [5,] 0 0 0 0 1 0 0 0
#> [6,] 0 0 0 0 0 1 0 0
#> [7,] 0 0 0 0 0 0 1 0
#> [8,] 0 0 0 0 0 0 0 1
#>
#> $n
#> [1] 8
#>