
Polynomial feature expansion (Geron Ch 4, morie.fn grpoly)
Source:R/geron_train_native.R
morie_geron_polynomial_features.Rd[1, X, X^2, ..., X^d] per feature, powers only, no cross terms, so
the column order is (bias), then all features at power 1, then all at
power 2, and so on. powers entries are 0-based (feature, power)
pairs with (0, 0) marking the bias.
Examples
morie_geron_polynomial_features(X = c(1, 2, 3, 4, 5, 6, 7, 8), degree = 5L)
#> $features
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 1 1 1 1 1 1
#> [2,] 1 2 4 8 16 32
#> [3,] 1 3 9 27 81 243
#> [4,] 1 4 16 64 256 1024
#> [5,] 1 5 25 125 625 3125
#> [6,] 1 6 36 216 1296 7776
#> [7,] 1 7 49 343 2401 16807
#> [8,] 1 8 64 512 4096 32768
#>
#> $powers
#> $powers[[1]]
#> [1] 0 0
#>
#> $powers[[2]]
#> [1] 0 1
#>
#> $powers[[3]]
#> [1] 0 2
#>
#> $powers[[4]]
#> [1] 0 3
#>
#> $powers[[5]]
#> [1] 0 4
#>
#> $powers[[6]]
#> [1] 0 5
#>
#>
#> $n_features
#> [1] 6
#>
#> $estimate
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 1 1 1 1 1 1
#> [2,] 1 2 4 8 16 32
#> [3,] 1 3 9 27 81 243
#> [4,] 1 4 16 64 256 1024
#> [5,] 1 5 25 125 625 3125
#> [6,] 1 6 36 216 1296 7776
#> [7,] 1 7 49 343 2401 16807
#> [8,] 1 8 64 512 4096 32768
#>
#> $n
#> [1] 8
#>