
Simple imputation (Geron Ch 2, morie.fn grimp)
Source:R/geron_train_native.R
morie_geron_simple_imputer.RdFills NA per column with the mean / median / most frequent observed
value. numpy's mode takes the SMALLEST value among ties, which
sort(unique(.)) reproduces here.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_simple_imputer(V)
#> $imputed
#> [1] 1 2 3 4 5 6 7 8
#>
#> $statistics
#> [1] 4.5
#>
#> $n_missing
#> [1] 0
#>
#> $missing_by_column
#> [1] 0
#>
#> $strategy
#> [1] "mean"
#>
#> $estimate
#> [1] 1 2 3 4 5 6 7 8
#>
#> $n
#> [1] 8
#>