Advice on rank-hot (thermometer) encoding of categorical variables


julia> XS = [1,2,3,4,5,4,3,2,1]

julia> N = maximum(XS);

julia> [Int(i≤x) for x in XS, i in 1:N]

or



julia> map(Base.splat(≥), Iterators.product(XS, 1:N))
9×5 Matrix{Bool}:
 1  0  0  0  0
 1  1  0  0  0
 1  1  1  0  0
 1  1  1  1  0
 1  1  1  1  1
 1  1  1  1  0
 1  1  1  0  0
 1  1  0  0  0
 1  0  0  0  0
1 Like