BetaML.jl icon indicating copy to clipboard operation
BetaML.jl copied to clipboard

Improve oneHotEncode stability for encoding integers embedding categories

Open sylvaticus opened this issue 3 years ago • 0 comments

julia> oneHotEncoder([-1,1,1])
ERROR: BoundsError: attempt to access 1-element Vector{Int64} at index [-1]
Stacktrace:
 [1] setindex!
   @ ./array.jl:903 [inlined]
 [2] oneHotEncoderRow(x::Int64; d::Int64, factors::UnitRange{Int64}, count::Bool)
   @ BetaML.Utils ~/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:64
 [3] oneHotEncoder(Y::Vector{Int64}; d::Int64, factors::UnitRange{Int64}, count::Bool)
   @ BetaML.Utils ~/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:127
 [4] oneHotEncoder(Y::Vector{Int64})
   @ BetaML.Utils ~/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:121
 [5] top-level scope
   @ REPL[5]:1

julia> oneHotEncoder([-1,1,1],factors=[-1,1])
ERROR: BoundsError: attempt to access 1-element Vector{Int64} at index [-1]
Stacktrace:
 [1] setindex!
   @ ./array.jl:903 [inlined]
 [2] oneHotEncoderRow(x::Int64; d::Int64, factors::UnitRange{Int64}, count::Bool)
   @ BetaML.Utils ~/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:64
 [3] oneHotEncoder(Y::Vector{Int64}; d::Int64, factors::Vector{Int64}, count::Bool)
   @ BetaML.Utils ~/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:127
 [4] top-level scope
   @ REPL[6]:1

sylvaticus avatar Mar 22 '22 15:03 sylvaticus