ContinuousEncoder docstring: wrong `drop_last` default and nonexistent `ordered_factors` option

Open Beginner friendly
#109 1 comment 1 reaction 1 assignee View on GitHub

Maintainers usually reply within 1 day

@ablaom is already working on this.

Since Nov 30, 2026.

  • #110 by @ablaom — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Domain
documentation

Research direction

Read the ContinuousEncoder docstring in src/transformers/other_transformers/continuous_encoder.jl, especially the Protocol and Hyper-parameters sections. Correct the stated drop_last default, clarify that one_hot_ordered_factors=true enables one-hot encoding for ordered factors, and finish the truncated option description. Done when the text matches the struct defaults and supported keyword behavior shown in the issue.

Written by the indexing model from the issue text.

Description

documentation

The docstring for ContinuousEncoder has the same kind of problem that #57 fixed for OneHotEncoder, plus a reference to a keyword that doesn't exist.

In src/transformers/other_transformers/continuous_encoder.jl the struct is

@with_kw_noshow mutable struct ContinuousEncoder <: Unsupervised
    drop_last::Bool                = false
    one_hot_ordered_factors::Bool  = false
end

but the docstring says:

  1. Hyper-parameters section (L132): drop_last=true, while the actual default is false.
  2. Protocol section (L97-L100): an OrderedFactor is coerced to Continuous "unless ordered_factors=false is specified, in which case one-hot encode it". There is no ordered_factors field, and the logic is the other way round: you get one-hot encoding by passing one_hot_ordered_factors=true.

Also the one_hot_ordered_factors bullet ends mid-sentence ("...coerce it directly to a (single) Continuous feature using the order").

Example
using MLJBase, MLJTransforms, CategoricalArrays

m = ContinuousEncoder()
@show m.drop_last m.one_hot_ordered_factors

X = (name=categorical(["Danesh", "Lee", "Mary", "John"]),
     grade=categorical(["A", "B", "A", "C"], ordered=true),
     height=[1.85, 1.67, 1.5, 1.67])

W = MLJBase.transform(fit!(machine(ContinuousEncoder(), X), verbosity=0), X)
@show keys(W)
W2 = MLJBase.transform(fit!(machine(ContinuousEncoder(one_hot_ordered_factors=true), X), verbosity=0), X)
@show keys(W2)

ContinuousEncoder(ordered_factors=false)

Output:

m.drop_last = false
m.one_hot_ordered_factors = false
keys(W) = (:name__Danesh, :name__John, :name__Lee, :name__Mary, :grade, :height)
keys(W2) = (:name__Danesh, :name__John, :name__Lee, :name__Mary, :grade__A, :grade__B, :grade__C, :height)
ERROR: LoadError: MethodError: no method matching ContinuousEncoder(; ordered_factors::Bool)
This method does not support all of the given keyword arguments (and may not support any).

Closest candidates are:
  ContinuousEncoder(; drop_last, one_hot_ordered_factors) got unsupported keyword argument "ordered_factors"

So with the defaults all four name levels are kept (no column dropped), and following the protocol text literally just errors.

Expected

The docstring should say drop_last=false, and the protocol bullet should read something like "unless one_hot_ordered_factors=true is specified, in which case one-hot encode it". The example at the bottom already passes drop_last=true explicitly, so it's fine as is.

Versions
  • MLJTransforms v0.2.4 (dev at d3e3db3)
  • MLJBase v1.15.4, CategoricalArrays v1.1.1
  • Julia 1.13.3
Dominant language
Julia
Stars
1
Forks
5
Avg merge
1d 4h
Merged PRs (30d)
6

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaAI/MLJTransforms.jl

All issues in JuliaAI/MLJTransforms.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.