A Julia package providing a wide range of categorical encoders and data transformers to be used with the MLJ package.
For the following demo, you will need to additionally run Pkg.add("RDatasets").
using MLJ, MLJTransforms
import RDatasets
# 1. Load Data
X = RDatasets.dataset("HSAUR", "Forbes2000");
# 2. Load the model
FrequencyEncoder = @load FrequencyEncoder pkg="MLJTransforms"
encoder = FrequencyEncoder(
features=[:Country, :Category], # The categorical columns to select
ignore=false, # Whether to exclude or include selected columns
ordered_factor = false, # Whether to also encode columns of ordered factor elements
normalize=true # Whether to normalize the frequencies used for encoding
)
# 3. Wrap it in a machine and fit
mach = fit!(machine(encoder, X))
Xnew = transform(mach, X)See the full documentation for more information and a full list of transformers in this package.
