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

Aperta Adatta ai principianti
#109 1 commento 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ablaom ci sta già lavorando.

Dal 30/11/2026.

  • #110 di @ablaom — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
documentation

Direzione di ricerca

Leggi il docstring di ContinuousEncoder in src/transformers/other_transformers/continuous_encoder.jl, in particolare le sezioni Protocol e Hyper-parameters. Correggi il valore predefinito indicato per drop_last, chiarisci che one_hot_ordered_factors=true abilita la codifica one-hot per i fattori ordinati e completa la descrizione troncata dell’opzione. Il lavoro è completato quando il testo corrisponde ai valori predefiniti della struct e al comportamento delle keyword supportate mostrati nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Julia
Stelle
1
Fork
5
Merge medio
1g 4h
PR unite (30g)
6

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaAI/MLJTransforms.jl

Tutte le issue di JuliaAI/MLJTransforms.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.