Skip to contents

Integer codes against a fixed level order; the codes are 0-based to match Python. Implies order AND equal spacing, which is why one-hot is the safer default for a linear model.

Usage

morie_geron_ordinal_encoding(X, categories = NULL)

Arguments

X

Vector or matrix of categories.

categories

Optional list of level vectors.

Value

List with encoded (0-based), categories, n_categories, estimate, n.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_ordinal_encoding(V)
#> $encoded
#>      [,1]
#> [1,]    0
#> [2,]    1
#> [3,]    2
#> [4,]    3
#> [5,]    4
#> [6,]    5
#> [7,]    6
#> [8,]    7
#> 
#> $categories
#> $categories[[1]]
#> [1] 1 2 3 4 5 6 7 8
#> 
#> 
#> $n_categories
#> [1] 8
#> 
#> $estimate
#>      [,1]
#> [1,]    0
#> [2,]    1
#> [3,]    2
#> [4,]    3
#> [5,]    4
#> [6,]    5
#> [7,]    6
#> [8,]    7
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Ordinal (integer) encoding against a fixed level order"
#>